Lesson 14 DHT11 Temperature and Humidity Sensor
Lesson 14 DHT11 Temperature and Humidity Sensor
Humidity Sensor
Introduction
In this lesson,you will learn how to use a DHT11 Temperature and Humidity
Sensor.
Hardware Required
1 * RexQualis UNO R3
Principle
Small size & low consumption & long transmission distance(100m) enable DH
T11 to be suited in all kinds of
harsh application occasions. Single-row packaged with four pins, making the c
onnection very convenient.
Resolution(RH): 1%RH
Net weight: 1g
Code interpretation
byte i = 0;
byte result=0;
delayMicroseconds(30);
result |=(1<<(7-i));
return result;
void setup()
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
Serial.begin(19200);
Serial.println("Ready");
void loop()
{
byte dht11_dat[5];
byte dht11_in;
byte i;
// start condition
delay(18);
PORTC |= _BV(DHT11_PIN);
delayMicroseconds(40);
delayMicroseconds(40);
if(dht11_in){
return;
delayMicroseconds(80);
if(!dht11_in){
delayMicroseconds(80);
dht11_dat[i] = read_dht11_dat();
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
byte dht11_check_sum =
dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
// check check_sum
if(dht11_dat[4]!= dht11_check_sum)
Serial.print(dht11_dat[0], DEC);
Serial.print(".");
Serial.print(dht11_dat[1], DEC);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(dht11_dat[2], DEC);
Serial.print(".");
Serial.print(dht11_dat[3], DEC);
Serial.println("C ");
delay(2000);
Experimental Procedures
Schematic Diagram
Step 2: Open the code:
DHT11_Temperature_and_Humidity_Sensor_Code
Step 3: Attach Arduino UNO R3 board to your computer via
USB cable and check that the 'Board Type' and 'Serial Port' are
set correctly.