You are on page 1of 12

Lab7: DHT11 Temperature and Humidity Sensor with Arduino

LAB 7: DHT11 Temperature and ! !


! Humidity Sensor with Arduino

! Introduction
! ! The DHT11 digital temperature and humidity sensor is a
composite Sensor contains a calibrated digital signal output of the
temperature and humidity. The sensor includes a resistive sense of wet
components and an NTC temperature measurement devices, and connected
with a high-performance 8-bit microcontroller.

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 1 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Serial communication instructions (single-wire bi-directional)


! DHT11 uses a simplified single-bus communication(Figure 7.1) . Single
bus that only one data line, the system of data exchange, control by a single
bus to complete. Device (master or slave) through an open-drain or tri-state
port connected to the data line to allow the device does not send data to
release the bus, while other devices use the bus; single bus usually require
an external one about 5.1k pull-up resistor, so that when the bus is idle, its
status is high. Because they are the master-slave structure, and only when
the host calls the slave, the slave can answer, the host access devices must
strictly follow the single-bus sequence, if the chaotic sequence, the device will
not respond to the host.

- Data format:
! The 8 bit humidity integer data : 8 bit the Humidity fractional data : 8 bit
temperature interger data : 8 bit temperature fractional data : 8 bit parity bit
(8 bit checksum ).

-Over All Data Timing Diagram


! When MCU sends a start signal, DHT11 changes from the low-power-
consumption mode to the running-mode, waiting for MCU completing the start
signal. Once it is completed, DHT11 sends a response signal of 40-bit data
that include the relative humidity and temperature information to MCU. Users
can choose to collect (read) some data. Without the start signal from MCU,
DHT11 will not give the response signal to MCU. Once data is collected,
DHT11 will change to the low- power-consumption mode until it receives a
start signal from MCU again. (Figure 7.2)
Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 2 of 12
Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.2
- MCU read steps
! Communication between the Host (MCU) and slave can be done
through the following steps .

Step 1:
! After power on the DHT11 (DHT11 on after power to wait 1s across the
unstable state during this period can not send any instruction), the I/O pin
pulled by pull-up resistor has been to maintain high. The DHT11 is in the input
state, the moment of detection of external signals from MCU.

Step 2:
! MCU I/O set to output at the same time output low, and low hold time
can not be less than 18ms, then the MCU I/O is set to input state, due to the
pull-up resistor, the DHT11 the I/O pin also will be high, waiting DHT11 to
answer signal. The start signal as shown: (Figure 7.3)

Step 3:
! Once DHT11 detects the Start Signal, it will send out a low voltage level
response signal, which lasts 80us. Then it sets the voltage level from low to
high and keeps it for 80us. The DHT11 response signal as shown: (Figure
7.4)

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 3 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig 7.4 DHT11 response signal Low-> 80us, High-> 80us

Step 4:
! When DHT11 is sending data to MCU, every bit of data begins with the
50us low-voltage-level and the length of the following high-voltage-level
signal determines whether data bit is "0" or "1" (see Figures 7.5 and 7.6
below).

Fig. 7.5 Bit 0 : Low-> 50us, High-> 26-28us

Fig. 7.6 Bit 1 : Low-> 50us, High->70us

! When the last bit data is transmitted, DHT11 pulls down the voltage
level and keeps it for 50us, then it leaves the line pulled-up and goes back in
the stand-by mode.
Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 4 of 12
Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.7 Show DHT11 module connect to Arduino UNO for this LAB .

Procedure I.
! 1. Use Arduino UNO Board and Electronic parts from Arduino lab
box set build a real circuit from a figure 7.7.
! 2. Write a C program follow figure 7.8a-7.8c in Atmel studio. Then
build the hex file for this program and upload to Arduino board that
connected with DHT11 module (figure 7.7).
! 3. Use digital Oscilloscope channel I measure signal on pin DATA of
DHT11 module.Find the start signal and sample of data bit 0 and 1
then save the result and show the result to staff of LAB.(the start signal and
sample data 0 and 1 should be like figure 7.9a-7.9c)
! 4. Use Logics Analyzer save the signal data from pin DATA of DHT11
module(should be like figure 7.10). Find 40 bit data that send from DHT11
and read data in binary number(by your eyes).Show how to checksum and
convert data to decimal number of temperature and relative humidity.

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 5 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.8a) Test source code part I (Part II -Fig. 7.8b cont.)

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 6 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.8b) Test source code part II (Part III -Fig. 7.8c cont.)

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 7 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.8c) Test source code part III (The end)

Fig. 7.9a) Show The Start Signal from MCU

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 8 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.9b) Show Bit 0 -> high = 24us

Fig. 7.9c) Show Bit 1 -> high = 70us

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 9 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino
Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 10 of 12
Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Procedure II.
! 1. Design and Modify the C program source code from procedure I to
the new program that can show 40 bit data , show temperature , and humidity
on LCD display (the result should be like Figure 11a-11c).
! 2. Send the short report, flowchart, and source code of the new
program.Show the result to staff of LAB.

Fig. 7.11a) Show 5 byte data for checksum.

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 11 of 12


Lab7: DHT11 Temperature and Humidity Sensor with Arduino

Fig. 7.11b) show the temperature

Fig. 7.11c) show the humidity

Microprocessor and Embedded Computer Systems! Sem.2 / 2013 ECE page 12 of 12