This blog is about how to collect the Temperature and Humidity reading from a sensor called DHT-11 sensor, using an Arduino Uno.
In this, I will configure the Arduino Uno to subscribe to the temperature and humidity sensor ( or also called as DHT-11 ) thru it’s data pin ( also called as the signal pin) and collect the information and post it on the Serial Monitor of the Arduino IDE.
Level : Basic
Parts Required :
Arduino Uno connected to the laptop.
DHT-11 Temperature and Humidity Sensor.
Arduino IDE installed on your laptop/desktop.
Jumper wires and knowledge of the pin layout of the DHT-11.
This set up should not take more than a few minutes.
First, lets start with connections on the Arduino on the breadboard.
Connect the Vcc of the DHT-11 to the +5V of the Arduino.
Ground of DHT-11 to Ground of the Arduino
Data Pin Or Signal pin to the Pin 7 of the Arduino.
Next, Download the DHT 11 library from http://playground.arduino.cc/Main/DHTLib
On the Arduino IDE, Include the DHT-11 library, Sketch -> Include Library -> Add .zip library and select the DHT11.zip .
Add the code as shown:
#define DHT11_PIN 7
int chk = DHT.read11(DHT11_PIN);
sprintf ( buffer, "Temperature = %d, Humidity = %d", (int) DHT.temperature, (int) DHT.humidity );
Serial.println ( buffer );
// --OR-- ( if you want to print the temperature and Humidity in separate lines)
//Serial.print("Temperature = " DHT.temperature);
//Serial.print("Humidity = ");
Compile and Upload the code and bring up the Serial Monitor to start data readings.
Other settings on the Uno are as shown below in the snapshots.