DHT11 and Arduino

Darpan Pathak
3 min readJan 9, 2018

--

DHT11 — MQ135 with Arduino

This was a small weekend experiment which I wanted to try for a long time. After a long time i have started experimenting with Arduino again. For my first attempt i choose to work with DHT11 temperature and humidity sensor.

To get started with this project, we need following items ready with us

  1. Arduino UNO ( You can choose any version but i choose to work with UNO the basic version)
  2. DHT11 Sensor ( You can find amazon link by clicking here )
  3. Jumper Wires

If you want to know more about the DHT11 sensor, you can check the link below

DHT11 Sensor Versions

The diagram is given below, and I used a 3pin version. The good thing about DHT11 is that it gives you both humidity and temperature both.

Factsheet for DHT11

  • Ultra low cost
  • 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 20–80% humidity readings with 5% accuracy
  • Good for 0–50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)
  • Body size 15.5mm x 12mm x 5.5mm
  • 3 pins with 0.1" spacing

The circuit that I setup is based the below diagram

DHT11 connection with arduino

If you see the circuit digram, you can find the connection as below

VCC of DHT11 -> 5v Pin of Arduino UNO

GND of DHT11 -> GND Pin of Arduino UNO

Signal pin of DHT11 -> Digital Pin 2 of Arduino UNO

Things to remember that even though the circuit digram has 4 pins of DHT11, i have used 3 pin DHT11 in my project and in worked as aspected. In case you use 4 pin DHT11, you might want to attach 10k pull up resister between VCC and Signal pin of the DHT11.

To program in arduino IDE, we will have to import the DHT11 library. I have attached the link of the lib below

https://github.com/darpanpathak/DHT11-arduino/blob/master/DHT.zip

and the code is given below

In this code, we are reading temperature and humidity on the serial port. we can see the output by opening the serial port as below

Output on the serial console

I have also logged this data in the firebase realtime database to visualise it on the web. You can see the realtime running graphs in the final output of this experiment. :-D

Final output with web application

You can find all images, library and Arduino sketch on my GitHub repo.

--

--

Darpan Pathak

Engineering manager and software architect | Formally a software engineer at cimpress, synechron, wipro | Entrepreneur, Software Engineer, Writer.