
Temp and hum sensor: DHT11
Read temperature and humidity
What are we going to do?
In this activity you'll read the ambient temperature and humidity with a DHT11 sensor brick. In order to use the sensor, you'll need a library. Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. Don't worry, I'll show you how they work. You'll also learn how the serial monitor works.
UNO board
You can use any Arduino UNO original or compatible board
USB cable
Depending on your board, you'll need a microUSB cable or a miniUSB cable
Computer
You need a computer with Arduino IDE software. If you don't have it, follow this link with instructions to download and install it.
DHT11 sensor brick
A DHT11 temperature and humidity sensor with SVG connections
Let's get started
Follow these instructions carefully. You can click on some of the images to zoom in.
Always connect the components BEFORE powering the UNO board or YOU MAY DAMAGE YOUR BOARD OR COMPONENTS.
Instructions
2. Open Arduino IDE
Once you've opened the editor, download and open the sample code from HERE
4. Change code
If you succesfully downloaded and opened the code from previous step, you only need to add the correct library.- Go to Sketch -> Include library -> manage libraries
- Then, write dht11 on the search box
- Finally, install DHT sensor library VERSION 1.2.3Â (other versions are not working with this example) by Adafruit by clicking on the install button
5. Upload to the board
Use the upload button to transfer the program to your board. Once done, you should read Upload completed. That means the transfer was succesful. If it's not succesful, try disconnecting your board and connecting it again and repeating the upload process.
6. Final result
After uploading, everything should be working as planned, but, in order to be able to see the temperature and humidity, you'll need to click on the Serial monitor button at the right top of the Arduino IDE. Once opened, make sure 9600 is selected at the right bottom of the serial monitor window.
Congratulations, you've done it! You're on the right path to be a maker! 🙂
Now, what else?
Now is your turn:
- Change the code to personalize the format of the temperature and humidity readings. Remember the difference between Serial.print and Serial.println
- Now, I propose a challenge, do you think you can change the code to show the temperature in Fahrenheit instead of Celsius?
Pingback: Encoder and servo – makit
Pingback: Seven segment display – makit
Pingback: Inputs and outputs: button – makit