Delete devices directory (#3472)

This commit is contained in:
H. Árkosi Róbert 2024-02-25 21:18:01 +01:00 committed by GitHub
parent 0be12a282e
commit ccfbee538f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
48 changed files with 2 additions and 2672 deletions

View File

@ -22,8 +22,7 @@ ESP8266 side. Bi-directional symmetric request / response protocol is implemente
between ESP8266 and MCU. ``sonoff_d1`` component implements this protocol and
translates between HA light commands and serial messages.
For detailed instructions on how to replace the stock firmware with ESPHome see :doc:`/devices/sonoff_s20`.
You will need to locate GPIO0 pin and serial port. Photos below should help.
To replace the stock firmware with ESPHome you will need to locate GPIO0 pin and serial port. Photos below should help.
.. figure:: images/sonoff_d1_gpio0.jpg
:align: center

View File

@ -97,9 +97,7 @@ Sonoff B1 configuration example
This component can be used with a Sonoff B1 smart light bulb. To flash
the Sonoff B1, open the plastic cover and connect/solder wires to the
PCB pads (3.3V, RX, TX, GND, GPIO0). If you connect GPIO0 to GND
during power up, the device enters flash mode. For more information
about flashing Sonoff devices, see:
:doc:`/devices/sonoff_s20`. All LEDs are connected to a
during power up, the device enters flash mode. All LEDs are connected to a
chain of two MY9321 chips that are connected to GPIO12 and GPIO14. A
complete configuration for a Sonoff B1 looks like:

View File

@ -324,5 +324,4 @@ spares I/Os.
See Also
--------
- :doc:`/devices/nodemcu_esp8266`
- :ghedit:`Edit`

View File

@ -162,8 +162,6 @@ Both options USB and OTA are done by running the command:
esphome <some-yaml-file> run
More details on programming can be found on :doc:`/devices/sonoff_basic`
3. Prepping and installing
**************************
@ -213,6 +211,5 @@ You can now add your device to home assistant via the configurations page and un
See Also
--------
- :doc:`/devices/sonoff_basic`
- `Flashing Sonoff Basic <https://randomnerdtutorials.com/how-to-flash-a-custom-firmware-to-sonoff/>`__.
- `Adding ESPHome to Home Assistant <https://www.home-assistant.io/components/esphome/>`__.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 447 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@ -1,7 +0,0 @@
Devices
========
.. toctree::
:glob:
*

View File

@ -1,66 +0,0 @@
NodeMCU ESP32
=============
.. seo::
:description: Instructions for using NodeMCU ESP32 boards in ESPHome and a description of all their pins and uses.
:image: nodemcu_esp32.jpg
The NodeMCU ESP32 board (in some cases also known as ESP32-DevkitC)
is fully supported by ESPHome. Simply select ``ESP32`` when
the ESPHome wizard asks you for your platform and |nodemcu-32s|_ as the board type.
.. |nodemcu-32s| replace:: ``nodemcu-32s``
.. _nodemcu-32s: http://docs.platformio.org/en/latest/platforms/espressif32.html#nodemcu
.. code-block:: yaml
# Example configuration entry
esphome:
name: livingroom
esp32:
board: nodemcu-32s
The ESP32 boards often use the internal GPIO pin numbering on the board, this means that
you don't have to worry about other kinds of pin numberings, yay!
.. figure:: images/nodemcu_esp32-full.jpg
:align: center
Pins on the NodeMCU ESP32 development board.
Note that in certain conditions you *can* use the pins marked as ``INTERNAL`` in the above image.
- ``GPIO0`` is used to determine the boot mode on startup. It should therefore not be pulled LOW
on startup to avoid booting into flash mode. You can, however, still use this as an output pin.
- ``GPIO34``-``GPIO39`` can not be used as outputs (even though GPIO stands for "general purpose input
**output**"...).
- ``GPIO32``-``GPIO39``: These pins can be used with the :doc:`/components/sensor/adc` to measure
voltages.
- ``GPIO2``: This pin is connected to the blue LED on the board as seen in the picture above. It also supports
the :doc:`touch pad binary sensor </components/binary_sensor/esp32_touch>` as do the other
pins marked ``touch`` in the above image.
- ``5V`` is connected to the 5V rail from the USB bus and can be used to power the board. Note that
the UART chip is directly connected to this rail and you therefore **cannot** supply other voltages
into this pin.
.. code-block:: yaml
# Example configuration entry
esphome:
name: livingroom
esp32:
board: nodemcu-32s
binary_sensor:
- platform: gpio
name: "Pin GPIO23"
pin: GPIO23
See Also
--------
- :doc:`/components/esp32`
- :doc:`nodemcu_esp8266`
- :ghedit:`Edit`

View File

@ -1,78 +0,0 @@
NodeMCU ESP8266
===============
.. seo::
:description: Instructions for using nodemcu ESP8266 boards in ESPHome together with a description of their pins and uses.
:image: nodemcu_esp8266.jpg
:keywords: NodeMCU, ESP8266
The NodeMCU board is fully supported by ESPHome. Simply select ``ESP8266`` when
the ESPHome wizard asks you for your platform and |nodemcuv2|_ as the board type.
.. note::
Most NodeMCU that can be purchased now are version 2 or upwards. If you're using an
original v1 board, set the board type to |nodemcu|_.
.. |nodemcuv2| replace:: ``nodemcuv2``
.. _nodemcuv2: http://docs.platformio.org/en/latest/platforms/espressif8266.html#nodemcu
.. |nodemcu| replace:: ``nodemcu``
.. _nodemcu: http://docs.platformio.org/en/latest/platforms/espressif8266.html#nodemcu
.. code-block:: yaml
# Example configuration entry
esphome:
name: livingroom
esp8266:
board: nodemcuv2
The NodeMCU's pin numbering as seen on the board (the ``D0`` etc pins) is different from
the internal pin numbering. For example, the ``D3`` pin number maps to the internal
``GPIO0`` pin. Fortunately ESPHome knows the mapping from the on-board pin numbers
to the internal pin numbering, but you need to prefix the pin numbers with ``D`` as in
the image below in order for this automatic mapping to occur.
In general, it is best to just use the ``D0``, ``D1``, ... pin numbering to avoid confusion
.. figure:: images/nodemcu_esp8266-full.jpg
:align: center
Pins on the NodeMCU ESP8266 development board.
Note that in certain conditions you *can* use the pins marked as ``INTERNAL`` in above image.
- ``D0`` also can be used to wake the device up from :doc:`deep sleep </components/deep_sleep>` if
the pin is connected to the ``RESET`` pin. On some boards ``D0`` is additionally connected to the LED
next to the UART chip, but in an inverted mode.
- ``D3``, ``D4`` and ``D8`` are used on startup to determine the boot mode, therefore these pins should
not be pulled low on startup. You can, however, still use them as output pins.
- ``D4`` additionally is connected to the blue LED next to the antenna, but in an inverted mode.
- ``A0``: This pin can be used as a normal GPIO pin (like ``D1`` etc) but additionally can measure
voltages from 0 to 1.0V using the :doc:`/components/sensor/adc`.
- ``VIN``: This board can be powered by an external power supply by using this pin. Supply a voltage depends on the board you use. Some boards support up to 12V, some up to 5V.
- ``ENABLE``/``RESET``: When these pins are triggered, the board resets. The difference between the pins
is how they can handle voltages above 3.3V.
.. code-block:: yaml
# Example configuration entry
esphome:
name: livingroom
esp8266:
board: nodemcuv2
binary_sensor:
- platform: gpio
name: "Pin D0"
pin: D0
See Also
--------
- :doc:`/components/esp8266`
- :doc:`nodemcu_esp32`
- :ghedit:`Edit`

View File

@ -1,447 +0,0 @@
Generic Sonoff
==============
.. seo::
:description: Instructions for using generic Sonoff devices with ESPHome.
:image: sonoff.svg
ESPHome supports Sonoff devices with ESP based chips inside, but as these devices are quite cheap
and shipping from China takes a long time, I've only set up dedicated guides for the
:doc:`Sonoff S20 <sonoff_s20>` and :doc:`Sonoff 4CH <sonoff_4ch>`.
.. code-block:: yaml
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp8285
After that use the following list of pin to function mappings to set up your Sonoff device.
This list has been compiled from the Sonoff Tasmota pin source file which can be found `here <https://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_template.h>`__.
.. note::
SAFETY HAZARD: Some devices such as Sonoff POWs/Shelly/etc, have the digital GND connected directly to mains voltage so **the GPIOs become LIVE during normal operation**. Our advice is to mark these boards to prevent any use of the dangerous digital pins.
Sonoff RF
---------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Green LED (inverted),
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
GPIO4, Optional sensor
GPIO14, Optional sensor
Sonoff SV
---------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Green LED (inverted),
GPIO17, Analog Input,
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
GPIO4, Optional sensor
GPIO5, Optional sensor
GPIO14, Optional sensor
Sonoff TH10/TH16
----------------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Green LED (inverted),
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
GPIO4, Optional sensor
GPIO14, Optional sensor
GPIO2, Optional Pin EXP-LOG (TH16 Ver 2.1 2019)
Sonoff Dual R1
--------------
.. pintable::
GPIO1, Relay #1,
GPIO3, Relay #2,
GPIO13, Blue LED (inverted),
GPIO4, Optional sensor
GPIO14, Optional sensor
Sonoff Dual R2
--------------
.. pintable::
GPIO12, Relay #1,
GPIO5, Relay #2,
GPIO10, Button,
GPIO13, Blue LED (inverted),
GPIO4, Optional sensor
GPIO14, Optional sensor
Sonoff Dual R2 v1.4
-------------------
.. pintable::
GPIO00, Button #0(inside header board v1.4),
GPIO09, Button #1(inside header board v1.4),
GPIO12, Relay #1,
GPIO5, Relay #2,
GPIO10, Button on the case,
GPIO13, Blue LED (inverted)
Sonoff Dual R3 v1.x, v2.x
-------------------------
.. pintable::
GPIO27, Relay #1,
GPIO14, Relay #2,
GPIO0, Button,
GPIO13, Blue LED (inverted),
GPIO32, SW Input #1 (inverted),
GPIO33, SW Input #2 (inverted),
GPIO25, UART TX pin (for power sensor)
GPIO26, UART RX pin (for power sensor)
For power measuring see :doc:`/components/sensor/cse7761` (v1.x) or :doc:`/components/sensor/bl0939` (v2.x)
Sonoff Pow R1
-------------
(equivalent to Huafan SS)
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO15, Blue LED,
GPIO5, HLW8012 SEL Pin
GPIO13, HLW8012 CF1 Pin
GPIO14, HLW8012 CF Pin
See :doc:`/components/sensor/hlw8012` for measuring power.
Sonoff Pow R2
-------------
(equivalent to Huafan SS)
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Blue LED (inverted),
See :doc:`/components/sensor/cse7766` for measuring power.
Sonoff S20, Sonoff S22, Sonoff S26
----------------------------------
See :doc:`sonoff_s20`.
Slampher
--------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Blue LED (inverted),
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
Sonoff Touch
------------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Blue LED (inverted),
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
Sonoff LED
----------
.. pintable::
GPIO0, Button (inverted),
GPIO13, Blue LED (inverted),
GPIO5, Red Channel
GPIO4, Green Channel
GPIO15, Blue Channel
GPIO12, Cold White Channel
GPIO14, Warm White Channel
See :doc:`/components/light/rgbww` for controlling the lights together with
:doc:`/components/output/esp8266_pwm`.
ElectroDragon
-------------
.. pintable::
GPIO2, Button 1 (inverted),
GPIO0, Button 2 (inverted),
GPIO13, Relay 1 and Red LED,
GPIO12, Relay 2 and Red LED,
GPIO16, Green/Blue LED
GPIO17, Analog Input
Sonoff SC
---------
.. pintable::
GPIO12, Light,
GPIO13, Red LED (inverted)
See :doc:`/components/light/monochromatic` and :doc:`/components/output/esp8266_pwm`
for controlling the light pin.
Sonoff 4CH Pro
--------------
Same configuration as the :doc:`Sonoff 4CH <sonoff_4ch>`.
Sonoff B1, Ai-Thinker AiLight
-----------------------------
See :doc:`/components/output/my9231`.
Sonoff T1, Sonoff T3 (1CH, 2CH, 3CH)
------------------------------------
.. pintable::
GPIO0, Button 1 (inverted),
GPIO12, Relay 1 and Blue LED,
GPIO9, Button 2 (inverted),
GPIO5, Relay 2 and Blue LED,
GPIO10, Button 3 (inverted),
GPIO4, Relay 3 and Blue LED,
GPIO13, Blue LED (inverted),
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
Arilux LC10, Magic Home
-----------------------
.. pintable::
GPIO2, Blue LED,
GPIO14, Red Channel,
GPIO5, Green Channel,
GPIO12, Blue Channel,
GPIO13, White Channel,
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
See :doc:`/components/light/rgbw` for controlling the lights together with
:doc:`/components/output/esp8266_pwm`.
Arilux LC01
-----------
.. pintable::
GPIO0, Button (inverted),
GPIO2, Blue LED,
GPIO5, Red Channel,
GPIO12, Green Channel,
GPIO13, Blue Channel,
GPIO14, White Channel,
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
See :doc:`/components/light/rgbw` for controlling the lights together with
:doc:`/components/output/esp8266_pwm`.
Arilux LC02
-----------
.. pintable::
GPIO0, Button (inverted),
GPIO2, Blue LED,
GPIO5, Red Channel,
GPIO14, Green Channel,
GPIO12, Blue Channel,
GPIO13, White Channel,
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
See :doc:`/components/light/rgbw` for controlling the lights together with
:doc:`/components/output/esp8266_pwm`.
Arilux LC11
-----------
.. pintable::
GPIO0, Button (inverted),
GPIO2, Blue LED,
GPIO5, Red Channel,
GPIO4, Green Channel,
GPIO14, Blue Channel,
GPIO13, Cold White Channel,
GPIO12, Warm White Channel,
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
See :doc:`/components/light/rgbww` for controlling the lights together with
:doc:`/components/output/esp8266_pwm`.
Sonoff S31
----------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Green LED (inverted),
See :doc:`/components/sensor/cse7766` for measuring power
Sonoff S55
----------
.. pintable::
GPIO0, Button (inverted),
GPIO12, Relay and Red LED,
GPIO13, Blue LED (inverted),
GPIO1, UART TX pin (for external sensors)
GPIO3, UART RX pin (for external sensors)
Sonoff Mini
-----------
.. pintable::
GPIO0, Button (inverted),
GPIO4, SW Input (inverted),
GPIO12, Relay and Red LED,
GPIO13, Blue LED (inverted),
GPIO16, Optional sensor
Sonoff THR316D
--------------
.. pintable::
GPIO0, Button,
GPIO21, Relay 1,
GPIO4, Relay 2,
GPIO27, Optionnal sensor power ON/OFF,
GPIO25, sensor,
GPIO16, Power LED,
GPIO15, Wifi LED (inverted),
GPIO13, Cycle LED (inverted),
GPIO23, Display Read,
GPIO18, Display Write,
GPIO5, Display Data,
GPIO17, Display CS,
GPIO1, UART TX pin (for log)
GPIO3, UART RX pin (for log)
Shelly 1
--------
.. pintable::
GPIO4, Relay,
GPIO5, SW Input,
Shelly 2
--------
.. pintable::
GPIO4, Relay #1,
GPIO5, Relay #2,
GPIO12, SW Input #1,
GPIO14, SW Input #2,
Teckin
------
.. pintable::
GPIO1, Button (inverted),
GPIO3, Blue LED (inverted),
GPIO13, Red LED (inverted),
GPIO14, Relay,
GPIO12, HLW8012 SEL Pin (inverted),
GPIO4, HLW8012 CF Pin,
GPIO5, HLW8012 CF1 Pin,
See :doc:`/components/sensor/hlw8012` for measuring power.
Example config: `teckin.yaml <https://github.com/esphome/esphome-docs/blob/current/devices/teckin.yaml>`__
Teckin SP20 (US)
----------------
.. pintable::
GPIO13, Button,
GPIO2, Blue LED (inverted),
GPIO0, Red LED (inverted),
GPIO4, Relay,
GPIO12, HLW8012 SEL Pin (inverted),
GPIO5, HLW8012 CF Pin,
GPIO14, HLW8012 CF1 Pin,
See :doc:`/components/sensor/hlw8012` for measuring power.
Example config: `teckin_sp20_us.yaml <https://github.com/esphome/esphome-docs/blob/current/devices/teckin_sp20_us.yaml>`__
TorchStar LED Controller (Nov 2018)
-----------------------------------
.. pintable::
GPIO13, Button (inverted),
GPIO16, Blue LED (inverted),
GPIO4, Red LED (inverted),
GPIO14, Red Channel,
GPIO12, Green Channel,
GPIO5, Blue Channel,
GPIO15, White Channel,
See Also
--------
- :doc:`sonoff_s20`
- :doc:`sonoff_4ch`
- :doc:`sonoff_basic`
- :doc:`/components/esp8266`
- :ghedit:`Edit`

View File

@ -1,336 +0,0 @@
Using With Sonoff 4CH
=====================
.. seo::
:description: Instructions for putting Sonoff 4CH devices into flash mode and installing ESPHome on them.
:image: sonoff_4ch.jpg
ESPHome can also be used with Sonoff 4CH wireless switches. These devices are
basically just an ESP8266 chip with 4 relays to control power output, a few buttons on the
top and a few status LEDs.
.. figure:: images/sonoff_4ch_header.jpg
:align: center
:width: 75.0%
Sonoff 4CH WiFi switch.
This guide will step you through setting up your Sonoff 4CH and flashing the first ESPHome firmware
with the serial interface. After that, you will be able to upload all future firmwares with the remote
Over-The-Air update process.
.. note::
If you've previously installed Sonoff-Tasmota on your Sonoff 4CH, you're in luck 😀.
ESPHome can generate a firmware binary which you can then upload via the
Tasmota web interface. To see how to create this binary, skip to :ref:`sonoff_4ch-creating_firmware`.
Since firmware version 1.6.0, iTead (the creator of this device) has removed the ability to upload
a custom firmware through their own upload process. Unfortunately, that means that the only way to
flash the initial ESPHome firmware is by physically opening the device up and using the UART
interface.
.. warning::
Opening up this device can be very dangerous if not done correctly. While the device is open,
you will be a single touch away from being electrocuted if the device is plugged in or connected to a high voltage 'mains' power supply.
So, during this *entire* guide **never ever** plug the device in or have it connected to mains power. Also, you should only do this
if you know what you're doing. If you, at any step, feel something is wrong or are uncomfortable
with continuing, it's best to just stop for your own safety.
It's your own responsibility to make sure everything you do during this setup process is safe.
For this guide you will need:
- Sonoff 4CH 😉.
- A USB to UART Bridge for flashing the device. These can be bought on Amazon (or other online stores) for less than 5 dollars.
Note that the bridge *must* be 3.3V compatible. Otherwise you will destroy your Sonoff.
- Jumper wires to connect the UART bridge to the header pins.
- A computer running Home Assistant with the ESPHome Home Assistant add-on.
- A screwdriver to open up the Sonoff 4CH.
Have everything? Great! Then you can start.
Step 1: Opening up the Sonoff 4CH
---------------------------------
The first step is to open up the Sonoff 4CH. Note that you do not have to run the original firmware
supplied with the Sonoff 4CH before doing this step.
.. warning::
Just to repeat this: Make **absolutely sure** the device is not connected to any appliance or
connected to mains power before doing this step.
While the device is not plugged in, turn the device so you are viewing it from the top,
then unscrew the long screws in the four corners of the top cover.
.. figure:: images/sonoff_4ch_top.jpg
:align: center
:width: 60.0%
There are four screws on the front of the Sonoff 4CH.
After that, you should be able to remove the front cover and should be greeted by the main board.
The chip we're interested in here is the "big" one encased in an aluminium cover.
.. figure:: images/sonoff_4ch_mcu.jpg
:align: center
:width: 75.0%
The main chip of the Sonoff 4CH and the header pins we're going to use to flash our custom
firmware.
Step 2: Connecting UART
-----------------------
Now we need our computer to somehow establish a data connection to the board. For this we will
have to connect the four wires on the UART to USB bridge to the UART pins of the Sonoff 4Ch.
Fortunately for us, exactly these pins come pre-populated with a few header pins. You can identify
these by the ``VCC33``, ``RX``, ``TX`` and ``GND`` markings on the silk-screen.
Now go ahead and connect these pins to your UART to USB bridge as seen in the below image. Make sure
that you connect these correctly, especially the ``VCC33`` and ``GND`` parts as you can otherwise
destroy the chip.
``VCC33`` should be connected to the ``3V3`` (**not** 5V) pin of the UART bridge, ``GND`` to ``GND``
and the same with ``RX``/``TX``.
When you're done, it should look something like this:
.. figure:: images/sonoff_4ch_uart.jpg
:align: center
.. note::
On some older 4CHs, the ``RX`` and ``TX`` pins are swapped (sometimes even the written silkscreen is
wrong). 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_4ch-creating_firmware:
Step 3: Creating Firmware
-------------------------
The Sonoff 4CH 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_4ch.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>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
Now run ``esphome sonoff_4ch.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 do this, while the UART
bridge is not connected to your USB port, press and hold the bottom-left push button labelled ``FW/IO0``
and continue to do so while plugging in the UART bridge into your computer. Keep holding the button for
another 2-4 seconds. The 4CH should now be in a flash mode and should not blink any LED.
.. figure:: images/sonoff_4ch_buttons.jpg
:align: center
You need to press the button labelled ``FW/IO0`` during startup.
Now you can finally run the upload command:
.. code-block:: bash
esphome sonoff_4ch.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 4CH. And in a moment,
you will be able to use all of ESPHome's great features with your Sonoff 4CH.
If above step don't work, however, 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 connect mains
power to the device in an attempt 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 4CH 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 4CH and a configuration file that exposes all
of the basic functions.
======================================== =========================================
``GPIO0`` Button #1 (inverted)
---------------------------------------- -----------------------------------------
``GPIO9`` Button #2 (inverted)
---------------------------------------- -----------------------------------------
``GPIO10`` Button #3 (inverted)
---------------------------------------- -----------------------------------------
``GPIO14`` Button #4 (inverted)
---------------------------------------- -----------------------------------------
``GPIO12`` Relay #1 and red LED
---------------------------------------- -----------------------------------------
``GPIO5`` Relay #2 and red LED
---------------------------------------- -----------------------------------------
``GPIO4`` Relay #3 and red LED
---------------------------------------- -----------------------------------------
``GPIO15`` Relay #4 and red LED
---------------------------------------- -----------------------------------------
``GPIO13`` Blue LED (inverted)
---------------------------------------- -----------------------------------------
``GPIO1`` ``TX`` pin (for external sensors)
---------------------------------------- -----------------------------------------
``GPIO3`` ``RX`` pin (for external sensors)
---------------------------------------- -----------------------------------------
``GPIO2`` ``IO2`` pin (for external sensors)
======================================== =========================================
.. note::
The ESP8266 will be prevented from booting if the following pins are pulled LOW (connected to GND) on cold startup: ``GPIO0``, ``GPIO1``, ``GPIO2``. Be prepared if you want to use them for input sensors.
.. code-block:: yaml
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 1"
- platform: gpio
pin:
number: GPIO9
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 2"
- platform: gpio
pin:
number: GPIO10
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 3"
- platform: gpio
pin:
number: GPIO14
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 4"
- platform: status
name: "Sonoff 4CH Status"
switch:
- platform: gpio
name: "Sonoff 4CH Relay 1"
pin: GPIO12
- platform: gpio
name: "Sonoff 4CH Relay 2"
pin: GPIO5
- platform: gpio
name: "Sonoff 4CH Relay 3"
pin: GPIO4
- platform: gpio
name: "Sonoff 4CH Relay 4"
pin: GPIO15
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: true
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff 4CH Blue LED"
output: blue_led
Above example also showcases an important concept of ESPHome: IDs and linking. In order
to make all components in ESPHome as "plug and play" as possible, you can use IDs to define
them in one area, and simply pass that ID later on. For example, above you can see a PWM (dimmer)
output being created with the ID ``blue_led`` for the blue LED. Later on it is then transformed
into a :doc:`monochromatic light </components/light/monochromatic>`.
If you additionally want the buttons to control the relays, look at `the complete Sonoff 4CH
with automation example <https://github.com/esphome/esphome-docs/blob/current/devices/sonoff_4ch.yaml>`__.
.. figure:: images/sonoff_4ch_result.png
:align: center
:width: 75.0%
Step 6: Finishing Up
--------------------
If you're sure everything is done with the 4CH and have double checked there's nothing that could cause a short
in the case, you can put the front cover back on and screw everything together.
Now triple- or even quadruple-check the UART bridge is not connected to the 4CH, then comes the time when you can
connect it.
Happy hacking!
See Also
--------
- :doc:`sonoff`
- :doc:`sonoff_s20`
- :ghedit:`Edit`

View File

@ -1,88 +0,0 @@
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 1"
on_press:
- switch.toggle: relay_1
- platform: gpio
pin:
number: GPIO9
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 2"
on_press:
- switch.toggle: relay_2
- platform: gpio
pin:
number: GPIO10
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 3"
on_press:
- switch.toggle: relay_3
- platform: gpio
pin:
number: GPIO14
mode:
input: true
pullup: true
inverted: true
name: "Sonoff 4CH Button 4"
on_press:
- switch.toggle: relay_4
- platform: status
name: "Sonoff 4CH Status"
switch:
- platform: gpio
name: "Sonoff 4CH Relay 1"
pin: GPIO12
id: relay_1
- platform: gpio
name: "Sonoff 4CH Relay 2"
pin: GPIO5
id: relay_2
- platform: gpio
name: "Sonoff 4CH Relay 3"
pin: GPIO4
id: relay_3
- platform: gpio
name: "Sonoff 4CH Relay 4"
pin: GPIO15
id: relay_4
output:
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: true
light:
- platform: monochromatic
name: "Sonoff 4CH Blue LED"
output: blue_led

View File

@ -1,276 +0,0 @@
Using With Sonoff Basic
=======================
.. seo::
:description: Instructions for putting Sonoff basic devices into flash mode and installing ESPHome on them.
:image: sonoff_basic.jpg
ESPHome can be used with Sonoff Basic. These devices are basically just
an ESP8266 chip with a relay to control the connection, a small button on the
front and a green LED light.
.. figure:: images/sonoff_basic-full.jpg
:align: center
:width: 75.0%
Sonoff Basic
This guide will not guide you through setting up your Sonoff Basic step-by-step. It just provide
a sample configuration. For detailed instructions, see :doc:`sonoff_s20`, as those devices are
pretty similar.
.. note::
If you've previously installed Sonoff-Tasmota or ESPurna on your Sonoff Basic, you're in luck 😀
ESPHome can generate a firmware binary which you can then upload via the
web interface.
Sample configuration
--------------------
The Sonoff Basic is based on the ``ESP8266`` platform and is a subtype of the ``esp01_1m`` board.
With this information, you can also step through the ESPHome wizard (``esphome sonoff_basic.yaml wizard``)
if you don't want to use the sample configuration file from below.
Below you will find a table of all usable GPIO pins of the Sonoff Basic and a configuration file that
exposes all of the basic functions.
================================================== ==================================================
``GPIO0`` Button (inverted)
-------------------------------------------------- --------------------------------------------------
``GPIO1`` ``TX`` pin (C1 Pin 2)
-------------------------------------------------- --------------------------------------------------
``GPIO3`` ``RX`` pin (C1 Pin 3)
-------------------------------------------------- --------------------------------------------------
``GPIO12`` Relay
-------------------------------------------------- --------------------------------------------------
``GPIO13`` Green LED (inverted)
-------------------------------------------------- --------------------------------------------------
``GPIO14`` Optional Sensor (C1 Pin 5)
================================================== ==================================================
.. code-block:: yaml
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff Basic Button"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Sonoff Basic Relay"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes
Now run ``esphome sonoff_basic.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.
Or run the upload command if your device is connected to the serial interface:
.. code-block:: bash
esphome sonoff_basic.yaml run
More detailed breakdown
-----------------------
1. Programming
**************
Ensure you have soldered on the additional header pins to the PCB and connect your USB FTDI programmer.
See https://randomnerdtutorials.com/how-to-flash-a-custom-firmware-to-sonoff/ for more details on the pinout and FTDI.
1.1. Put Sonoff into programming mode.
**************************************
* Press and hold the toggle pin (long black pin next to LED and custom soldered pins).
* Supply USB power to Sonoff via FTDI (e.g. plug in USB to the FTDI, or use a power switch as explained in link above).
* Keep holding the toggle pin for approx 3-5 seconds now you should be ready to program.
If you get a message unable to communicate when trying flash, check your TX/RX pin or retry entering boot mode again.
Quick notes:
* 3.3V setting on FTDI, 5V will cause damage.
* Ensure the connections on the PCB starts at the closed to the toggle pin, it uses 4 pins, but 5 pins are soldered on.
* TX and RX should be swapped - RX on Sonoff goes to TX on FTDI.
1.2. Upload the firmware
************************
Run this command from the same directory where your <my-awesome>.yaml file is located
.. code-block:: bash
esphome <my-awesome>.yaml run
Or if you're using the dashboard, just click the "UPLOAD" button.
You should get an output starting like this
.. code-block:: text
INFO Reading configuration...
INFO Detected timezone 'SAST' with UTC offset 2
INFO Generating C++ source...
INFO Compiling app...
INFO Running: platformio run -d fishpond
********************************************************************************************************
Obsolete PIO Core v3.6.3 is used (previous was 3.6.4b1)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/page/faq.html#multiple-pio-cores-in-a-system
...
lots of compile stuff
...
Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [====== ] 55.6% (used 45512 bytes from 81920 bytes)
PROGRAM: [==== ] 38.1% (used 390576 bytes from 1023984 bytes)
===================================== [SUCCESS] Took 4.70 seconds =====================================
INFO Successfully compiled program.
Found multiple options, please choose one:
[1] /dev/ttyUSB0 (FT232R USB UART)
[2] Over The Air (fishpond.device)
(number): 1
...
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
MAC: xx:xx:xx:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 394720 bytes to 267991...
Wrote 394720 bytes (267991 compressed) at 0x00000000 in 23.8 seconds (effective 132.7 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
1.3. And then nothing will happen
*********************************
Once you have flashed the device, nothing will happen. You need to power cycle the device.
You will notice the LED will start to flash and then becomes solid once connected to the WiFi network.
You can follow the logs produced by the running module by running the command
.. code-block:: bash
esphome <my-awesome>.yaml logs
Your output will possibly look like this
.. code-block:: text
INFO Reading configuration...
INFO Detected timezone 'SAST' with UTC offset 2
INFO Starting log output from fishpond.device using ESPHome API
INFO Connecting to fishpond.device:6053 (192.168.13.15)
INFO Successfully connected to fishpond.device
[11:13:27][D][time.homeassistant:029]: Synchronized time: Wed Jan 16 11:13:27 2019
[11:13:27][I][application:097]: You're running ESPHome v1.10.1 compiled on Jan 16 2019, 08:12:59
[11:13:27][C][status_led:023]: Status LED:
[11:13:27][C][status_led:024]: Pin: GPIO13 (Mode: OUTPUT)
[11:13:27][C][wifi:341]: WiFi:
[11:13:27][C][wifi:240]: SSID: 'some-ssid'
[11:13:27][C][wifi:241]: IP Address: 192.168.13.15
[11:13:27][C][wifi:243]: BSSID: xx:xx:xx:xx:xx:xx
[11:13:27][C][wifi:245]: Hostname: 'fishpond'
[11:13:27][C][wifi:250]: Signal strength: -91 dB ▂▄▆█
[11:13:27][C][wifi:251]: Channel: 1
[11:13:27][C][wifi:252]: Subnet: 255.255.255.0
[11:13:27][C][wifi:253]: Gateway: 192.168.13.1
[11:13:27][C][wifi:254]: DNS1: 192.168.13.1
[11:13:27][C][wifi:255]: DNS2: 0.0.0.0
[11:13:27][C][binary_sensor.status:046]: Status Binary Sensor 'esp_fishpond_system_status'
[11:13:27][C][binary_sensor.status:046]: Device Class: 'connectivity'
[11:13:28][C][switch.gpio:049]: GPIO Switch 'esp_fishpond_gpio12'
[11:13:28][C][switch.gpio:050]: Pin: GPIO12 (Mode: OUTPUT)
[11:13:28][C][switch.gpio:066]: Restore Mode: Restore (Default to OFF)
[11:13:28][C][binary_sensor.gpio:023]: GPIO Binary Sensor 'esp_fishpond_gpio0'
[11:13:28][C][binary_sensor.gpio:024]: Pin: GPIO0 (Mode: INPUT, INVERTED)
[11:13:28][C][binary_sensor.gpio:023]: GPIO Binary Sensor 'esp_fishpond_gpio14'
[11:13:28][C][binary_sensor.gpio:024]: Pin: GPIO14 (Mode: INPUT_PULLUP)
[11:13:28][C][output.esp8266_pwm:028]: ESP8266 PWM:
[11:13:28][C][output.esp8266_pwm:029]: Pin: GPIO13 (Mode: OUTPUT)
[11:13:28][C][output.esp8266_pwm:030]: Frequency: 1000.0 Hz
[11:13:28][C][logger:099]: Logger:
[11:13:28][C][logger:100]: Level: DEBUG
[11:13:28][C][logger:101]: Log Baud Rate: 115200
[11:13:28][C][light.state:266]: Light 'esp_fishpond_gpio13'
[11:13:28][C][light.state:268]: Default Transition Length: 1000 ms
[11:13:28][C][light.state:269]: Gamma Correct: 2.80
[11:13:28][C][switch.restart:034]: Restart Switch 'esp_fishpond_system_restart'
[11:13:28][C][switch.restart:034]: Icon: 'mdi:restart'
[11:13:28][C][time.homeassistant:032]: Home Assistant Time:
[11:13:28][C][time.homeassistant:033]: Timezone: 'SAST-2'
[11:13:28][C][sensor.wifi_signal:042]: WiFi Signal 'esp_fishpond_system_wifi_signal'
[11:13:28][C][sensor.wifi_signal:042]: Unit of Measurement: 'dB'
[11:13:28](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[11:13:28](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[11:13:28][C][api:072]: API Server:
[11:13:28][C][api:073]: Address: 192.168.13.15:6053
[11:13:28][C][ota:129]: Over-The-Air Updates:
[11:13:28][C][ota:130]: Address: 192.168.13.15:8266
1.4. Test now with OTA flashing
*******************************
Before installing the Sonoff, do a final OTA test, and this time selecting the OTA option and NOT the USB option when reflashing.
.. code-block:: bash
esphome <my-awesome>.yaml run
Once these actions succeeded you are pretty much in the clear and can be sure your device is ready.
See Also
--------
- :doc:`sonoff`
- :doc:`sonoff_4ch`
- :doc:`sonoff_s20`
- `GPIO locations <https://github.com/arendst/Sonoff-Tasmota/wiki/GPIO-Locations>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/devices/sonoff_basic.rst>`__

View File

@ -1,328 +0,0 @@
Using With Sonoff S20
=====================
.. seo::
:description: Instructions for putting Sonoff S20 devices into flash mode and installing ESPHome on them.
:image: sonoff_s20.jpg
ESPHome can also be used with Sonoff S20 smart sockets. These devices are
basically just an ESP8266 chip with a relay to control the socket, a small button on the
front and a blue and green LED light.
.. figure:: images/sonoff_s20_header.jpg
:align: center
:width: 75.0%
Sonoff S20 Smart Socket.
This guide will step you through setting up your Sonoff S20 and flashing the first ESPHome firmware
with the serial interface. After that, you will be able to upload all future firmware with the remote
Over-The-Air update process.
.. note::
If you've previously installed Sonoff-Tasmota on your Sonoff S20, you're in luck 😀.
ESPHome can generate a firmware binary which you can then upload via the
Tasmota web interface. To see how to create this binary, skip to :ref:`sonoff_s20-creating-firmware`.
Since firmware version 1.6.0, iTead (the creator of this device) has removed the ability to upload
a custom firmware through their own upload process. Unfortunately, that means that the only way to
flash the initial ESPHome firmware is by physically opening the device up and using the UART
interface.
.. warning::
Opening up this device can be very dangerous if not done correctly. While the device is open,
you will be a single touch away from being electrocuted if the device is plugged in.
So, during this *entire* guide **never ever** plug the device in. Also, you should only do this
if you know what you're doing. If you, at any step, feel something is wrong or are uncomfortable
with continuing, it's best to just stop for your own safety.
It's your own responsibility to make sure everything you do during this setup process is safe.
For this guide you will need:
- Sonoff S20 😉.
- A USB to UART Bridge for flashing the device. These can be bought on Amazon (or other online stores) for less than 5 dollars.
Note that the bridge *must* be 3.3V compatible. Otherwise you will destroy your S20.
- A computer running Home Assistant with the ESPHome Home Assistant add-on.
- A screwdriver to open up the S20.
- A soldering iron and a few header pins to connect the UART interface.
Have everything? Great! Then you can start.
Step 1: Opening up the Sonoff S20
---------------------------------
The first step is to open up the Sonoff S20. Note that you do not have to run the original firmware
supplied with the Sonoff S20 before doing this step.
.. warning::
Just to repeat this: Make **absolutely sure** the device is not connected to any appliance or
plugged in before doing this step.
While the device is not plugged in, turn the back side so it's facing you and unscrew the three
black screws that hold the case together.
.. figure:: images/sonoff_s20_screws.jpg
:align: center
:width: 60.0%
There are three screws on the back of the Sonoff S20.
After that, you should be able to remove the front cover and should be greeted by a bunch of parts.
.. figure:: images/sonoff_s20_parts.jpg
:align: center
:width: 75.0%
Step 2: Connecting UART
-----------------------
We're interested in the main part of the S20 with the green PCB. On the bottom of the PCB, you will
find four unpopulated holes. These pins expose the UART interface used to flash firmware onto the device
and debug issues.
.. figure:: images/sonoff_s20_pcb.jpg
:align: center
The UART interface of the Sonoff S20.
So, in order to flash our own custom firmware, we're going to need to somehow connect the UART to USB
bridge to these pins. The only way to make a good connection here is by using a soldering iron and soldering
on some pin headers. On older models of the Sonoff S20, you were able to get the whole PCB out. Newer versions,
however, glue the PCB onto the case to avoid people flashing custom firmware. If the latter is the case,
you will just need to solder the pin headers from above - it's a bit difficult, but possible.
When you're done, it should look something like this:
.. figure:: images/sonoff_s20_uart.jpg
:align: center
Now go ahead and connect the pins to your UART bridge, making sure the S20 is not plugged in as before.
Also beware that some UART to USB bridges supply 5V on the VCC pin if it's not explicitly labelled 3.3V.
It's best to just use a multimeter and double check if it's unclear.
.. note::
On some older S20s, the ``RX`` and ``TX`` pins are swapped (sometimes even the written silkscreen is
wrong). 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_s20-creating-firmware:
Step 3: Creating Firmware
-------------------------
The Sonoff S20 is based on the ``ESP8266`` platform and is a subtype of the ``esp01_1m`` board.
With this information, you can step through the ESPHome wizard (``esphome sonoff_s20.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>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
Now run ``esphome sonoff_s20.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
``.esphome/builds/<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 do this, while the UART
bridge is not connected to your USB port, press and hold the small push button in the middle of the PCB.
Then plug the UART bridge into your computer and keep holding the button for 2-4 seconds.
The S20 should now be in a flash mode and should not blink any LED.
Now you can finally run the upload command:
.. code-block:: bash
esphome sonoff_s20.yaml run
If successful, you should see something like this:
.. figure:: images/sonoff_s20_upload.png
:align: center
Hooray 🎉! You've now successfully uploaded the first ESPHome firmware to your Sonoff S20. And, in a moment,
you will be able to use all of ESPHome's great features with your Sonoff S20.
If above step don't work, however, 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 3.3V to VCC and GND to GND on the pins. **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 S20 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 S20 and a configuration file that exposes all
of the basic functions.
======================================== ========================================
``GPIO0`` Push Button (HIGH = off, LOW = on)
---------------------------------------- ----------------------------------------
``GPIO12`` Relay and its status LED
---------------------------------------- ----------------------------------------
``GPIO13`` Green LED (HIGH = off, LOW = on)
---------------------------------------- ----------------------------------------
``GPIO1`` ``RX`` pin (for external sensors)
---------------------------------------- ----------------------------------------
``GPIO3`` ``TX`` pin (for external sensors)
---------------------------------------- ----------------------------------------
``GPIO2`` ``E-LOG`` pin (From PCB V2.1; for external sensors)
======================================== ========================================
.. code-block:: yaml
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff S20 Button"
- platform: status
name: "Sonoff S20 Status"
- platform: gpio
pin: GPIO2
name: "Sonoff S20 Sensor"
switch:
- platform: gpio
name: "Sonoff S20 Relay"
pin: GPIO12
output:
# Register the green LED as a dimmable output ....
- platform: esp8266_pwm
id: s20_green_led
pin:
number: GPIO13
inverted: true
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff S20 Green LED"
output: s20_green_led
The above example also showcases an important concept of ESPHome: IDs and linking. In order
to make all components in ESPHome as "plug and play" as possible, you can use IDs to define
them in one area, and simply pass that ID later on. For example, above you can see a PWM (dimmer)
output being created with the ID ``s20_green_led`` for the green LED. Later on it is then transformed
into a :doc:`monochromatic light </components/light/monochromatic>`.
And if you want the thing that's connected through the output of the S20 to appear as a light
in Home Assistant, replace the last part with this:
.. code-block:: yaml
switch:
- platform: restart
name: "Sonoff S20 Restart"
output:
- platform: esp8266_pwm
id: s20_green_led
pin:
number: GPIO13
inverted: true
# Note: do *not* make the relay a dimmable (PWM) signal, relays cannot handle that
- platform: gpio
id: s20_relay
pin: GPIO12
light:
- platform: monochromatic
name: "Sonoff S20 Green LED"
output: s20_green_led
- platform: binary
name: "Sonoff S20 Relay"
output: s20_relay
To make pressing the button on the front toggle the relay, have a look at the `the complete Sonoff S20
with automation example <https://github.com/OttoWinter/esphomedocs/blob/current/devices/sonoff_s20.yaml>`__.
.. figure:: images/sonoff_s20_result.png
:align: center
:width: 75.0%
Step 6: Finishing Up
--------------------
Now you're pretty much done with setting up the Sonoff S20. The only steps left are to
remove any cables that you added within the housing and make sure everything in there is clean. If, for
example, you used wires to connect the UART console, you should definitely remove them to avoid
a short with mains.
Sometimes the soldered-on header pins can also interfere with the button. It's best to remove the
header pins again, as you will hopefully not need to use them again because of ESPHome's Over-The-Air
Update features (+ the OTA safe mode; if your node reboots more than 10 times in a row, it will automatically
enter an OTA-only safe mode).
If you're sure everything is done with the S20 and have double checked there's nothing that could cause a short
in the case, you can put the front cover with the button on the base again and screw everything together.
Now triple- or even quadruple-check the UART bridge is not connected to the S20, then comes the time when you can
plug it into the socket.
Happy hacking!
See Also
--------
- :doc:`sonoff`
- :doc:`sonoff_4ch`
- :ghedit:`Edit`

View File

@ -1,47 +0,0 @@
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff S20 Button"
on_press:
- switch.toggle: relay
- platform: status
name: "Sonoff S20 Status"
switch:
- platform: gpio
name: "Sonoff S20 Relay"
pin: GPIO12
id: relay
output:
- platform: esp8266_pwm
id: s20_green_led
pin: GPIO13
inverted: true
light:
- platform: monochromatic
name: "Sonoff S20 Green LED"
output: s20_green_led

View File

@ -1,325 +0,0 @@
Using With Sonoff T1 UK 3 Gang
==============================
.. seo::
:description: Instructions for putting Sonoff T1 UK 3 Gang devices into flash mode and installing ESPHome on them.
:image: sonoff_t1_uk_3g_v1.1.jpg
ESPHome can also be used with Sonoff T1 UK 3 Gang wireless switches. These devices are
basically just an ESP8266 chip with 3 relays to control power output and three backlit capacitive touch buttons to control the relays.
.. note::
This instruction is made for T1 UK with the touch board v1.1 which is trickier to get into flash mode
than v1
.. figure:: images/sonoff_t1_uk_3g_v1.1.jpg
:align: center
:width: 75.0%
Sonoff T1 UK 3 Gang WiFi switch.
This guide will step you through setting up your Sonoff T1 UK 3 Gang and flashing the first ESPHome firmware
with the serial interface. After that, you will be able to upload all future firmwares with the remote
Over-The-Air update process.
.. note::
If you've previously installed Sonoff-Tasmota on your Sonoff T1 UK 3 Gang, you're in luck 😀
ESPHome can generate a firmware binary which you can then upload via the
Tasmota web interface. To see how to create this binary, skip to :ref:`sonoff_t1_uk_3g_v1.1-creating_firmware`.
Since firmware version 1.6.0, iTead (the creator of this device) has removed the ability to upload
a custom firmware through their own upload process. Unfortunately, that means that the only way to
flash the initial ESPHome firmware is by physically opening the device up and using the UART
interface.
.. warning::
Opening up this device can be very dangerous if not done correctly. While the device is open,
you will be a single touch away from being electrocuted if the device is plugged in.
So, during this *entire* guide **never ever** plug the device in. Also, you should only do this
if you know what you're doing. If you, at any step, feel something is wrong or are uncomfortable
with continuing, it's best to just stop for your own safety.
It's your own responsibility to make sure everything you do during this setup process is safe.
For this guide you will need:
- Sonoff T1 UK 3 Gang 😉
- A USB to UART Bridge for flashing the device. These can be bought on Amazon for less than 5 dollars.
Note that the bridge *must* be 3.3V compatible. Otherwise you will destroy your Sonoff.
- Jumper wires to connect the UART bridge to the header pins and to connect GPIO0 to the Ground.
- Computer running ESPHome or Home Assistant add-on.
- Screwdriver to open up the Sonoff T1 UK 3 Gang.
Have everything? Great! Then you can start.
Step 1: Opening up the Sonoff T1 UK 3 Gang
------------------------------------------
The first step is to open up the Sonoff T1 UK 3 Gang. Note that you do not have to run the original firmware
supplied with the Sonoff T1 UK 3 Gang before doing this step.
.. warning::
Just to repeat this: Make **absolutely sure** the device is not connected to any appliance or
plugged in before doing this step.
While the device is not plugged in, turn the device face down and put a narrow flat screwdriver into the slot at the bottom.
With careful twisting motion detach the faceplate.
.. figure:: images/sonoff_t1_uk_3g_back_v1.1.jpg
:align: center
:width: 60.0%
Careful twisting motion.
After that, use the same screwdriver to carefully lift the top PCB off of the switch.
This PCB contains the ESP chip and what's left inside the switch body are relays.
.. figure:: images/sonoff_t1_uk_3g_plate_off_v1.1.jpg
:align: center
:width: 75.0%
"TOUCH BOARD" with touchpads holds the ESP chip.
Step 2: Connecting UART
-----------------------
Now we need our computer to somehow establish a data connection to the board. For this we will
have to connect the four wires on the UART to USB bridge to the UART pins of the Sonoff T1 v1.1.
Fortunately for us, these pins on the ESP controller have dedicated solder pads on the PCB. You can identify
these by the ``VCC33``, ``RX``, ``TX`` and ``GND`` markings on the silk-screen.
Now go ahead and connect these pins to your UART to USB bridge as seen in below image. Make sure
that you connect these correctly, especially the ``VCC33`` and ``GND`` parts as you can otherwise
destroy the chip.
``VCC33`` should be connected to the ``3V3`` (**not** 5V) pin of the UART bridge, ``GND`` to ``GND``
and the same with ``RX``/``TX``.
There's no need for soldering - for quick job like one time firmware flashing you can just hold pins in respective holes by hand
provided **you are not touching any live contacts**, only the wires.
.. note::
On some older T1 UK 3 Gangs, the ``RX`` and ``TX`` pins are swapped (sometimes even the written silkscreen is
wrong). 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_t1_uk_3g_v1.1-creating_firmware:
Step 3: Creating Firmware
-------------------------
The Sonoff T1 UK 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_t1_uk_3g_v1.1.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>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
Now run ``esphome sonoff_t1_uk_3g_v1.1.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 T1 and the best way to do it is to use a wire with pins on either side.
To do this, while the device is UART bridge is not connected to your USB port, flip the PCB over,
take a wire and connect the second Ground hole on the PCB (red) to the third from the right bottom leg on the chip as depicted below (yellow) -
that leg is connected to the ``GPIO0`` on ESP and plug the UART to your USB port.
Keep holding ``GND`` and ``GPIO0`` connected for 2-4 seconds. The T1 UK 3 Gang should now be in a flash mode and should not blink with any LED.
The touchpads may light up.
.. figure:: images/sonoff_t1_uk_3g_backplate_v1.1.jpg
:align: center
Connect red and yellow contacts while powering the board.
Now you can finally run the upload command:
.. code-block:: bash
esphome sonoff_t1_uk_3g_v1.1.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 T1 UK 3 Gang. And in a moment,
you will be able to use all of ESPHome's great features with your Sonoff T1 UK 3 Gang. Now you can put your T1 back together and fire up.
.. note::
While now your T1 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 T1
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 T1 UK 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 T1 UK 3 Gang and a configuration file that exposes all
of the basic functions.
======================================== =========================================
``GPIO0`` Touchpad #1 (inverted)
---------------------------------------- -----------------------------------------
``GPIO9`` Touchpad #2 (inverted)
---------------------------------------- -----------------------------------------
``GPIO10`` Touchpad #3 (inverted)
---------------------------------------- -----------------------------------------
``GPIO12`` Relay #1 and Touchpad #1 backlight
---------------------------------------- -----------------------------------------
``GPIO5`` Relay #2 and Touchpad #2 backlight
---------------------------------------- -----------------------------------------
``GPIO4`` Relay #3 and Touchpad #3 backlight
---------------------------------------- -----------------------------------------
``GPIO13`` Blue LED (inverted)
---------------------------------------- -----------------------------------------
``GPIO1`` ``RX`` pin (for external sensors)
---------------------------------------- -----------------------------------------
``GPIO3`` ``TX`` pin (for external sensors)
======================================== =========================================
.. code-block:: yaml
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T1 UK 3 Gang Touchpad 1"
- platform: gpio
pin:
number: GPIO9
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T1 UK 3 Gang Touchpad 2"
- platform: gpio
pin:
number: GPIO10
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T1 UK 3 Gang Touchpad 3"
- platform: status
name: "Sonoff T1 UK 3 Gang Status"
switch:
- platform: gpio
name: "Sonoff T1 UK 3 Gang Relay 1"
pin: GPIO12
- platform: gpio
name: "Sonoff T1 UK 3 Gang Relay 2"
pin: GPIO5
- platform: gpio
name: "Sonoff T1 UK 3 Gang Relay 3"
pin: GPIO4
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: true
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff T1 UK 3 Gang Blue LED"
output: blue_led
Above example also showcases an important concept of ESPHome: IDs and linking. In order
to make all components in ESPHome as "plug and play" as possible, you can use IDs to define
them in one area, and simply pass that ID later on. For example, above you can see a PWM (dimmer)
output being created with the ID ``blue_led`` for the blue LED. Later on it is then transformed
into a :doc:`monochromatic light </components/light/monochromatic>`.
If you additionally want the buttons to control the relays, look at `the complete Sonoff T1 UK 3 Gang
with automation example <https://github.com/esphome/esphome-docs/blob/current/devices/sonoff_t1_uk_3gang_v1.1.yaml>`__.
Step 6: Finishing Up
--------------------
If you're sure everything is done with the T1 UK 3 Gang and have double checked there's nothing that could cause a short
in the case, you can put the T1 back together.
Now triple- or even quadruple-check the UART bridge is not connected to the T1 UK 3 Gang, then comes the time when you can
connect it.
Happy hacking!
See Also
--------
- :doc:`sonoff`
- :doc:`sonoff_4ch`
- :doc:`sonoff_s20`
- :ghedit:`Edit`

View File

@ -1,86 +0,0 @@
esphome:
name: <NAME_OF_NODE>
# Automation turning on the blue status LED once T1 is booted up
on_boot:
priority: -10
then:
- light.turn_on: blue_led_light
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T1 UK 3 Gang Touchpad 1"
on_press:
- switch.toggle: relay_1
- platform: gpio
pin:
number: GPIO9
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T1 UK 3 Gang Touchpad 2"
on_press:
- switch.toggle: relay_2
- platform: gpio
pin:
number: GPIO10
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T1 UK 3 Gang Touchpad 3"
on_press:
- switch.toggle: relay_3
- platform: status
name: "Sonoff T1 UK 3 Gang Status"
switch:
- platform: gpio
name: "Sonoff T1 UK 3 Gang Relay 1"
pin: GPIO12
id: relay_1
- platform: gpio
name: "Sonoff T1 UK 3 Gang Relay 2"
pin: GPIO5
id: relay_2
- platform: gpio
name: "Sonoff T1 UK 3 Gang Relay 3"
pin: GPIO4
id: relay_3
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: true
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff T1 UK 3 Gang Blue LED"
output: blue_led
internal: true
id: blue_led_light

View File

@ -1,329 +0,0 @@
Using With Sonoff T3 EU 3 Gang
=====================================
.. seo::
:description: Instructions for putting Sonoff T3 EU 3C devices into flash mode and installing ESPHome on them.
:image: sonoff_t3_eu_3g_v1.0.jpg
ESPHome can also be used with Sonoff T3 EU 1/2/3 Gang wireless switches. These devices are
basically just an ESP8266 chip with up to 3 relays to control power output and three backlit capacitive touch buttons to control the relays.
.. figure:: images/sonoff_t3_eu_3g_v1.0.jpg
:align: center
:width: 75.0%
Sonoff T3 EU 3 Gang WiFi switch.
This guide will step you through setting up your Sonoff T3 EU 3 Gang and flashing the first ESPHome firmware
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.
After that, you will be able to upload all future firmware updates with the remote
Over-The-Air update process.
.. note::
If you've previously installed Sonoff-Tasmota on your Sonoff T3 EU 3 Gang, you're in luck 😀
ESPHome can generate a firmware binary which you can then upload via the
Tasmota web interface. To see how to create this binary, skip to :ref:`sonoff_t3_eu_3g_v1.0-creating_firmware`.
Since firmware version 1.6.0, iTead (the creator of this device) has removed the ability to upload
a custom firmware through their own upload process. Unfortunately, that means that the only way to
flash the initial ESPHome firmware is by physically opening the device up and using the UART
interface.
.. warning::
Opening up this device can be very dangerous if not done correctly. While the device is open,
you will be a single touch away from being electrocuted if the device is plugged in.
So, during this *entire* guide **never ever** plug the device in. Also, you should only do this
if you know what you're doing. If you, at any step, feel something is wrong or are uncomfortable
with continuing, it's best to just stop for your own safety.
It's your own responsibility to make sure everything you do during this setup process is safe.
For this guide you will need:
- Sonoff T3 EU 3 Gang 😉
- A USB to UART Bridge for flashing the device. These can be bought on Amazon for less than 5 dollars.
Note that the bridge *must* be 3.3V compatible. Otherwise you will destroy your Sonoff.
- Jumper wires to connect the UART bridge to the header pins and to connect GPIO0 to the Ground.
- Computer running ESPHome or the Home Assistant ESPHome add-on.
- Screwdriver to open up the Sonoff T3 EU 3 Gang.
Have everything? Great! Then you can start.
Step 1: Opening up the Sonoff T3 EU 3 Gang
------------------------------------------
The first step is to open up the Sonoff T3 EU 3 Gang. Note that you do not have to run the original firmware
supplied with the Sonoff T3 EU 3 Gang before doing this step.
.. warning::
Just to repeat this: Make **absolutely sure** the device is not connected to any appliance or
plugged in before doing this step.
While the device is not plugged in, turn the device face down and put a narrow flat screwdriver into the slot at the bottom.
With careful twisting motion detach the faceplate.
.. figure:: images/sonoff_t3_eu_3g_back_v1.0.jpg
:align: center
:width: 60.0%
Careful twisting motion.
After that, use the same screwdriver to carefully lift the top PCB off of the switch.
This PCB contains the ESP chip and what's left inside the switch body are relays.
.. figure:: images/sonoff_t3_eu_3g_plate_off_v1.0.jpg
:align: center
:width: 60.0%
"TOUCH BOARD" with touchpads holds the ESP chip.
Step 2: Connecting UART
-----------------------
Now we need our computer to somehow establish a data connection to the board. For this we will
have to connect the four wires on the UART to USB bridge to the UART pins of the Sonoff T3 v1.0.
Fortunately for us, these pins on the ESP controller have dedicated solder pads on the PCB (``J3``). You can identify
these by the ``VCC33``, ``RX``, ``TX`` and ``GND`` markings on the silk-screen.
Now go ahead and connect these pins to your UART to USB bridge as seen in below image. Make sure
that you connect these correctly, especially the ``VCC33`` and ``GND`` parts as you can otherwise
destroy the chip.
``VCC33`` should be connected to the ``3V3`` (**not** 5V) pin of the UART bridge, ``GND`` to ``GND``
and the same with ``RX``/``TX``.
There's no need for soldering - for quick job like one time firmware flashing you can just hold pins in respective holes by hand
provided **you are not touching any live contacts**, only the wires.
.. figure:: images/sonoff_t3_eu_3g_touchpads_v1.0.jpg
:align: center
:width: 75.0%
The Resistors ``R19``, ``R20`` and ``R21`` expose ``GPIO0``, ``GPIO9`` and ``GPIO10`` respectively.
.. figure:: images/sonoff_t3_eu_3g_backplate_v1.0.jpg
:align: center
:width: 75.0%
Backside also exposes ``GPIO2``.
.. note::
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>
esp8266:
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_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
of the basic functions.
======================================== =========================================
``GPIO0`` Touchpad #1 (inverted)
---------------------------------------- -----------------------------------------
``GPIO9`` Touchpad #2 (inverted)
---------------------------------------- -----------------------------------------
``GPIO10`` Touchpad #3 (inverted)
---------------------------------------- -----------------------------------------
``GPIO12`` Relay #1 and Touchpad #1 backlight
---------------------------------------- -----------------------------------------
``GPIO5`` Relay #2 and Touchpad #2 backlight
---------------------------------------- -----------------------------------------
``GPIO4`` Relay #3 and Touchpad #3 backlight
---------------------------------------- -----------------------------------------
``GPIO13`` Blue LED (inverted)
---------------------------------------- -----------------------------------------
``GPIO1`` ``RX`` pin (for external sensors)
---------------------------------------- -----------------------------------------
``GPIO3`` ``TX`` pin (for external sensors)
======================================== =========================================
.. code-block:: yaml
esphome:
name: <NAME_OF_NODE>
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
logger:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T3 EU 3 Gang Touchpad 1"
- platform: gpio
pin:
number: GPIO9
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T3 EU 3 Gang Touchpad 2"
- platform: gpio
pin:
number: GPIO10
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T3 EU 3 Gang Touchpad 3"
- platform: status
name: "Sonoff T3 EU 3 Gang Status"
switch:
- platform: gpio
name: "Sonoff T3 EU 3 Gang Relay 1"
pin: GPIO12
- platform: gpio
name: "Sonoff T3 EU 3 Gang Relay 2"
pin: GPIO5
- platform: gpio
name: "Sonoff T3 EU 3 Gang Relay 3"
pin: GPIO4
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: true
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff T3 EU 3 Gang Blue LED"
output: blue_led
Above example also showcases an important concept of ESPHome: IDs and linking. In order
to make all components in ESPHome as "plug and play" as possible, you can use IDs to define
them in one area, and simply pass that ID later on. For example, above you can see a PWM (dimmer)
output being created with the ID ``blue_led`` for the blue LED. Later on it is then transformed
into a :doc:`monochromatic light </components/light/monochromatic>`.
If you additionally want the buttons to control the relays, look at `the complete Sonoff T3 EU 3 Gang
with automation example <https://github.com/esphome/esphomedocs/blob/current/devices/sonoff_t3_eu_3gang_v1.0.yaml>`__.
Step 6: Finishing Up
--------------------
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
in the case, you can put the T3 back together.
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
connect it.
Happy hacking!
See Also
--------
- :doc:`sonoff`
- :doc:`sonoff_4ch`
- :doc:`sonoff_s20`
- :ghedit:`Edit`

View File

@ -1,86 +0,0 @@
esphome:
name: <NAME_OF_NODE>
# Automation turning on the blue status LED once T3 is booted up
on_boot:
priority: -10
then:
- light.turn_on: blue_led_light
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T3 EU 3 Gang Touchpad 1"
on_press:
- switch.toggle: relay_1
- platform: gpio
pin:
number: GPIO9
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T3 EU 3 Gang Touchpad 2"
on_press:
- switch.toggle: relay_2
- platform: gpio
pin:
number: GPIO10
mode:
input: true
pullup: true
inverted: true
name: "Sonoff T3 EU 3 Gang Touchpad 3"
on_press:
- switch.toggle: relay_3
- platform: status
name: "Sonoff T3 EU 3 Gang Status"
switch:
- platform: gpio
name: "Sonoff T3 EU 3 Gang Relay 1"
pin: GPIO12
id: relay_1
- platform: gpio
name: "Sonoff T3 EU 3 Gang Relay 2"
pin: GPIO5
id: relay_2
- platform: gpio
name: "Sonoff T3 EU 3 Gang Relay 3"
pin: GPIO4
id: relay_3
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: true
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff T3 EU 3 Gang Blue LED"
output: blue_led
internal: true
id: blue_led_light

View File

@ -1,71 +0,0 @@
esphome:
name: '<NODE_NAME>'
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
# Disable UART logging (pins GPIO1/3 are used for button/led)
baud_rate: 0
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
name: "Teckin Button"
pin:
number: GPIO1
mode:
input: true
pullup: true
inverted: true
on_press:
- switch.toggle: relay
switch:
- platform: gpio
id: blue_led
pin:
number: GPIO13
inverted: true
- platform: gpio
name: "Teckin Relay"
pin: GPIO14
id: relay
on_turn_on:
- switch.turn_on: blue_led
on_turn_off:
- switch.turn_off: blue_led
# Use red LED for connectivity status indicator
status_led:
pin:
number: GPIO3
inverted: true
sensor:
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO04
cf1_pin: GPIO05
# Higher value gives lower watt readout
current_resistor: 0.00221
# Lower value gives lower voltage readout
voltage_divider: 871
current:
name: "Teckin Current"
accuracy_decimals: 2
voltage:
name: "Teckin Voltage"
power:
name: "Teckin Power"
update_interval: 15s

View File

@ -1,92 +0,0 @@
# Example ESPHome code to emulate stock firmware functionality while maintaining 100%
# local control through Home Assistant.
substitutions:
device_name: '<NODE_NAME>' # used internally.. e.g. teckin_sp20
friendly_name: '<Node Name>' # displayed in HA.. e.g. Teckin SP20
esphome:
name: ${device_name}
esp8266:
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable Logs from the device
logger:
# Enable Home Assistant API
api:
# Enable Over-The-Air updates
ota:
sensor:
# Power measuring sensor
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO5
cf1_pin: GPIO14
current:
name: ${friendly_name} Current
power:
name: ${friendly_name} Power
id: power
filters:
# Some calibration
- multiply: 0.4545
voltage:
name: ${friendly_name} Voltage
current_resistor: 0.001 # default 0.001
voltage_divider: 910 # default 2351
change_mode_every: 3 # default 8
update_interval: 3s # default 60s
# Sum power readings over the day
- platform: total_daily_energy
name: ${friendly_name} Total Daily Energy
power_id: power
filters:
- multiply: 0.001 # convert Wh to kWh
unit_of_measurement: kWh
# Enable getting local time for total daily energy calculation
time:
- platform: homeassistant
id: homeassistant_time
status_led:
pin:
number: GPIO0 # Red LED
inverted: true
binary_sensor:
- platform: gpio
pin: GPIO13
id: button
name: ${friendly_name} Button
on_press:
- switch.toggle: relay
internal: true
switch:
- platform: gpio
id: blue_led
pin:
number: GPIO2
inverted: true
- platform: gpio
pin: GPIO4
id: relay
name: ${friendly_name}
# Tie Blue LED to relay
on_turn_on:
- switch.turn_on: blue_led
on_turn_off:
- switch.turn_off: blue_led

View File

@ -951,7 +951,6 @@ If you'd like to share configurations for specific devices, please contribute to
web-api/index
components/index
cookbook/index
devices/index
guides/index
changelog/index
custom/index