Adding temperature / humidity sensor to Sonoff S20 socket

I wasn’t overly happy with the reporting time of the Xiaomi temp/humidity sensor’s, as they are battery based, so it’s only when a major change happen’s, to save battery life, I get it, but it annoy’s me what the graph looks like, Xiaomi on the left, Sonoff TH10 on the right.

So i did some googling around, as I have a load of Sonoff S20’s around the house for things, and came across this page on the Tasmota Github, https://github.com/arendst/Sonoff-Tasmota/issues/670 and thought I would give it a go, and just write it up on here to show that if I can do it, anyone can do it.

So first off, open up the S20 plug, and look for where the header pins will go,

Solder in a set of header pins,

Grab some header wires, and a 3.5mm stereo jack, i got mine from eBay here, https://www.ebay.co.uk/itm/263856922007 and solder them onto the pins. To check which pins are which, I just striped down a 3.5mm cable and plugged it into the jack, and used a volt meter on continuity mode to give me a buzz, when a connection was made. You should already know which pins are which as you have flashed Tasmota onto the device already, but just in case, you can find all the information here, https://github.com/arendst/Sonoff-Tasmota/wiki/Sonoff-S20-Smart-Socket

3

You should find the outside pins are the stereo wires, and the top middle pin is the earth wires on the cable, its irreverent on colours etc, just as long as you plug the headers into the correct pins.

Drill a 6mm hole in the side of the S20, and with some hot glue, stick the jack in place,

Now connect up the header pins to 3.3v, GND and I used GPIO3, you should have worked out which correlates to which when you soldered on the header cables.

Looks all nice and neat when put back together.

Now solder on a DHT21 AM2301, I got mine from eBay again here, https://www.ebay.co.uk/itm/141676092448 to a 3.5mm jack cable, you guessed it, eBay again, https://www.ebay.co.uk/itm/351522770049

Excuse the blue tape, I don’t have any heatshrink, but obviously, you want the 3.3v to go to the Red cable, GND to go to the Black cable, and then GPIO3 to go to the yellow cable.

Go into the Tasmota settings on the S20,

9

Chose the AM2301 on the Module page, give it a restart, and you should now have temperature and humidity readings on the front page,

10

Doesn’t look too bad when its done and sorted. (apart from the sketchy insulation tape :smiley: )

Then if you want to add it into HA, this is the sensor code for it,

- platform: mqtt
  name: "Plug 2 Temperature"
  state_topic: "tele/plug_2/SENSOR"
  value_template: "{{ value_json['AM2301'].Temperature }}"
  unit_of_measurement: "°C"
  retain: true
- platform: mqtt
  name: "Plug 2 Humidity"
  device_class: "humidity"
  state_topic: "tele/plug_2/SENSOR"
  value_template: "{{ value_json['AM2301'].Humidity }}"
  unit_of_measurement: "%"
  retain: true

Obvoulsly adjust to the correct state topic for your device.

So for relatively cheaply, and minimal soldering skills, as mine are pretty bad, you can now get a nice constant 5 minute temperature reading on devices that you were already using.

Hope this inspires someone else to give it a go too, any questions, just ask, and I’ll do my best to help out.

8 Likes

Awesome i would also like to get this working, but i have a sonoff s20 with PCB Version 2.1.
Does anyone know where i can connect the gpio?