2021-11-05 02:00:01 +00:00
|
|
|
= DHT11 =
|
|
|
|
|
|
|
|
The DHT11 is a very cheap humidity/temp sensor, made by ASAIR.
|
|
|
|
|
|
|
|
== Pinout ==
|
|
|
|
|
|
|
|
Then the module is facing you,
|
|
|
|
|
|
|
|
For three pins the pinout is
|
|
|
|
|
|
|
|
| GND | VCC | DAT |
|
|
|
|
|
|
|
|
This is because on the breakout boards, a 10K pullup resistor is on Pin 2 of
|
|
|
|
the sensor module.
|
|
|
|
|
|
|
|
== Data ==
|
|
|
|
|
|
|
|
Data is sent using a single bus line. This bus line sends info in the following
|
|
|
|
manner.
|
|
|
|
|
|
|
|
| Humidity int (8b) | Humidity decimal (8b) | Temp int (8b) | Temp decimal (8b) | Parity |
|
2021-11-05 02:15:01 +00:00
|
|
|
|
|
|
|
Parity is calculated by adding all of the four proceeding values together.
|
|
|
|
Whatever the result is should match the Parity. The values sent back should be
|
|
|
|
read as Big Endian; the most signifigant bit comes first for each 8bit block of
|
|
|
|
data.
|
|
|
|
|
|
|
|
== Steps to read Data ==
|
|
|
|
|
|
|
|
1) After the DHT11 has been turned on, in must stay on for at least 1S in order
|
|
|
|
for it to calibrate itself properly. Do not probe it earlier than this.
|
|
|
|
2) The data line must be held low for *no less than 18ms*. After this time, the
|
|
|
|
pin on the MCU must switch to being in an input state.
|
|
|
|
3) The DHT11 will respond with 80us of VCC, followed by 80us of GND. This is
|
|
|
|
used as a way of calibrating the format in which the device will reply with
|
|
|
|
data.
|
|
|
|
4) After this exactly 40bits of data will be sent back. The format for each
|
|
|
|
type of response is as shown.
|
|
|
|
- A one (1) consists of 50us of GND, followed by 26-28us of VCC
|
|
|
|
- A zero (0) consists of 50us of GND, followed by 70us of VCC.
|