|
| 1 | +Using With Sonoff T3 EU 3 Gang |
| 2 | +===================================== |
| 3 | + |
| 4 | +.. seo:: |
| 5 | + :description: Instructions for putting Sonoff T3 EU 3C devices into flash mode and installing ESPHome on them. |
| 6 | + :image: sonoff_t3_eu_3g_v1.0.jpg |
| 7 | + |
| 8 | +ESPHome can also be used with Sonoff T3 EU 1/2/3 Gang wireless switches. These devices are |
| 9 | +basically just an ESP8266 chip with up to 3 relays to control power output and three backlit capacitive touch buttons to control the relays. |
| 10 | + |
| 11 | +.. figure:: images/sonoff_t3_eu_3g_v1.0.jpg |
| 12 | + :align: center |
| 13 | + :width: 75.0% |
| 14 | + |
| 15 | + Sonoff T3 EU 3 Gang WiFi switch. |
| 16 | + |
| 17 | +This guide will step you through setting up your Sonoff T3 EU 3 Gang and flashing the first ESPHome firmware |
| 18 | +with the serial interface. This should also work for the T1 EU 3 Gang and T2 EU 3 Gang with PCB version ``T1EU TOUCH V1.0`` from 2018. |
| 19 | +After that, you will be able to upload all future firmware updates with the remote |
| 20 | +Over-The-Air update process. |
| 21 | + |
| 22 | +.. note:: |
| 23 | + |
| 24 | + If you've previously installed Sonoff-Tasmota on your Sonoff T3 EU 3 Gang, you're in luck 😀 |
| 25 | + ESPHome can generate a firmware binary which you can then upload via the |
| 26 | + Tasmota web interface. To see how to create this binary, skip to :ref:`sonoff_t3_eu_3g_v1.0-creating_firmware`. |
| 27 | + |
| 28 | +Since firmware version 1.6.0, iTead (the creator of this device) has removed the ability to upload |
| 29 | +a custom firmware through their own upload process. Unfortunately, that means that the only way to |
| 30 | +flash the initial ESPHome firmware is by physically opening the device up and using the UART |
| 31 | +interface. |
| 32 | + |
| 33 | +.. warning:: |
| 34 | + |
| 35 | + Opening up this device can be very dangerous if not done correctly. While the device is open, |
| 36 | + you will be a single touch away from being electrocuted if the device is plugged in. |
| 37 | + |
| 38 | + So, during this *entire* guide **never ever** plug the device in. Also, you should only do this |
| 39 | + if you know what you're doing. If you, at any step, feel something is wrong or are uncomfortable |
| 40 | + with continuing, it's best to just stop for your own safety. |
| 41 | + |
| 42 | + It's your own responsibility to make sure everything you do during this setup process is safe. |
| 43 | + |
| 44 | +For this guide you will need: |
| 45 | + |
| 46 | +- Sonoff T3 EU 3 Gang 😉 |
| 47 | +- An USB to UART Bridge for flashing the device. These can be bought on Amazon for less than 5 dollars. |
| 48 | + Note that the bridge *must* be 3.3V compatible. Otherwise you will destroy your Sonoff. |
| 49 | +- Jumper wires to connect the UART bridge to the header pins and to connect GPIO0 to the Ground. |
| 50 | +- Computer running ESPHome or the Home Assistant ESPHome add-on. |
| 51 | +- Screwdriver to open up the Sonoff T3 EU 3 Gang. |
| 52 | + |
| 53 | +Have everything? Great! Then you can start. |
| 54 | + |
| 55 | + |
| 56 | +Step 1: Opening up the Sonoff T3 EU 3 Gang |
| 57 | +------------------------------------------ |
| 58 | + |
| 59 | +The first step is to open up the Sonoff T3 EU 3 Gang. Note that you do not have to run the original firmware |
| 60 | +supplied with the Sonoff T3 EU 3 Gang before doing this step. |
| 61 | + |
| 62 | +.. warning:: |
| 63 | + |
| 64 | + Just to repeat this: Make **absolutely sure** the device is not connected to any appliance or |
| 65 | + plugged in before doing this step. |
| 66 | + |
| 67 | +While the device is not plugged in, turn the device face down and put a narrow flat screwdriver into the slot at the bottom. |
| 68 | +With careful twisting motion detach the faceplate. |
| 69 | + |
| 70 | +.. figure:: images/sonoff_t3_eu_3g_back_v1.0.jpg |
| 71 | + :align: center |
| 72 | + :width: 60.0% |
| 73 | + |
| 74 | + Careful twisting motion. |
| 75 | + |
| 76 | +After that, use the same screwdriver to carefully lift the top PCB off of the switch. |
| 77 | +This PCB contains the ESP chip and what's left inside the switch body are relays. |
| 78 | + |
| 79 | +.. figure:: images/sonoff_t3_eu_3g_plate_off_v1.0.jpg |
| 80 | + :align: center |
| 81 | + :width: 60.0% |
| 82 | + |
| 83 | + "TOUCH BOARD" with touchpads holds the ESP chip. |
| 84 | + |
| 85 | +Step 2: Connecting UART |
| 86 | +----------------------- |
| 87 | + |
| 88 | +Now we need our computer to somehow establish a data connection to the board. For this we will |
| 89 | +have to connect the four wires on the UART to USB bridge to the UART pins of the Sonoff T3 v1.0. |
| 90 | + |
| 91 | +Fortunately for us, these pins on the ESP controller have dedicated solder pads on the PCB (``J3``). You can identify |
| 92 | +these by the ``VCC33``, ``RX``, ``TX`` and ``GND`` markings on the silk-screen. |
| 93 | + |
| 94 | +Now go ahead and connect these pins to your UART to USB bridge as seen in below image. Make sure |
| 95 | +that you connect these correctly, especially the ``VCC33`` and ``GND`` parts as you can otherwise |
| 96 | +destroy the chip. |
| 97 | + |
| 98 | +``VCC33`` should be connected to the ``3V3`` (**not** 5V) pin of the UART bridge, ``GND`` to ``GND`` |
| 99 | +and the same with ``RX``/``TX``. |
| 100 | + |
| 101 | +There's no need for soldering - for quick job like one time firmware flashing you can just hold pins in respective holes by hand |
| 102 | +provided **you are not touching any live contacts**, only the wires. |
| 103 | + |
| 104 | +.. figure:: images/sonoff_t3_eu_3g_touchpads_v1.0.jpg |
| 105 | + :align: center |
| 106 | + :width: 75.0% |
| 107 | + |
| 108 | + The Resistors ``R19``, ``R20`` and ``R21`` expose ``GPIO0``, ``GPIO9`` and ``GPIO10`` respectively. |
| 109 | + |
| 110 | +.. figure:: images/sonoff_t3_eu_3g_backplate_v1.0.jpg |
| 111 | + :align: center |
| 112 | + :width: 75.0% |
| 113 | + |
| 114 | + Backside also exposes ``GPIO2``. |
| 115 | + |
| 116 | +.. note:: |
| 117 | + |
| 118 | + If your upload fails with an ``error: espcomm_upload_mem failed`` message it's most likely due |
| 119 | + to the pins being swapped. In that case, just swap ``RX`` and ``TX`` and try again - you won't break |
| 120 | + anything if they're swapped. |
| 121 | + |
| 122 | +.. _sonoff_t3_eu_3g_v1.0-creating_firmware: |
| 123 | + |
| 124 | +Step 3: Creating Firmware |
| 125 | +------------------------- |
| 126 | + |
| 127 | +The Sonoff T3 EU 3 Gang is based on the ``ESP8266`` platform (technically it's the ``ESP8285``, but for our purposes |
| 128 | +they're the same) and is a subtype of the ``esp01_1m`` board. |
| 129 | +With this information, you can step through the ESPHome wizard (``esphome sonoff_t3_us_3gang_v1.0.yaml wizard``), |
| 130 | +or alternatively, you can just take the below configuration file and modify it to your needs. |
| 131 | + |
| 132 | +.. code-block:: yaml |
| 133 | +
|
| 134 | + esphome: |
| 135 | + name: <NAME_OF_NODE> |
| 136 | + platform: ESP8266 |
| 137 | + board: esp01_1m |
| 138 | +
|
| 139 | + wifi: |
| 140 | + ssid: <YOUR_SSID> |
| 141 | + password: <YOUR_PASSWORD> |
| 142 | +
|
| 143 | + api: |
| 144 | +
|
| 145 | + logger: |
| 146 | +
|
| 147 | + ota: |
| 148 | +
|
| 149 | +Now run ``esphome sonoff_t3_us_3gang_v1.0.yaml compile`` to validate the configuration and |
| 150 | +pre-compile the firmware. |
| 151 | + |
| 152 | +.. note:: |
| 153 | + |
| 154 | + After this step, you will be able to find the compiled binary under |
| 155 | + ``<NAME_OF_NODE>/.pioenvs/<NAME_OF_NODE>/firmware.bin``. If you're having trouble with |
| 156 | + uploading, you can also try uploading this file directly with other tools. |
| 157 | + |
| 158 | +Step 4: Uploading Firmware |
| 159 | +-------------------------- |
| 160 | + |
| 161 | +In order to upload the firmware, you're first going to need to get the chip into a flash mode, otherwise |
| 162 | +the device will start up without accepting any firmware flash attempts. |
| 163 | +To put ESP8266 into flash mode you need to connect ``GPIO0`` to ``GND`` when the device is powering up. |
| 164 | + |
| 165 | +This is a tricky process with T3 and the best is to hold the ground wire to the right side of the ``R19`` Resistor which is connected to ``GPIO0``. |
| 166 | +Keep holding ``GND`` and ``GPIO0`` connected for 2-4 seconds. The T3 EU 3 Gang should now be in a flash mode and should not blink with any LED. |
| 167 | +The touchpads may light up. |
| 168 | + |
| 169 | +.. figure:: images/sonoff_t3_eu_3g_uart_v1.0.jpg |
| 170 | + :align: center |
| 171 | + :width: 75.0% |
| 172 | + |
| 173 | + Connect ``GND`` to ``R19`` right contact while powering the board. |
| 174 | + |
| 175 | +Now you can finally run the upload command: |
| 176 | + |
| 177 | +.. code-block:: bash |
| 178 | +
|
| 179 | + esphome sonoff_t3_us_3gang_v1.0.yaml run |
| 180 | +
|
| 181 | +If successful, you should see something like this: |
| 182 | + |
| 183 | +.. figure:: images/sonoff_4ch_upload.png |
| 184 | + :align: center |
| 185 | + |
| 186 | +Hooray 🎉! You've now successfully uploaded the first ESPHome firmware to your Sonoff T3 EU 3 Gang. And in a moment, |
| 187 | +you will be able to use all of ESPHome's great features with your Sonoff T3 EU 3 Gang. Now you can put your T3 back together and fire up. |
| 188 | + |
| 189 | +.. note:: |
| 190 | + |
| 191 | + While now your T3 will start up and connect to your WiFi network if you power it up from UART it will not behave normally, |
| 192 | + it may flash random LEDs, turn on and off touchpads' backlight and not react on touching touchpads. This will all be fixed once you re-assemble your T3 |
| 193 | + and power it up from the mains power once safe to do so. |
| 194 | + |
| 195 | +If above step does, however, not work, here are some steps that can help: |
| 196 | + |
| 197 | +- Sometimes the UART bridge cannot supply enough current to the chip to operate, in this |
| 198 | + case use a 3.3V supply you have lying around. A nice hack is to use the power supply of |
| 199 | + NodeMCU boards. Simply connect the NodeMCU's 3.3V to VCC and GND to GND. **Do not attempt |
| 200 | + to plug the device into a socket to overcome this problem while troubleshooting.** |
| 201 | +- In other cases the ``TX`` and ``RX`` pin are reversed. Simple disconnect the device, swap |
| 202 | + the two pins and put it into flash mode again. |
| 203 | + |
| 204 | +Step 5: Adding the Button, Relay and LEDs |
| 205 | +----------------------------------------- |
| 206 | + |
| 207 | +Now we would like the T3 EU 3 Gang to actually do something, not just connect to WiFi and pretty much sit idle. |
| 208 | + |
| 209 | +Below you will find a table of all usable GPIO pins of the Sonoff T3 EU 3 Gang and a configuration file that exposes all |
| 210 | +of the basic functions. |
| 211 | + |
| 212 | +======================================== ========================================= |
| 213 | +``GPIO0`` Touchpad #1 (inverted) |
| 214 | +---------------------------------------- ----------------------------------------- |
| 215 | +``GPIO9`` Touchpad #2 (inverted) |
| 216 | +---------------------------------------- ----------------------------------------- |
| 217 | +``GPIO10`` Touchpad #3 (inverted) |
| 218 | +---------------------------------------- ----------------------------------------- |
| 219 | +``GPIO12`` Relay #1 and Touchpad #1 backlight |
| 220 | +---------------------------------------- ----------------------------------------- |
| 221 | +``GPIO5`` Relay #2 and Touchpad #2 backlight |
| 222 | +---------------------------------------- ----------------------------------------- |
| 223 | +``GPIO4`` Relay #3 and Touchpad #3 backlight |
| 224 | +---------------------------------------- ----------------------------------------- |
| 225 | +``GPIO13`` Blue LED (inverted) |
| 226 | +---------------------------------------- ----------------------------------------- |
| 227 | +``GPIO1`` ``RX`` pin (for external sensors) |
| 228 | +---------------------------------------- ----------------------------------------- |
| 229 | +``GPIO3`` ``TX`` pin (for external sensors) |
| 230 | +======================================== ========================================= |
| 231 | + |
| 232 | +.. code-block:: yaml |
| 233 | +
|
| 234 | + esphome: |
| 235 | + name: <NAME_OF_NODE> |
| 236 | + platform: ESP8266 |
| 237 | + board: esp01_1m |
| 238 | +
|
| 239 | + wifi: |
| 240 | + ssid: <YOUR_SSID> |
| 241 | + password: <YOUR_PASSWORD> |
| 242 | +
|
| 243 | + api: |
| 244 | +
|
| 245 | + logger: |
| 246 | +
|
| 247 | + ota: |
| 248 | +
|
| 249 | + binary_sensor: |
| 250 | + - platform: gpio |
| 251 | + pin: |
| 252 | + number: GPIO0 |
| 253 | + mode: INPUT_PULLUP |
| 254 | + inverted: True |
| 255 | + name: "Sonoff T3 EU 3 Gang Touchpad 1" |
| 256 | + - platform: gpio |
| 257 | + pin: |
| 258 | + number: GPIO9 |
| 259 | + mode: INPUT_PULLUP |
| 260 | + inverted: True |
| 261 | + name: "Sonoff T3 EU 3 Gang Touchpad 2" |
| 262 | + - platform: gpio |
| 263 | + pin: |
| 264 | + number: GPIO10 |
| 265 | + mode: INPUT_PULLUP |
| 266 | + inverted: True |
| 267 | + name: "Sonoff T3 EU 3 Gang Touchpad 3" |
| 268 | + - platform: status |
| 269 | + name: "Sonoff T3 EU 3 Gang Status" |
| 270 | +
|
| 271 | + switch: |
| 272 | + - platform: gpio |
| 273 | + name: "Sonoff T3 EU 3 Gang Relay 1" |
| 274 | + pin: GPIO12 |
| 275 | + - platform: gpio |
| 276 | + name: "Sonoff T3 EU 3 Gang Relay 2" |
| 277 | + pin: GPIO5 |
| 278 | + - platform: gpio |
| 279 | + name: "Sonoff T3 EU 3 Gang Relay 3" |
| 280 | + pin: GPIO4 |
| 281 | +
|
| 282 | + output: |
| 283 | + # Register the blue LED as a dimmable output .... |
| 284 | + - platform: esp8266_pwm |
| 285 | + id: blue_led |
| 286 | + pin: GPIO13 |
| 287 | + inverted: True |
| 288 | +
|
| 289 | + light: |
| 290 | + # ... and then make a light out of it. |
| 291 | + - platform: monochromatic |
| 292 | + name: "Sonoff T3 EU 3 Gang Blue LED" |
| 293 | + output: blue_led |
| 294 | +
|
| 295 | +
|
| 296 | +Above example also showcases an important concept of ESPHome: IDs and linking. In order |
| 297 | +to make all components in ESPHome as "plug and play" as possible, you can use IDs to define |
| 298 | +them in one area, and simply pass that ID later on. For example, above you can see a PWM (dimmer) |
| 299 | +output being created with the ID ``blue_led`` for the blue LED. Later on it is then transformed |
| 300 | +into a :doc:`monochromatic light </components/light/monochromatic>`. |
| 301 | +If you additionally want the buttons to control the relays, look at `the complete Sonoff T3 EU 3 Gang |
| 302 | +with automation example <https://github.com/esphome/esphomedocs/blob/current/devices/sonoff_t3_eu_3gang_v1.0.yaml>`__. |
| 303 | + |
| 304 | +Step 6: Finishing Up |
| 305 | +-------------------- |
| 306 | + |
| 307 | +If you're sure everything is done with the T3 EU 3 Gang and have double checked there's nothing that could cause a short |
| 308 | +in the case, you can put the T3 back together. |
| 309 | + |
| 310 | +Now triple- or even quadruple-check the UART bridge is not connected to the T3 EU 3 Gang, then comes the time when you can |
| 311 | +connect it. |
| 312 | + |
| 313 | +Happy hacking! |
| 314 | + |
| 315 | +See Also |
| 316 | +-------- |
| 317 | + |
| 318 | +- :doc:`sonoff` |
| 319 | +- :doc:`sonoff_4ch` |
| 320 | +- :doc:`sonoff_s20` |
| 321 | +- :ghedit:`Edit` |
0 commit comments