This is an Arduino library for Aosong ASAIR AHT1x, AHT2x Digital Humidity & Temperature Sensor

Overview

license-badge version stars hit-count github-issues

Aosong ASAIR AHT1x/AHT2x

This is an Arduino library for Aosong ASAIR AHT10/AHT15/AHT20/AHT21/AHT25/AM2301B/AM2311B Digital Humidity & Temperature Sensor

  • AHT1x +1.8v..+3.6v, AHT2x +2.2v..+5.5v
  • AHT1x 0.25uA..320uA, AHT2x 0.25uA..980uA
  • temperature range -40C..+85C
  • humidity range 0%..100%
  • typical accuracy T +-0.3C, RH +-2% (1)
  • typical resolution T 0.01C, RH 0.024%
  • normal operating range T -20C..+60C, RH 10%..80%
  • maximum operating rage T -40C..+80C, RH 0%..100%
  • I2C bus speed 100KHz..400KHz, 10KHz recommended minimum
  • recommended measurement frequency 8sec..30sec (2)
  • recommended to route VDD or GND between I2C lines to reduce crosstalk between SCL & SDA
  • power supply pins must be decoupled with 100nF capacitor

Supports all sensors features:

  • read humidity (3)
  • read temperature (3)
  • soft reset with sensor initialization
  • CRC calculation for AHT2x (3)

Tested on:

  • Arduino AVR
  • Arduino ESP8266
  • Arduino ESP32
  • Arduino STM32

(1) Prolonged exposure for 60 hours at humidity > 80% can lead to a temporary drift of the signal +3%. Sensor slowly returns to the calibrated state at normal operating conditions.
(2) Measurement with high frequency leads to heating of the sensor, must be > 2 seconds apart to keep self-heating below 0.10C.
(3) Library returns 255 if a communication error occurs, calibration coefficient is off or CRC doesn't match (for AHT2x only).

