Adding a DHT22 temperature and humidity sensor to the Sonoff
I want more…
Just a few days ago I replaced the firmware on my Sonoff, and immediately after, I wanted more…
After looking on their website, I found a version which also had a DHT11 sensor attached, and I then wanted to do something similar, just with a DHT22 for higher resolution (0.1C on a DHT22, compared to 1C on a DHT11). After digging a bit more in the schematic for the Sonoff, I found that the last pin on the 1×5 pinheader, was connected to GPIO14, so it should not be that difficult to get up and running.
Let’s do this!
Well, okay… I might have cheated a bit, by using the NodeMCU development board first, and get all the coding done and tested, before uploading it to the ESP8266 in the Sonoff…
Next I mounted the DHT22 to the side of the box, beware, you don’t have much free space on the side where the power supply is. Instead mount it on the side with the relay. Here I have put a screw in just above the relay, so I can drill holes at the other end, and easily have them clear the relay too.
Here the wires for the DHT22 have been soldered to the pin header, one for 3V3, one for GND, and the last for the data coming from the sensor.
Don’t make the wires too long, or the case will be difficult to close, and they would be at bigger risk of getting close to things they should not come close of.
When closing the case, make the wires bend out towards the led, to keep them away from the other components inside the box.
After having had a go at replacing the firmware on the Sonoff, and adding a temperature and humidity sensor, I am generally pleased with how the device is put together, and the choice of parts, but… As you probably noticed, I got the mains in and mains out soldered directly to the board. I had to do this because after tightening and losenig the screws in the terminals a few times, the thread simply started to fail, and made it impossible to tighten them. The entire body of the connectors were also twisting quite badly when tightening the screws, which is a problem I have found with quite a lot of products.
In my first projects, I used similar terminals, but after having those fail, I went searching for alternatives, and found some very good ones. They are slightly bigger, and instead of having a screw pressing down on a thin metal plate, they lift a little metal bar up, which holds the wires very firmly in, and will hold up to a lot more use.
But still, for the price of this thing, it is still very good value, with a lot of uses once you made it 100% your own.
Code will be provided soon, just need to do some cleaning up in it first.