Tasmota on Sonoff S20 and S26 Smart Plugs

After failing to install Tasmota on some Australian certified smart plugs using tuya-convert I embarked on dismantling some Sonoff S20 and S26 smart plugs and flashing Tasmota on them using a CH340G USB to serial adaptor.

I purchased the CH340G USB to serial adaptor from eBay, and you can see it below.


So, starting with the S20, there are some good instructions on flashing this device in the Tasmota documentation. I firstly disassembled my device, and had a look at the board. 



You can see there are various sets of header holes, but it is those near the button that can be to be used to flash the device. Unfortunately mine weren't labelled, but the instructions I referred to previously had an image of another PCB which had the headers labelled. So, I connected the headers to the CH340G using duPont cables.


It's worth noting that the RX and TX cables need to be crossed so that RX connects to TX, and vice versa. The CH340G was set to supply 3.3V via the jumpers on the board.  I then plugged the CH340G into the USB port on my PC while holding down the button on the S20. GPIO0 on an ESP8266 chip needs to be held to ground on startup in order to put the device in flash mode, and holding the button on the S20 achieves this. 


I then downloaded the current Tasmota binary (6.6.0 at this time) and used a piece of software called NodeMCU-pyFlasher to flash the Tasmota binary to the S20. You can see the state of the NodeMCU-pyFlasher software after flashing below.



After successfully flashing the firmware, it's necessary to power cycle or restart the device, and it should boot up in the WiFi Manager mode, allowing the device to be configured to connect to a selected WiFi network. Unfortunately with my S20 I had a lot of issues here, in that I was not able to reliably connect to the device and set the config. So I actually needed to connect via serial to issue the commands required to set the WiFi configuration. I did this using Termite which is a serial terminal for Windows, and the CH340G USB to serial adapter I used for flashing Tasmota. 

You can see the Termite terminal window below, along with an example of the Tasmota Backlog command I executed to set the SSID and password. 


After setting the WiFi SSID and password, the S20 restarted and successfully connected to my WiFi access point. I then reserved a fixed IP address for the device in the DHCP settings of my access point, restarted the S20, and I was able to connect to the Tasmota web GUI by entering the selected IP into the address bar of a web browser. You can see the interface below.


Next I entered the Configuration menu and selected Configure Module, which led to the screen where I could select one of the preconfigured Tasmota modules. As per the instructions I selected the Sonoff S2X (8) module, as shown below.


Finally, returning to the Tasmota Main Menu I was able to see the web button to toggle the power for the device on and off.


In order for me to get the S20 talking to Home Assistant, it was also necessary for me to configure MQTT and other settings, but for now that's as far as I'll go with the Tasmota configuration.


Now on to the Sonoff S26. Again, fortunately there are some very helpful instructions in the Tasmota documentation for getting Tasmota onto this device, which were a great starting point. 

You can see the device in the images below, both complete and disassembled.





Due to it's smaller form factor, unfortunately the S26 didn't have the luxury of the header holes that were available on the S20. So, I realised it wasn't going to be as easy to flash as the S20. The instructions were recommending soldering cables to the contacts on the module, but I was determined not to do that, as I didn't want to make any physical modifications to the device.

You can see a close up image of the board with the ESP8266 module below, including the terminals for 3V3, GND, TX and RX.


The contacts looked reasonably accessible, and so I commenced efforts to connect to the device using duPont cables held against the contacts. It's fair to say this was not an easy process, and required 2 or 3 people holding cables or pressing buttons in a series of carefully synchronised manoeuvres. In the end the process involved holding the cables against the contacts, pressing the button on the device (so that it enters flash mode on startup), connecting the CH340G to a PC, and then flashing the device using the NodeMCU-pyFlasher software as described above for the S20. You can see an image giving an indication of how I (or rather we) did this below. I suspect this wasn't the most sensible method, but in the end it worked, and I didn't need to do any soldering. (I was also sufficiently emboldened to later try a similar process to flash Tasmota onto a number of Brilliant Smart Plugs.)


After successfully flashing Tasmota onto the S26, I then commenced setting it up. Fortunately the S26 didn't seem to suffer from the same WiFi issues I had with the S20, so I was able to set up the SSID and password using the Tasmota WiFi Manager. After reassembling the device, and powering it up, I could see a sonoff-xxxx access point available in the list of available WiFi networks on my Android phone, as expected. 


I connected to this access point, and was prompted to sign into the network.


After selecting that notification I was presented with a screen to configure the WiFi network I wanted to connect to.


After saving the configuration the device restarted and attached to my WiFi network. As with the S20, I then configured the S26 by selecting the Sonoff S2X (8) module on the Configure Module page in the Tasmota Configuration menu.

So, finally, after quite a few weeks of messing around I finally had some devices with Tasmota installed, and was ready to embark on my next Home Assistant project idea.









Comments

Popular posts from this blog

Smart Irrigation Controller with Tasmota and Home Assistant

Controlling Samsung Air Conditioner from Home Assistant

Brilliant Smart Ceiling Fan Remote in Home Assistant