DIY: Cheap wifi-based temperature/humidity sensor based on ESP8266 & DHT22

Hi,

just completed my first hardware project for my OpenHAB setup: A simple and cheap wifi sensor for temperature and humidity. This is how the sensor data looks in the classic UI:

Look for “Temperatur” and “Luftfeuchtigkeit” - my interface language is German. The sensor is based on the cheap ESP8266 wifi microcontroller and a DHT22 temperature/humidity sensor. It looks like this:

The PCB is around 5x5cm and can be built in 30 minutes from scratch. If you want to know more, the complete project description (including code & schematic) is on github:

ESP8266-DHT22-sensor on Github

The README also contains the item definitions etc. for integrating the sensor into OpenHAB.

-Mathias

16 Likes

Thx for sharing and the great documentation!
Will definitely try it some time …

I’ve been making something similar but it posts it’s data to a MQTT server running on the same machine as OpenHAB. I also have 3 made using a arduino ethernet for my work to monitor the server room temperatures.

MQTT seems to be a popular choice for DIY sensors, and there is nothing wrong with it. I simply wanted to avoid the need for another component (the broker). Typically, temperature and humidity change only rather slow, so polling the values via HTTP seemed to be the easiest way. But as I said: nothing wrong with MQTT!

Quick update: I added support for the Dallas DS18S20 onewire sensor. This sensor costs around 2 Euros - if you don’t need humidity you can now use this sensor instead of the slightly more expensive DHT22. Besides, I had some of these sensors lying around.

I also revised my schematic and added proper decoupling capacitors. The DS18S20 appeared to cause intermittent resets of the ESP8266. After adding the capacitors the circuit now runs very reliable.

The updated code is in the github repository.

Looks interesting.
Is it suitable for battery operation? I.e. Can it push a reading when it wakes up or is it always listening for a poll with its webserver?
Mike.

Hi @mjptec,

currently, it is always listening - so it is not suited for battery operation. But it is not difficult to modify the hardware: if you add the appropriate resistor you can use the deep sleep mode of the ESP8266. The software then would need to wake the system periodically and post the current measurements to OpenHAB’s REST interface.

So, in short: doable, but not implemented. But I accept pull requests :wink:

-Mathias

1 Like

Hi @gonium,

Actually, that’s a really nice little board. I’ve not come across it before. I shall order some and see if I can contribute.

Mike.

@mjptec - I just read that the pin needed for deep sleep is not exposed on the ESP-01 modules. Although it can be hacked to get to the pin I think it would be easier if you started with a bigger ESP-12 module. I bought one with a small devboard around it for about 7 Euros, if I remember correctly.

Nice work:)

@gonium

OK, thanks for the heads up, it looks like a much more versatile board to work with anyway. In fact it would make an excellent basis for a generic sensor / actuator module.

If only z-wave were this open.

@mjptec - I just found the Espressif ESP-WROOM-02 module. At 4 Euro it is not significantly more expensive than the ESP-01, but it offers much more in terms of pins etc. The only drawback is that it isn’t pluggable, but maybe someone comes up with a nice adapter to fix this.

I ordered some modules at a German webshop and will have a look as soon as the paket arrives.

-Mathias

Just finished the protoboard version of the DS18S20 temperature sensor:

Since the sensor is more compact I opted for a smaller board: its just 5x2.5 cm.

UPDATE: Making the board as small as possible seemed to be a good idea, but in fact it destroyed the accuracy of the sensor. It was too close to the ESP8266 and picking up the waste heat of it. I extended the board again and moved the sensor away from the ESP8266. I also added long supply traces that can dissipate the heat better. Now I’m happy with the accuracy, although I want to run a long-term test before final judgement.

Hi @gonium,

Thanks, I’ve ordered a couple of the wroom version as well. It does seem to be the best option.
I’ll make a test PCB in the next couple of weeks an let you know how I get on with the low power version. :smile:

Mike.

I’m pretty busy these days, but I managed to record some sensor data for the long-term test of my sensors. The data looks like this:

The top (green) line shows a DS18S20-based sensor, the lower (red) line shows the DHT22 temperature measurement. The DHT22 sensor sits 80cm above my floor, the DS18S20 sensor about 3,5m - so the temperature offset between the two is expected.

BUT: The individual measurements of the DHT22 are not stable enough. I will rewrite the firmware to use a low-pass filter for the measurements, but this will have to wait until I return home.

Universal FW for esp8266 - http://www.wifi-iot.ru/
I use it for door sensors, power and gas counter. It support many sensors “out the box”:
LM75, INA219, DS1621, DHT 11/22, BMP 085/180, BH1750, AM2321, 1-wire DS18B20, BME280, SHT21/SI7021.
Pro version only $2, but it save a lot of time. No need to program esp, all settings in web ui.
And you can ask author to add something what you need.

For OpenHAB i use MQTT module.
You just check firmware modules and create firmware you need.
If you need many functions use esp12 with 1024k flash.

This is openhab, oled and esp12 and that firmware- http://www.youtube.com/watch?v=1XvOkSpi68I
https://dl.dropboxusercontent.com/u/4094156/IMG_6117.jpg

Info page in russian - http://homes-smart.ru/index.php/oborudovanie/bez-provodov-wi-fi/62-besprovodnoj-datchik-na-baze-esp8266-dlya-servisa-narodmon-ru

I did just that, the new code is in the github repository. The result is clearly visible in this graph:

I uploaded the new firmware around 22:00. Currently, I am averaging the last six measurements. Between measurements there is a 10s delay. I could probably tune these parameters a little in order to make the plotted line more smooth, but the DHT22 is not a very stable sensor and I prefer not to interfere with the measurements too much. For a room temperature sensor, getting the average of the last minute seems adequate: it is not changing that quickly.

Hi @martiniman,

this indeed looks interesting. My only critique is that it is not open source - I would like to have a look at the code before I integrate it in my network. Do you know whether the source code is available somewhere?

-Mathias

Here IRC chat (#esp8266 on forestnet.org), MaksMS firmware author, you can freely talk with him.
Web version: http://chat.forestnet.org/?channels=esp8266&uio=d4

I played around with many temperature/humidity sensors and i was unsatisfied with the DTH11 and DTH22 sensors releated to humidty (+/- 20%) values.
I’ve decided to use Sensirion modules like SHT10. More reliable than the DTH sensors but also more expensive.

This should only be an information to the quality of this sensor.