DHT11 Humidity and temp sensor

This guide also available on Youtube here:

The DHT11 Humidity and temp sensor comes in a small package similar to that below

In the version used here there are three connection pins but in others I’ve seen there have been four but one has been unused. The three connections are Vcc,Gnd and Signal. The connection diagram is shown below:

In order to talk to this device you will need two libraries from Adafruit. The first is specific to the DHT11.

https://github.com/adafruit/DHT-sensor-library

If you do not know how to install a Arduino Library see this guide.

The second library is the Adafruit Common sensor library, which as the name suggests is a library (created by Adafruit) that has common functions in used by their other sensor libraries. If you’ve not already installed it for another sensor then it can be found here:

https://github.com/adafruit/Adafruit_Sensor

Edits to the code
Look at this line in the code (should be at line 6)

#define DHTPIN 2

This is stating which digital pin is going to be supplying data from the sensor, we have used pin 7 in our circuit, so change this to

#define DHTPIN 7

Lines 8-11 also need some editing;

This shows that the Adafruit library can work with various similar sensors, we are using the DHT11 so comment out the #define DHTTYPE DHT22 and uncomment the //#define DHTTYPE DHT11. The code should look as follows;

Testing
Open the supplied example at “File->Examples->DHT Sensor Library->DHTtester“. Compile and upload. Once upload data i fed back over the serial link, open “Tools->Serial Monitor”. You should see a screen similar to this one;

Using with an OLED
If you know how to connect up an OLED to your system you can have a more pleasing readout of data, see this guide if you are not sure how to connect up an OLED screen. The code below will output the data to this screen:

That’s it for now, hope this helps you use one of these sensors. If you look at the other sensor guides on this site (Pressure and Temp ) you should now have enough information to make a small weather station. All that’s needed is a small anemometer (wind speed indicator).