Editor choice

SONOFF S20 smart health connected socket to make a super smart plug with ESP Easy – Your Smart Health Home Projects Guide

Today we present to you a tutorial . In this tutorial,  we explains how hacked the ESP8266 from a SONOFF S20 plug from the company Itead.Itead, the Chinese company that manufactures SONOFF products, offers a full range of products for smart health home  and smart health connected objects: controlled outlet, intelligent power supply, relay card, accessories for Raspberry Pi and Arduino…. These devices are built around an ESP8266 Wi-Fi module. Itead also markets several products, including the form of a bare card to integrate into DIY health home automation projects. Itead thought of hackers by integrating on the PCD the tracks allowing to solder a connector to communicate via the serial port with the ESP8285 module. To control your smart health connected socket from Jeedom, you can installed the ESP Easy firmware. You can also used the Rule system presented here to program the control button available on the front panel.

The Sonoff S20 plug is obsolete and not CE certified. It is better to buy the more compact and CE / FCC certified model S26 (2018). Follow this tutorial to hack the original firmware with the Tasmota Open Source firmware.

 

Buy Sonoff S20  from official site

Sonoff S20 Smart Socket - WiFi Smart Plug EU/US/UK/CN/AU

$12.86 out of stock
Last update was on: February 17, 2025 8:12 am

Remote ON/OFF–Turn electrical devices on/off from anywhere
App Support –Free iOS and Android mobile App eWeLink
LAN Control –Turn on/off the device even when WiFi has no Internet access
Sync Status–Real-time device status provided to App
Timing–Set...

Best Price of Sonoff S26

Remote ON/OFF–Turn electrical devices on/off from anywhere
App Support –Free iOS and Android mobile App eWeLink
LAN Control –Turn on/off the device even when WiFi has no Internet access
Sync Status–Real-time device status provided to App
Timing–Set...
$8.50
out of stock
Sonoff S26 WiFi Smart Plug - EU/US/UK/CN/AU/IT/IL/CH/BR

Best Price of ESP8266 Module

Warnings. Replacing the original firmware voids the warranty. It is not possible to reinstall the original firmware. The devices are not CE or FCC. You are responsible for the use of Itead products. DIY Projects cannot be held responsible in the event of an accident, injury or deterioration of equipment.

Project display

health home automation is gradually democratizing with the continuous appearance of new smart health connected objects.

On the communication protocol side, two technologies stand out, wifi and bluetooth, allowing direct communication with smartphones without having to go through a gateway (eg RF433, Zwave, etc.).

Wifi has the advantage of a larger range, often covering the entire house, but above all it allows communication via the internet thanks to the domestic box and its integrated router.

So everywhere, outside your health home, you can interact with objects smart health connected by wifi.

But the constraint of smart health connected objects is that each manufacturer has their dedicated app on the smartphone.

So the idea is to move towards Wi-Fi connections easily recognized by health home automation solutions.

For example Jeedom, a free open source health home automation solution, is continuously developing new interfaces thanks to its concept of “plugins”.

And for wifi there is the Espeasy plugin which allows you to interact with equipment with a wifi module Esp8266 “flashed” with the Espeasy firmware.

Yes, in general, the wifi modules operate with proprietary firmware, therefore closed, and the Esp8266, a very popular wifi module for “makers”, can be flashed with many firmware and in particular Espeasy, which has a user-friendly web interface.

One of the basic components of the smart health connected house is the piloted power outlet to: simulate presence (light, music, …), trigger additional heating, turn on the radio for its alarm clock, …

The purpose of this article (we are finally getting there) is to transform a conventional Wi-Fi socket into a super-communicating socket capable of managing various sensors: temperature, pressure, humidity, brightness, etc.

On the market it seems that the SONOFF S20 is currently the only wifi socket equipped with an Esp8266 module.

Flash ESP Easy on the SONOFF S20 socket

If you are new to ESP Easy, I would refer you to this overview article before going any further.

Necessary material :

  • SONOFF S20 socket: around $ 14
  • FTDI converter
  • USB cable
  • Connection cables
  • Female solder connectors

The SONOFF S20 socket is supplied and configured as standard for the E-Welink app. Flashing ESP Easy will obviously overwrite its initial configuration.

You have to start with disassemble the socket: remove the screw on the back (hidden by the red label), then unclip.

