DHT11/DHT22

Environment - DHT11/12/22 SONOFF2301/7021/MS01 NORMAL CLIMATE

../_images/P005_DHT11_DHT22_1.jpg

Introduction

DHT11 and its sibling DHT22 are temperature and humidity sensors which using a custom 1-wire protocol. That means that they are not compatible with the same 1-wire bus as standard 1-wire units.

Specifications:
  • Temperature (-40C to +85C)

  • Humidity (0-100 % rel. humidity)

Wiring

The DHT sensor needs to be connected to a configurable GPIO on the ESP module. In case you have a simple ESP-01 module, it’s best to use the GPIO-2 pin.

../_images/P005_DHT11_DHT22_2.jpg

DHT11 (blue)

../_images/P005_DHT11_DHT22_3.jpg

DHT22 (white)

ESP               DHT11/DHT22
GPIO (X)   <-->   Data (2nd pin)

Power
5.0V       <-->   VCC (1st pin)
GND        <-->   GND (4th pin)

Note

Do not use GPIO 15 as an input for the DHT11/22. During startup of the ESP8266, this pin must be LOW for proper operation. It is good to avoid using GPIO 0 as an input as well. This pin must be HIGHT at startup, unless program mode is required. The data pin of the DHT11/22 needs a pull-up resistor. A value of 4.7k - 10k proves to be sufficient.

Setup

../_images/P005_Setup_DHT11_DHT22_1.png

Task settings

  • Device: Name of plugin

  • Name: Name of the task (example name DHT)

  • Enable: Should the task be enabled or not

Sensor

  • GPIO <–> Data: Pulse input is generally set to GPIO 14 (D5).

  • Sensor model: Pick your sensor model, either DHT11 or DHT22.

Data acquisition

  • Send to controller 1..3: Check which controller (if any) you want to publish to. All or no controller can be used.

  • Interval: How often should the task publish its value (5..15 seconds is normal).

Rules examples

On DHT#Celsius Do
 If [DHT#Celsius]>-15
   NeoPixelAll,255,0,0 //Red light
 Else
   NeoPixelAll,0,255,0 //Green light
 EndIf
EndOn

How to patch Wemos DHT shield

The Wemos DHT shield uses a pin which is also toggled at boot disrupting the connected DHT22 sensor.

This causes the sensor to become unresponsive after a reboot.

The DHT sensor needs to be connected to a configurable GPIO on the ESP module. In case you have a simple ESP-01 module, it’s best to use the GPIO-2 pin.

See this elaborate post on GitHub describing the problem and how to patch the board to make it work like it should.

Where to buy

Store

Link

AliExpress

Link 1 ($) DHT11 Link 2 ($) DHT22

Banggood

Link 3 ($) DHT11 Link 4 ($) DHT22

eBay

Link 5 ($) DHT11 Link 6 ($) DHT22

$ = affiliate links which will give us some money to keep this project running, thank you for using those.