AHT20 Element
The AHT20Element allows retrieving temperature and humidity values from the AHT20 sensors from aosong.
This temperature and humidity sensor from aosong is using the i2c bus for communication and offers a 12 bit resolution for values.
parameter | range |
---|---|
Supply voltage | DC : 2.2 - 5.5V |
Measuring range (humidity) | 0 ~ 100 % RH |
Measuring range (temperature) | -40 ~ + 85 °C |
Humidity accuracy | ± 2 % RH ( 25 °C ) |
Temperature accuracy | ± 0.3 °C |
Resolution | temperature: 0.01 °C Humidity: 0.024 % RH |
Response time | temperature: 5s humidity: 8s 1/e (63%) |
Interface | I2C signal |
i2c address | 0x38 |
This chip is used inside some packaged sensors like the DHT20 and AM2301B.
Web UI for the AHT20 Element
There is a dedicated card for this element available to show the actual temperature and humidity.
Using the AHT20 Element
The AHT20 Element is not part of the core set of elements. is is not requiring any library as dependency.
The HOMEDING_INCLUDE_AHT20
must be defined in the main sketch to compile and register the element.
// Use some more Elements that need additional libraries
#define HOMEDING_INCLUDE_AHT20
#include <HomeDing.h>
Connecting a AHT20 Sensor
The sensor is using the I2C bus for communication and is usually placed on a adapter board giving access to the required pins.
Using the default I2C bus pins:
Signal | ESP8266 | ESP32 | Sensor | Description |
---|---|---|---|---|
GND | GND | GND | GND | Ground for I2C and Power Supply |
VCC | 3.3v | 3.3v | VCC/VDD | Power Supply |
SDA | GPIO4(D2) | IO21 | SDA | I2C Data Signal |
SCL | GPIO5(D1) | IO22 | SCL | I2C Clock Signal |
The required power for the sensor is low and the 3.3V from most CPU boards can be used.
The common i2c bus is configured in the device element. For more details on using the i2c bus and specifying pins see I2C bus.
Element Configuration
The following properties are available for configuration of the element:
onTemperature – These actions are emitted by the element when the temperature gets a new value. The action will not be sent when reading the sensor values that > stay the same.
onHumidity – These actions are emitted by the element when the humidity gets a new value. The action will not be sent when reading ne sensor values that stay > the same.
powerinvert – This property controls the physical level of the powerpin. When set to true the sensor is enabled by creating a physical LOW level.
From the base Sensor Element implementation the following properties are available for configuration:
readTime – Time between 2 probes being fetched from the sensor. Default value is 1m.
resendTime – The current values of the probe are resent after this specified time even when not changing.
warmupTime – This time is waited after powering the sensor on the first start or after a reset before the first data is fetched. The default time is set to 3 seconds.
restart – This property can be set to true to enable an automated restart when the sensor was not responding data.
From the base element implementation the following properties are available for configuration:
title – Caption text for the element. Used by the element specific cards on the dash boards.
description – A line of text that gives a short description of the device used in the web UI.
room – The location of the device.
loglevel – This property holds the element specific log level. The default value is LOGGER_LEVEL_ERR == 1.
startup – This property can be used to start the element using a different initialization phase. Possible values are “sys”, “net”, “time”. See The Startup sequence.
Configuration Example
This example shows how to configure this element:
{
"aht20": {
"th": {
"title": "AHT20",
"description": "Temperature and Humidity sensor",
"readtime": "30s",
"onTemperature": "device/0?log=temp: $v\u00dfC",
"onHumidity": "device/0?log=hum: $v%"
}
}
}
Element State
The following properties are available with the current values at runtime
active – Is set to true when the element is active.
temperature – The last read temperature value from the sensor.
humidity – The last read humidity value from the sensor.
Example State
{
"aht20/th": {
"active":"true",
"temperature":"27.41",
"humidity":"38.10"
}
}
See Also
- http://www.aosong.com/en/products-32.html
- https://www.adafruit.com/product/5183
- https://learn.adafruit.com/modern-replacements-for-dht11-dht22-sensors
- https://kandrsmith.org/RJS/Misc/Hygrometers/calib_many.html