Comments
  •  M5StickCPlus sensors conflicts with last AHTxx version. All reads are blocked

    M5StickCPlus sensors conflicts with last AHTxx version. All reads are blocked

    Summary

    I'm using this library in my project with a wrapper that I wrote, CanAirIO Sensors Library. With the old version, AHT10 library and using other sensors at the same time, it was working fine in this device. With the new version, AHTxx library, it blocks the other sensors reads. In this wrapper we have charged multiple sensors libraries and we try to auto-recognize all because we have different devices and sensor configurations. In the previous version, when I had AHT10 initialization without any AHT sensor connected, it was working fine and don't block the other sensors.

    More details please review here

    opened by hpsaturn 5
  • AHTxx.cpp:101:8: error: 'class TwoWire' has no member named 'setClockStretchLimit'

    AHTxx.cpp:101:8: error: 'class TwoWire' has no member named 'setClockStretchLimit'

    I get this:

    /Users/.../Documents/Arduino/libraries/AHTxx/src/AHTxx.cpp:101:8: error: 'class TwoWire' has no member named 'setClockStretchLimit'
       Wire.setClockStretchLimit(stretch); //experimental! default 150000usec
            ^~~~~~~~~~~~~~~~~~~~
    

    so I commented out the line and now it works.

    My Arduino installation is brand new, with latest libraries, on a new Mac. I used to use AHT10, but this pointed me to this library, so I haven't used it before. Running on a ESP32.

    opened by gotfredsen 5
  • [AHT10@esp32 in PlatformIO] Error: Bus is in Slave Mode

    [AHT10@esp32 in PlatformIO] Error: Bus is in Slave Mode

    Default example not working. I confirmed that the sensor works on esp8266 and esp32 with older version. enjoyneering/AHT10

    [    16][E][Wire.cpp:283] setClock(): Bus is in Slave Mode
    [   116][E][Wire.cpp:308] beginTransmission(): Bus is in Slave Mode
    [   116][E][Wire.cpp:331] endTransmission(): Bus is in Slave Mode
    AHT1x not connected or fail to load calibration coefficient
    

    Behavior when no sensor on the I2C bus is connected, after power on. Messages do not appear if I disconnect the sensor and reset the DevBoard. (Without disconnecting the USB power)

    Reconnecting to COM3 ...         Connected!
    ets Jun  8 2016 00:22:57
    
    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:2
    load:0x3fff0030,len:1184
    load:0x40078000,len:12784
    load:0x40080400,len:3032
    entry 0x400805e4
    
    [    16][E][esp32-hal-i2c-slave.c:577] i2c_slave_check_line_state(): Bus Invalid State, Can't init sda=0, scl=0
    [    16][E][esp32-hal-i2c-slave.c:309] i2cSlaveInit(): bad pin state
    [    21][E][Wire.cpp:167] begin(): Slave Init ERROR
    [    25][E][esp32-hal-i2c.c:254] i2cSetClock(): could not acquire lock
    [   132][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
    AHT1x not connected or fail to load calibration coefficient
    

    pio run

    PLATFORM: Espressif 32 (5.0.0) > Espressif ESP32 Dev Module
    HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
    DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
    PACKAGES: 
     - framework-arduinoespressif32 @ 3.20003.220626 (2.0.3) 
     - tool-esptoolpy @ 1.30300.0 (3.3.0) 
     - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
    
    Dependency Graph
    |-- AHTxx @ 1.1.5+sha.d3de55e
    |   |-- Wire @ 2.0.0
    |-- Wire @ 2.0.0
    Building in release mode
    
    opened by bato3 4
  • No response at all by using the given example

    No response at all by using the given example

    I am using a WeMos D1 Mini with a AHT10. The connections are from the AHT10 to WeMos:

    SDA -> D2 (GPIO4) SCL -> D1 (GPIO5) VIN -> 3V3 GND -> G

    Adress pin is 0x38.

    After flashing with your example I get the error checking for the wiring, but it seems correct to me.

    opened by herzphi 3
  • [PlatformIO registry] I can't find the library using PlatformIO registry search

    [PlatformIO registry] I can't find the library using PlatformIO registry search

    Summary

    Hi, maybe the library was not published yet? because I don't found it via pio search tools (web and via CLI)

    For example:

    pio pkg search AHT
    Found 1 packages (page 1 of 1)
    
    adafruit/Adafruit AHTX0
    Library • 2.0.3 • Published on Thu Sep 15 18:14:46 2022
    
    opened by hpsaturn 2
  • ESP01s not working with library

    ESP01s not working with library

    With the Wemos D1 mini, the library works wonderfully and without errors. However, when I try to run the example code from the AHT2x on an ESP01s, I always get the same error: "AHT2x not connected or fail to load calibration ... ".

    How can I get the code to run?

    opened by Avpi18 2
  • AHTXX_START_MEASUREMENT_CTRL

    AHTXX_START_MEASUREMENT_CTRL

    Hi, for me (in the default configuration) readTemperature() and readHumidity() takes ~ 80ms each.

    I experimented a little bit with the AHTXX_START_MEASUREMENT_CTRL value. 0xFF seems to really speed up measurement. How have you found the 0x33 value? It seems kind of undocumented... Have you also tried to use other values here? 0xFF seems to work pretty well.

    best regards

    opened by markusschweitzer 1
  • ESP32+AHT10+BMP280+DS3231

    ESP32+AHT10+BMP280+DS3231

    Добрый день. В системе установлено ESP32, AHT10, BMP280 и DS3231. Контакты питания развязаны конденсатором 100nF и 1000mF. Дорожки на плате минимальные, не более 2 см. Питание 3,3V через стабилизатор напряжения.
    Все датчики и часы поочередно опрашиваются каждые 3 секунды. Система может работать день, но потом не отвечает AHT10. BMP280 и DS3231 возвращают данные, но не каждый период. Через раз RTC отвечают 00:00:00, но все же есть периоды, когда отвечает верным временем. BMP280 возвращает верные данные. AHT10 вообще не возвращает значения. aht10.softReset() не помогает. Также ESP.restart(); также не помогает. Но если нажать кнопку RST на отладочной плате ESP32, система начинает работать. Или отключить / включить питание. I²C bus speed устанавливалось 10 KHz, 20 KHz, 100KHz, 400KHz. Это не помогает. Зависание также наблюдается если часто нажимать кнопку RST на отладочной плате ESP32 много раз. В какой-то период AHT10 перестает работать. Есть предположение, что AHT10 не успевает отдать все данные и ждет от Master SCL сигнала для продолжения передачи. Поэтому датчик не отвечает. Но это не точно. Что можно сделать в такой ситуации? Возможно перезагрузить линии I²C? Или как-то дочитать данные с AHT10?

    opened by DVB-Arduino 1
  • Использование сенсора AHT10 одновременно с дисплеем Nokia5110 на шине I2C

    Использование сенсора AHT10 одновременно с дисплеем Nokia5110 на шине I2C

    Шина I2C(SDA, SDL) позволяет подключать несколько датчиков. Но позволяет она подключать дисплей нокия 5110? Как то эта библиотека позволяет решить проблему. Получаю при подключении дисплея на шину I2C значения 255.

    opened by brightproject 1
Owner
enjoyneering
enjoyneering
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9/2.13/1.54 inch e-Paper Module

How to join: If device in FN(factory new) state: Press and hold button (1) for 2-3 seconds, until device start flashing led Wait, in case of successfu

Sergey Koptyakov 33 Dec 9, 2022
Sensirion Mass Flow Sensor Arduino library, modified from MyElectrons and Nabilphysics Arduino repositories for SFM3300 Digital Mass Flow Sensor

Sensirion Mass Flow Sensor Arduino library, modified from MyElectrons and Nabilphysics Arduino repositories for SFM3300 Digital Mass Flow Sensor. When the sensor data gets stuck, the library has a hard reset function to ensure that it is read continuously.

Paul Ryan Santiago 3 Apr 11, 2022
Updated Vindriktning with Wifi Connectivity, Motion sensor, Temperature and Humidity

Vindriktning-plus Updated Vindriktning with Wifi Connectivity, Motion sensor, Temperature and Humidity Inspired & parts of the code are used from: htt

Glittering Dealer 4 Sep 20, 2022
My new zigbee project. Wireless temperature and humidity mini sensor with electronic ink display 2.13 inches, low power consumption, compact size, enclosure with magnets.

My new zigbee project. Wireless temperature and humidity mini sensor with electronic ink display 2.13 inches, low power consumption, compact size, enclosure with magnets. The device use SHTC3 sensors, chip CC2530, battery CR2477.

Andrew Lamchenko 20 Nov 20, 2022
Arduino library for the SHT2x series temperature and humidity sensors including SHT20, 21, 25.

SHT2x Arduino library for the SHT2x and HTU2x temperature and humidity sensors. Description The SHT2x family of sensors should work up to 400 KHz I2C.

Rob Tillaart 10 Dec 7, 2022
Custom Arduino-based temperature and humidity data logger.

Arduino Datalogger A custom data logger based on ATmega32u4 with a custom PCB. The device features the following main components: Atmel ATmega32u4 MCU

Valentin Bersier 7 Jul 19, 2021
Baseline Arduino shield for temperature, humidity, soil moisture and ambient light

Introduction Green-Shield is an Arduino R3 shield for temperature, humidity, soil moisture and ambient light optimized for use in greenhouses where th

#Eduh 3 Dec 29, 2021
LM75A temperature sensor library that you can use with STM32F10x series microcontrollers.

STM32F10x-LM75A-Library LM75A temperature sensor library that you can use with STM32F10x series microcontrollers. Launching the LM75A sensor in your a

null 12 Nov 25, 2022
Driver for the TI TMP102 I2C temperature sensor. For use with TI TM4C123X MCUs.

TI TMP102 Driver Simple driver for the TI TMP102 I2C temperature sensor. For use with TI TM4C123X MCUs and TI's TivaWare™ Peripheral Driver Library. D

Dan Maher 4 Jun 27, 2021
This is for interfacing rasberry-pi's (2 cards) with an arduino for sending raw data to form the close loop system to avoid motor heating by acting on a given temperature.

This is for interfacing rasberry-pi's (2 cards) with an arduino for sending raw data to form the close loop system to avoid motor heating by acting on a given temperature. Interface is explained through a master slave approach and client server approach. another camera is used with OPEN-CV platform to interface and collect data aswell.

Younes HAMZA 2 Oct 25, 2021
Voltage Controlled Digital Core Multimode Oscillator using Mozzi library on Arduino

Arduino-VDCO Voltage Controlled Digital Core Multimode Oscillator using Mozzi library on Arduino Its a digital Oscillator/Voice for the Eurorack Stand

null 47 Dec 12, 2022
multispectral monitoring of a sourdough starter; esp32 eink module, scd30 co2 sensor, vl6180 distance sensor

EINK STARTER MONITOR See full blogpost here Tracks height of starter with a VL6180 i2c distance sensor, and CO2/temperature/humidity with an SCD30. A

AKA 15 Feb 16, 2022
Tasmota-Berry Tank Sensor for fuel-oil usind VL53L1X or SR04 sensor

Tasmota-Tank-Sensor Tasmota-Berry Tank Sensor for fuel-oil volume measurement using an VL53L1X or SR04 sensor The Sensor body The sensor was prepared

Tom Lafleur 3 Oct 9, 2022
Arduino library for ST Microelectronics VL53L5 multizone Time-of-Flight ranging sensor

VL53L5 Arduino library for ST Microelectronics VL53L5 multizone Time-of-Flight ranging camera (get it here!) Quickstart Connect I2C in the usual way (

Simon D. Levy 24 Dec 14, 2022
Arduino based bicycle movement sensor and GPS tracker

Bike Tracker Background There are actually plenty of bicycle trackers around, so why make your own? Well, so that it works the way you want it… And it

null 22 Aug 21, 2022
Harsh Badwaik 1 Dec 19, 2021
Fingerprint doorlock Arduino project make from Fingerprint sensor and Solenoid door lock

Fingerprint-doorlock Fingerprint doorlock Arduino project make from Fingerprint sensor and Solenoid door lock Main Idea Create Doorlock that uses Fing

Narongkorn 1 Dec 15, 2021
Collection of Arduino sketches for TDK's combo accel/gyro motion sensor

ICM42688 Collection of Arduino sketches for TDK's combo accel/gyro motion sensor The basic sketch configures the sensors' data rates and full scale se

Kris Winer 12 Dec 13, 2022
Projecte de tecnologia de 2n bat amb Arduino per a l'obertura de la porta del laboratori Edison amb un sensor d'empremtes dactilars.

projecte-fingerprint Projecte de tecnologia de 2n bat amb Arduino per a l'obertura de la porta del laboratori Edison amb un sensor d'empremtes dactila

Amadeu Moya 2 May 10, 2022