Close

Chosing a humidity sensor : skip DHT22, go for BME280!

A project log for My Smart FishRoom/Animal Room

how i'm building my fishroom (aquariums), and what i do to automate it and make it smart.

Audrey RobinelAudrey Robinel 01/04/2018 at 07:280 Comments

A quick post on humidity sensors here. I was reading this HAD article on Statistics (great reading by the way), and noticed the use of DHT11 humidity sensors. DHT11 are worse sensors than DHT22, and to speak frankly, the DHT22 is already quite crappy to begin with.

Why is that? first of all, it's communication protocol is something weird that you'll use only for this sensor, unlike 1wire that is used by multiple sensors (ok, in all honesty, we use it almost only for DS18B20 temperature probes, but other stuff exists, and at least there are cool things with this protocol, such as unique adresses, the fact that it's a bus and uses up only one GPIO for whatever number of sensors, etc...) or I2C that is used by loads of sensors.

Why does it matter? Well if you design a board for some application, and you have somewhere to put I2C devices, you can reuse it for other applications. On my ESP8266 breakout board, i did put KF2510 connectors with 4 pins, for I2C (VCC, GND, SDA and SCL), and i use the same boards for loads of projects.

With a DHT11/22, you have to put the pull up resistor between vcc and data for each connector, meaning that you can't use it for something else that doesn't require a pull-up, or require another resistor value.

Another problem with this sensor is that it has low accuracy and low resolution. Perhaps i've always gotten bad ones, but two sensors rarely return the same value in the same environement (several °C of difference, and 5-20% of humidity difference....).

What is the final nail in the coffin of those sensors is the cost of good quality sensors : the BME280, made by bosh (at least we know from where it comes from, as well as have access to ONE comprehensive datasheet) costs 2€ on a cool little breadboard that works out of the box on many µCs or systems.

On top of that, you add a good temperature sensor, and a barometer along, all with much better resolution and accuracy. In most cases, in similar conditions my BME 280 sensors return very similar values, or pretty damn close to that.


Those two graphs show the humidity in my fishroom for a few days, and as you can see the graphs look pretty similar.
I didn't keep the data, but it wasn't the case at all with DHT22 back when i used those.

The point of this post/rant is to say this : don't chose a sensor because it's cheap and there is a tutorial online for it. Use more recent sensors, they are often barely more expensive than old junk that have been around for ages. They also often use more standardized interfaces, are well documented, and most of the time, Adafruit or Sparkfun has a great library (and a guide) for those parts. And more often than not, their libraries work for the cheap chinese clones of the adafruit breakout boards.

In the end, you get more reliable data, you know what accuracy to expect, you know the refresh rate for sure, the communication protocol is nice and standard, you can easily integrate it in your projects, and you benefit from a good ecosystem. And when a better sensor comes out, you can easily upgrade your IOT thing or your sensing stuff with the shiny new sensor (i'm waiting for the BME680 boards to be available at low price!)

Discussions