Skip to content

AM2301/AM2302 (DHT21/DHT22) temperature and humidity sensor~

This feature is included in tasmota, tasmota32, tasmota-knx and tasmota-display binaries

When compiling your build add the following to user_config_override.h:

#ifndef USE_DHT
#define USE_DHT     // Add support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor (1k6 code)
#endif

AM2301 driver supports AM2301 (DHT21), AM2302 (DHT22) and AM2321 temperature and humidity sensors. Introduced in Tasmota through Sonoff AM2301 accessory for Sonoff TH.

This driver is ONLY for single wire implementations of the sensor.

For AM2301B I2C model, refer to AHT2x driver.

Configuration~

Wiring~

AM2301 ESP
- GND
OUT GPIOx
+ 3.3V - 5.2V (5V is recommended)

Tasmota Settings~

In the Configuration -> Configure Module page assign: - GPIOx to AM2301

After a reboot webUI will display temperature and humidity measured.

image

Sensor sends a tele/%topic%/SENSOR JSON response:

{
  "Time": "2019-01-01T00:00:00",
  "AM2301": {
    "Temperature": 24.6,
    "Humidity": 58.2
  },
  "TempUnit": "C"
}

Commands~

TempOffset can be used for calibrating the measured temperature. This setting affects all temperature sensors on the device.

Wemos DHT Shield~

Like the Wemos DHT11 shield specs the DATA OUT pin of Wemos DHT22 is connected to D4 of the Wemos.

image

Tasmota Settings~

In the Configuration -> Configure Module page assign:

  1. GPIO2 to AM2301 (2)

Sensors~

Read more about differences between sensors.

image