Sensor Comparison: DHT11 Vs DHT22 Vs BME680 Vs DS18B20

3.4K12

Intro: Sensor Comparison: DHT11 Vs DHT22 Vs BME680 Vs DS18B20

The purpose of this mini project was to compare these popular hobbyest temperature sensors performance side by side in a "Normal" ambient room temperature.

STEP 1: Sensor Datasheet Comparison

The BME680 sensor is the most feature rich option with the ability to output 4 different data points on each read (Temperature, Humidity, pressure & gas levels) making it a great all in one option for any hobbyist projects, this comes with the trade of being the only sensor requiring more than 1 data line.

All the other options here use a 1-wire comms line, the DHTxx sensors will require a unique line per sensor while the DS18B20 comes with a 64-bit unique ID meaning you can connect multiple DS18B20 sensors to the same 1-Wire data line.

On paper these sensors have similar temperature reading specs. The least appealing option being the DHT11 which has a much tighter temperature range & the worst recorded accuracy at +/-2%.

On paper all of these sensors are likely accurate enough for a hobbyist project but let now find out how they really perform.

STEP 2: How to Wire Up Experiment

For this experiment we will be using an Arduino Nano to communicate with all 4 sensors simultaneously to get a real time comparison of the 4.

Follow the Fritzing diagram if you want to duplicate this setup,

BME680 (I2C)

 - SCL = A5

 - SDA = A4

DHT11

 - Sig = D6

DHT22

 - Sig = D5

DS18B20

 - Sig = D2 (This line is pulled up to supply 5V with a 4.7k Ohms resistor)

Please review the attached DS18B20 pin out diagram to ensure you have connected VDD & GND the correct way around before powering up!


STEP 3: Code & Test

Before you can program the attached code, you will first need to install the required Libraries


#include "DHT.h"

#include <OneWire.h> 

#include <DallasTemperature.h>

#include <Wire.h>

#include <SPI.h>

#include <Adafruit_Sensor.h>

#include "Adafruit_BME680.h"


To do so open the Library Manager as shown in the attached image & install the libraries listed above,


Once the libraries have been installed you can download the attached "DHT11_DHT22_BME680_DS18B_Demo.ino" and program the Arduino Nano.


Note that the serial port for this code has been configured for BAUD 115200, so ensure that the Arduino serial port has been configured for that as shown in the attached image.


This code has been configured to output all the sensors results in a CSV format so the data can easily be imported into excel for analysis.


I used Putty to open a com port with the Arduino, my putty terminal was configured to save the console into a .log file which effectively works as a log.

STEP 4: Results

I left the setup running for 3 hours at my desk logging the results every approximately 1.5 seconds.

Thermal Raw

I was actually quite surprised by how differently they all behaved,

  1. The DHT11 & DHT22 behaved very similar with the same temperature curve over the 3 hours with a minor <0.5C offset.
  2. The BME680 & DS18B20 had almost 2C offset but behaved the same over the 3 hours with an increase of temperature while the DHTxx modules reduced at the ~1 hour point.
  3. The dynamic range of the BME680 sensor is a lot better than the very "steppy" outputs from the other 3 sensors. The DHT22 looks like it's probably second best based on these results.

Thermal Zeroed

I formatted the results so that they all started at 0C, then plotted the change from original start point over the test period. This filters out the actual temperature in the room and instead highlights the change measured by the sensors.

  1. Here we can still see that the three sensors are all within ~1.2C of each other at any given point.

Humidity Raw

The Humidity results were very consistent with all 3 sensors able of measure having identical shapes over the 3-hour test period.

  1. Here we can see the DHT11 sensors pressure resolution is very low, it is still able to capture the general changes, but the data doesn't look nice when plotted like this!
  2. The DHT22 and BME680 almost look identical just with an offset which is very impressive.

I would have expected the BME680 to outperform the DHT22 here due to it using a MEMS sensor system, but the resistive moisture sensor in the DHT22 works impressively well.

Obviously, all these results have to be taken with a large pinch of salt, none of these devices have been calibrated so we can only compare them to one another. Based on these results I would likely recommend the BME680 if the best resolution is required, but the DHT11 is surprisingly good considering it's so cheap!

STEP 5: Conclusions

DHT11 - This is the cheap and cheerful option. Simple to setup & use, cheap and quite accurate

DHT22 - This is a beefed-up version of the DHT11 improved accuracy while still being simple to use at the cost of an increased price

BME680 - The most feature rich option with excellent resolution and accuracy at the cost of a more complex communication setup and price

DS18B20 - The industrial/extreme environment option, while the accuracy of this sensor for its price is not that impressive, it trades that off with the ability to stack multiple sensors on a 1-Wire signal line and the closed enclosure of the DS18B20 makes it ideal for harsh environments or outside use.

STEP 6: Thanks for Reading

I hope this short guide has been helpful, if you have any questions please leave a comment or direct message me!

Comments

Great writeup! Interesting to see the difference in these. Using a few DS18B20 here at home and a couple of AHT10 and found this while looking into temperature diffrences betwen those two.