If your upload fails with an ``error: espcomm_upload_mem failed`` message it's most likely due
to the pins being swapped. In that case, just swap ``RX`` and ``TX`` and try again - you won't break
anything if they're swapped.
.._sonoff_t3_eu_3g_v1.0-creating_firmware:
Step 3: Creating Firmware
-------------------------
The Sonoff T3 EU 3 Gang is based on the ``ESP8266`` platform (technically it's the ``ESP8285``, but for our purposes
they're the same) and is a subtype of the ``esp01_1m`` board.
With this information, you can step through the ESPHome wizard (``esphome sonoff_t3_us_3gang_v1.0.yaml wizard``),
or alternatively, you can just take the below configuration file and modify it to your needs.
..code-block:: yaml
esphome:
name: <NAME_OF_NODE>
platform: ESP8266
board: esp01_1m
wifi:
ssid: <YOUR_SSID>
password: <YOUR_PASSWORD>
api:
logger:
ota:
Now run ``esphome sonoff_t3_us_3gang_v1.0.yaml compile`` to validate the configuration and
pre-compile the firmware.
..note::
After this step, you will be able to find the compiled binary under
``<NAME_OF_NODE>/.pioenvs/<NAME_OF_NODE>/firmware.bin``. If you're having trouble with
uploading, you can also try uploading this file directly with other tools.
Step 4: Uploading Firmware
--------------------------
In order to upload the firmware, you're first going to need to get the chip into a flash mode, otherwise
the device will start up without accepting any firmware flash attempts.
To put ESP8266 into flash mode you need to connect ``GPIO0`` to ``GND`` when the device is powering up.
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``.
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.
The touchpads may light up.
..figure:: images/sonoff_t3_eu_3g_uart_v1.0.jpg
:align:center
:width:75.0%
Connect ``GND`` to ``R19`` right contact while powering the board.
Now you can finally run the upload command:
..code-block:: bash
esphome sonoff_t3_us_3gang_v1.0.yaml run
If successful, you should see something like this:
..figure:: images/sonoff_4ch_upload.png
:align:center
Hooray 🎉! You've now successfully uploaded the first ESPHome firmware to your Sonoff T3 EU 3 Gang. And in a moment,
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.
..note::
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,
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
and power it up from the mains power once safe to do so.
If above step does, however, not work, here are some steps that can help:
- Sometimes the UART bridge cannot supply enough current to the chip to operate, in this
case use a 3.3V supply you have lying around. A nice hack is to use the power supply of
NodeMCU boards. Simply connect the NodeMCU's 3.3V to VCC and GND to GND. **Do not attempt
to plug the device into a socket to overcome this problem while troubleshooting.**
- In other cases the ``TX`` and ``RX`` pin are reversed. Simple disconnect the device, swap
the two pins and put it into flash mode again.
Step 5: Adding the Button, Relay and LEDs
-----------------------------------------
Now we would like the T3 EU 3 Gang to actually do something, not just connect to WiFi and pretty much sit idle.
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