In your smart home, controlling and access sensors and devices is an essential capability. From a functional viewpoint, smart power switches just offer a remote control for enabling or disabling power. But from a smart home perspective, these devices allow powerful and creative use cases, like time-based scheduling of other sensors, or the activation and deactivation based on events.
Reading several articles from the IOT and Home Assistant Community, a particular brand for smart devices was suggested: Sonoff. Devices from this manufacturer provide great compatibility with Tasmota, a feature-rich firmware that interoperate with many smart devices. Browsing the extensive hardware support list, I stumbled over the recent Sonoff S26 R2.
This article presents my experiences when flashing these devices. You will learn about the required hardware and software, see the steps of disassembling, soldering, flashing and testing the switch, and finally see how to integrate them in Home Assistant.
The technical context for this article is Tasmota 14.3
and Tasmotizer #cc9d34e (2024-01-30)
. All given examples should work with newer versions of the firmware and library too.
This article originally appeared at my blog admantium.com.
Overview: Required Hardware and Software
You will need the following items:
- Sonoff S26 R2 smart power switch
- USB-to-Serial adapter, preferably with the CH340G chipset
- Soldering Iron
- Jumper & Du-Pont wires
- Construction tools (skew driver, pincers etc)
For the software:
- Download the latest Tasmota Firmware
- An ESP8255 flashing tool, such as Tasmotizer for uploading the firmware and easy first-time with a name, WIFI and MQTT credentials
- A MQTT message broker such as Mosquito.
Sonoff Power Switch: Disassembly
On the outside, the power switch has a notch for inserting the power plug, and a button that activates the power outlet. On the backside, you see three screws. Unscrew them to open the half-shelves.
Inside you see the power outlet plus an integrated circuit.
Sonoff Power Switch: Soldering Wires for Serial Connection
The next step is to fix wires to VCC, GND, RX and TX on the board. On the backside of the integrated circuit, for each of these you will have 2-milimeter diameter surface contacts to which you need to connect wires.
You can either use special pincer connectors or solder the wired to the surface. I opted for soldering and did for each connection:
- Apply soldering wire to the soldering pen, then coat the jumper wire
- Heat the surface contacts, then applying soldering wire, forming little pins
- Solder the jumper wires to the pins
It took some time, but I had no trouble with the very first try. Here is how it looks like:
Sonoff Power Switch: Flashing and Configuring the Device
Now all four wires need to be connected corrected to the USB-to-Serial adapter:
- VCC to 3.3V
- GND to GND
- RX to TX
- TX to RX
Also check if your USB adapter has a jumper for setting 3.V and 5V logic - set this to 3.3V too.
Connect the USB adapter to your computer and start the Tasmotizer app. Click on "Refresh", and the interface ttyusbserial
should appear. Select the downloaded firmware, and click on Flash
. If you see a progress dialogue like shown here, everything is good. Otherwise, toggle each soldered wire - if they fall off, you have got your culprit (this happened for my 2nd Sonoff!).
Now it gets exiting! Reconnect the USB Adapter, then click on "Configuration", and provide the name, WIFI and MQTT connections:
After a short time, you should see a new device in your router: Your Sonoff is a Tasmota-Based Device!
The final step is to apply the correct configuration template, a text that instructs the device about its function. I used this one:
{"NAME":"Sonoff S26R2","GPIO":[17,255,255,255,0,0,0,0,21,56,0,0,0],"FLAG":0,"BASE":8}
You apply this template in the same configuration dialog as shown above. With this change, the power switch is ready to be used.
Functional Test
Before desoldering, I actually jumped ahead to a full Home Assistant integration test - but this is not necessarily. If you have the device flashed and see it in your router, you can also access the device via a Web UI that’s automatically provided by Tasmota. Simple connect to port 80 to the devices ID, and this should show up:
Check the "Information" button, and try to turn the device on and off. If all works well, careful desolder the wires and close the case.
Home Assistant Integration
First, go the integration page and add the Tasmota integration. On the devices section, you should see the newly found Tasmota devices.
Click on a device, and you should see its complete configuration. Click on the button "Add to Lovelace", and configure the order of entities in the next screen.
This card shows all device details, and a small switch to activate or deactivate your Sonoff.
Conclusion
Smart power switches are simple smart devices that toggle their state by a command. This article showed you how to bring the Tasmota software to Sonoff S26 R2 switches, converting a proprietary device to an easily controlled and Home Assistant integrated device. First, you learned about the hardware and flashing preparation: open the switch case, identify the VCC, GND, RX and TX pins, solder connecting wires to it. Second, you learned about the Tasmotizer software: Define an initial configuration, flash the device, add a template function, test via the web interface. Third, you saw how to integrate the Sonoff device with Home Assistant: Add the integration, add a dashboard card. Now, for which automations will you use these power switches?
Top comments (0)