Get Started With the DHT11 Humidity and Temperature Sensor
Read the temperature and humidity with DHT11 and Arduino
Written By: Cherie Tan
![](https://files.littlebird.com.au/guides/57_poster.png)
![Dash icon](https://fast.littlebird.com.au/static/guides/dash.webp)
Difficulty
Easy
![Steps icon](https://fast.littlebird.com.au/static/guides/steps.webp)
Steps
8
Sometimes, you will want to be able to read both the temperature and humidity in your surroundings.
Doing so will enable you to progress onto working on further projects such as a greenhouse control device or a DIY weather station.
![](https://files.littlebird.com.au/guides/516_img1.png)
Bridge DHT11 Pin 1 and Pin 2 with a 10K Resistor.
This resistor will pull up the signal line.
#include <SimpleDHT.h> // for DHT11, // VCC: 5V or 3V // GND: GND // DATA: 2 int pinDHT11 = 2; SimpleDHT11 dht11; void setup() { Serial.begin(9600); } void loop() { // start working... Serial.println("================================="); Serial.println("Sample DHT11..."); // read without samples. byte temperature = 0; byte humidity = 0; int err = SimpleDHTErrSuccess; if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000); return; } Serial.print("Sample OK: "); Serial.print((int)temperature); Serial.print(" *C, "); Serial.print((int)humidity); Serial.println(" H"); // DHT11 sampling rate is 1HZ. delay(1500); }
Upload this code to your Arduino