sonoff s20 wifi connected socket esp8266 diy hack "width =" 154 "height =" 252 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/2-sonoff-s20-prise-connectee -dos-wifi-esp8266-diy-hack.jpg 154w, https://projetsdiy.fr/wp-content/uploads/2017/05/2-sonoff-s20-prise-connectee-dos-wifi-esp8266-diy- hack-800x1309.jpg 800w "sizes =" (max-width: 154px) 100vw, 154px

On the electronic card there is a connection area with 4 terminals (VCC, RX, TX, GND); the marking is not systematic.

Then you have to weld a header with 4 pins on the electronic card to constitute the flashing connector (soldering on the reverse side), and for the applications described below.

sonoff s20 connector serial rx tx "width =" 227 "height =" 223 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/3-sonoff-s20-connector-serial-rx- tx.jpg 227w, https://projetsdiy.fr/wp-content/uploads/2017/05/3-sonoff-s20-connector-serial-rx-tx-799x785.jpg 799w, https://projetsdiy.fr/ wp-content / uploads / 2017/05/3-sonoff-s20-connector-serial-rx-tx-80x80.jpg 80w "sizes =" (max-width: 227px) 100vw, 227px sonoff s20 connector serial port rx tx hearder "width =" 267 "height =" 200 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/4-sonoff-s20-connector-serial- port-rx-tx-hearder.jpg 267w, https://projetsdiy.fr/wp-content/uploads/2017/05/4-sonoff-s20-connector-serial-port-rx-tx-hearder-800x599.jpg 800w "sizes =" (max-width: 267px) 100vw, 267px

The most delicate operation if we can say is to properly connect the socket to your PC via the FTDI serial converter with the following diagram:

SONOFF S20 side FTDI side
VCC VCC (be careful to put the FTDI jumper in the 3.3 V position)
RX TX
TX RX
GND GND

Install the Espeasy firmware on your PC (download the R120 version from https://sourceforge.net/projects/espeasy/)

By unzipping we get:

esp easy esp8266 firmware zip "width =" 408 "height =" 170 "srcset =" https://bwellmart.com/wp-content/uploads/2020/03/5-esp-easy-esp8266-firmware-zip.jpg 408w, https://projetsdiy.fr/wp-content/uploads/2017/05/5-esp-easy-esp8266-firmware-zip-799x333.jpg 799w, https://projetsdiy.fr/wp-content/uploads /2017/05/5-esp-easy-esp8266-firmware-zip-300x125.jpg 300w "sizes =" (max-width: 408px) 100vw, 408px

Double click to launch flash.cmd

espeasy sonoff s20 flash "width =" 429 "height =" 197 "srcset =" https://bwellmart.com/wp-content/uploads/2020/03/6-espeasy-sonoff-s20-flash.jpg 429w, https : //projetsdiy.fr/wp-content/uploads/2017/05/6-espeasy-sonoff-s20-flash-799x367.jpg 799w, https://projetsdiy.fr/wp-content/uploads/2017/05/ 6-espeasy-sonoff-s20-flash-300x138.jpg 300w "sizes =" (max-width: 429px) 100vw, 429px

There are 3 fields to complete:

  • Behavior : USB port number of your PC to which the FTDI is smart health connected (on Windows: Settings -> smart health connected devices -> Device manager -> Ports)

Tip: if you have the Arduino IDE, open the IDE and go to Tools -> Harbor

  • Flash size : 1024 (memory size of the Esp8266)
  • Build : 120 (Espeasy version)
  • Then Entrance

Before uploading Espeasy, you must configure the Esp8266 in flashing mode: before connecting to VCC press the socket button (GPIO 0 will be set to GND) and keep it pressed during power-up.

Uploading is fast:

espeasy sonoff s20 flashing firmware "width =" 383 "height =" 267 "srcset =" https://bwellmart.com/wp-content/uploads/2020/03/7-espeasy-sonoff-s20-flashing-firmware.jpg 383w, https://projetsdiy.fr/wp-content/uploads/2017/05/7-espeasy-sonoff-s20-flashing-firmware-799x557.jpg 799w, https://projetsdiy.fr/wp-content/uploads /2017/05/7-espeasy-sonoff-s20-flashing-firmware-300x209.jpg 300w "sizes =" (max-width: 383px) 100vw, 383px

If the flashing fails, the FTDI may not deliver enough current. In this case supply the VCC of the Esp8266 with a separate 3V supply (eg 2 x 1.5V batteries) with GND sharing.

Once the flashing is finished, you must start Espeasy and know its main features. Everything is explained in this tutorial.

However, I draw attention to the stage where the screen appears with “Proceed to main config », Do not forget to reconnect on your Wifi network before launching Proceed to main config.

Now that Espeasy is installed how to control the operation of the outlet, first with the Espeasy web interface then with Jeedom.

The socket has a relay and a push button for manual operation.

The relay is activated by the GPIO 12 (1 = ON, O = OFF) and the push button acts on GPIO 0 (Pressed = 0, released = 1).

To Review the relay, use the “Command” function in “Tools”: enter “gpio, 12,1” then Submit; the relay slams. With gpio, 12.0 the relay returns to rest.

sonoff s20 esp easy test command "width =" 192 "height =" 198 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/8-sonoff-s20-esp-easy-test- command.jpg 192w, https://projetsdiy.fr/wp-content/uploads/2017/05/8-sonoff-s20-esp-easy-test-command-800x825.jpg 800w "sizes =" (max-width: 192px) 100vw, 192px

Let’s Review the push button: nothing happens. This is normal, it is necessary to create a program with GPIO 0. For this we will use the Rules programming editor and create Devices.

Creation of 3 Devices:

  • SWITCH, linked to the push button
  • GPIO12, linked to the relay
  • GPIO2, virtual device for programming needs

sonoff s20 hack esp easy devices "width =" 475 "height =" 201 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/9-sonoff-s20-hack-esp-easy- devices.jpg 475w, https://projetsdiy.fr/wp-content/uploads/2017/05/9-sonoff-s20-hack-esp-easy-devices-799x338.jpg 799w, https://projetsdiy.fr/ wp-content / uploads / 2017/05/9-sonoff-s20-hack-esp-easy-devices-300x127.jpg 300w "sizes =" (max-width: 475px) 100vw, 475px

Device Configuration:

sonoff s20 hack esp easy switch command "width =" 328 "height =" 359 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/10-sonoff-s20-hack-esp-easy -switch-command.jpg 328w, https://projetsdiy.fr/wp-content/uploads/2017/05/10-sonoff-s20-hack-esp-easy-switch-command-799x875.jpg 799w, https: / /projetsdiy.fr/wp-content/uploads/2017/05/10-sonoff-s20-hack-esp-easy-switch-command-274x300.jpg 274w "sizes =" (max-width: 328px) 100vw, 328px sonoff s20 hack esp easy gpio-2 "width =" 319 "height =" 366 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/11-sonoff-s20-hack-esp- easy-gpio-2.jpg 319w, https://projetsdiy.fr/wp-content/uploads/2017/05/11-sonoff-s20-hack-esp-easy-gpio-2-799x917.jpg 799w, https: //projetsdiy.fr/wp-content/uploads/2017/05/11-sonoff-s20-hack-esp-easy-gpio-2-261x300.jpg 261w "sizes =" (max-width: 319px) 100vw, 319px sonoff s20 hack esp easy gpio-12 "width =" 315 "height =" 359 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/11-sonoff-s20-hack-esp- easy-gpio-12.jpg 315w, https://projetsdiy.fr/wp-content/uploads/2017/05/11-sonoff-s20-hack-esp-easy-gpio-12-799x911.jpg 799w, https: //projetsdiy.fr/wp-content/uploads/2017/05/11-sonoff-s20-hack-esp-easy-gpio-12-263x300.jpg 263w "sizes =" (max-width: 315px) 100vw, 315px

The GPIO2 and GPIO12 devices were created to have the status reports of the associated GPIOs.

By activating the relay with the command gpio, 12.1, we see that the Device GPIO12 goes to state 1.

Let’s move on to the programming logic: pressing the push button must change the state of GPIO12 regardless of the event that created its initial state.

To familiarize yourself with Rules I recommend reading https://www.letscontrolit.com/wiki/index.php/ESPEasy#Rules_page

Here is the script you just need to paste in the Rules field:

on GPIO#Sw12=1 do
  gpio,2,1
  endon
on GPIO12#Sw12=0 do
  gpio,2,0
  endon
on SWITCH#Switch=1 do
  if (GPIO2#Sw2)=0
    gpio,12,1
  else
    gpio,12,0
  endif
endon

sonoff s20 hack esp easy rule "width =" 449 "height =" 335 "srcset =" https://projetsdiy.fr/wp-content/uploads/2017/05/13-sonoff-s20-hack-esp-easy- rule.jpg 449w, https://projetsdiy.fr/wp-content/uploads/2017/05/13-sonoff-s20-hack-esp-easy-rule-799x596.jpg 799w, https://projetsdiy.fr/ wp-content / uploads / 2017/05/13-sonoff-s20-hack-esp-easy-rule-300x224.jpg 300w "sizes =" (max-width: 449px) 100vw, 449px

We Review: it works, and the blue LED lights up when the relay is activated.

But our take has other resources that the Esp8266 provides. Remember the 4 terminals of the flashing connector: VCC, GND, TX, RX.

These terminals are available to supply sensors, in fact TX and RX are respectively smart health connected to GPIO1 and GPIO3.

The list of sensors and equipment managed by Espeasy is already quite substantial: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Supported_Sensors.2FActuators

These various sensors and equipment are efficient and inexpensive (a few euros on Amazon, Ebay, Aliexpress, etc.)

Note that if you configure the GPIO1 and GPIO3 in SDA and SCL (I2C communication) you can connect several sensors or equipment using this communication mode: for example a BME280 weather sensor (pressure, temperature, humidity) and a 4 × LCD display 20 or Oled SSD.

In fact Espeasy differentiates the I2C addresses of each device (I2C Scan function in the Tools menu).

In practical terms, you can use a 3.5 mm jack with 4 connectors to properly connect the sensors.

We therefore see the advantage of a SONOFF S20 thus modified, for example to regulate autonomously the temperature and / or humidity of a room with heating equipment, a dehumidifier; the lighting according to the brightness.

An example of weather sensor tested on a SONOFF module, and the S20 socket modified with a jack.

sonoff smart power "width =" 268 "height =" 136 "srcset =" https://bwellmart.com/wp-content/uploads/2020/03/14-sonoff-smart-power.jpg 268w, https: // projectsdiy.fr/wp-content/uploads/2017/05/14-sonoff-smart-power-798x405.jpg 798w "sizes =" (max-width: 268px) 100vw, 268px sonoff s20 hack "width =" 215 "height =" 142 "srcset =" https://bwellmart.com/wp-content/uploads/2020/03/15-sonoff-s20-hack.jpg 215w, https: // projectsdiy.fr/wp-content/uploads/2017/05/15-sonoff-s20-hack-799x528.jpg 799w "sizes =" (max-width: 215px) 100vw, 215px

But the end of the end is still to integrate our instrumented plug into a health home automation solution.

Again, Espeasy is very user-friendly because it can communicate through numerous protocols: HTTP, MQTT, ThingSpeak,…

The same process obviously applies to all SONOFF products incorporating an ESP8266 (or ESP8265) wifi module.

Use the coupon code to get Free Shipping on SONOFF orders over $99
SONOFFFPSL
ITEAD itead.cc

Conclusion

In health home automation, wifi offers a very efficient mode of communication both in terms of speed and range.

Thanks to the appearance of open components such as the Esp8266, it becomes relatively easy to boost the capacities of inexpensive basic products such as a smart health connected socket, and integrate them into open health home automation solutions like Jeedom, Domoticz or home Assistant.

 

 

 

 

 

 

 

Best Price of Sonoff S26

Remote ON/OFF–Turn electrical devices on/off from anywhere
App Support –Free iOS and Android mobile App eWeLink
LAN Control –Turn on/off the device even when WiFi has no Internet access
Sync Status–Real-time device status provided to App
Timing–Set...
$8.50
out of stock
Sonoff S26 WiFi Smart Plug - EU/US/UK/CN/AU/IT/IL/CH/BR

 

 

 

 

 

 

 

 

 

 

 

 

 

Discover other Sonoff socket models
6x Sonoff ITEAD WiFi Wireless Smart Switch Module Shell ABS Socket for Home DIY condition: New Brand: GenericMPN: Does not applyType: APP WIFI Wireless SwitchConnectivity: WirelessConnected Home Protocol: Wi-FiConnected Home Compatibility: eWelink
$106.23
in stock
6x Sonoff ITEAD WiFi Wireless Smart Switch Module Shell ABS...
Use the coupon code to get Free Shipping on SONOFF orders over $99
SONOFFFPSL
ITEAD itead.cc

Discover more Smart health DIY projects with AB SMART HEALTH

We will be happy to hear your thoughts

Leave a reply

B Well Mart
Logo
Shopping cart