enjoyneering / ahtxx Goto Github PK
View Code? Open in Web Editor NEWThis is an Arduino library for Aosong ASAIR AHT1x, AHT2x Digital Humidity & Temperature Sensor
This is an Arduino library for Aosong ASAIR AHT1x, AHT2x Digital Humidity & Temperature Sensor
Hi, The library does not work for me on ESP32 or ESP32C3, on serial I get "AHT1x not connected or fail to load calibration coefficient". On ESP32 the sensor is connected to the default I2C pins 21,22 and no difference if aht10(21,22) is used either.
The same hardware works well on ESP32 with Adafruit library (but not on ESP32C3).
In my project i conect two AHT10 at diferent address (0x38 & 0x39)
How i can define, initialize and obtain temp and humidity of each sensor?
Y run the i2c scanner and can see the two sensor, but I no undersatnd how to use the library.
you can helpme?
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
Шина I2C(SDA, SDL) позволяет подключать несколько датчиков.
Но позволяет она подключать дисплей нокия 5110?
Как то эта библиотека позволяет решить проблему.
Получаю при подключении дисплея на шину I2C значения 255.
hello, and thanks for the library.
It works smoothly with an arduino nano + aht10 board alone, but if i try to get it work in the context of a mysensors node, the i2c fails systematically to establish communication.
I tried to dive into the library and figured out that the _address
is messed up (i guess by mysensors).
Actually if i replace in ahtxx.cpp
all _address
by 0x38
it works.
I'm a web developer and linux addict but completely newbe in c++, could you please help me to solve this ?
Thanks
In description of begin(), the return value is said to be "- returned value by Wire.endTransmission(): ", mentioning 5 different return values.
That is not the case. It returns bool true/false.
I've built a few temperature probes that are an ESP8266 with an AHT2x attached. The outdoor AHT20 works fine, indoors I have an AHT20 ('Elderhof') and an AHT25 ('Office') which have weird random bumps. A bump-up in temperature has a corresponding bump-down in the humidity reading.
Readings are taken every 30 seconds and fed into HA over MQTT. I looked at the bump-up of the Office sensor around midnight Oct 10 in detail: It rises over 5 minutes - i.e. it is not instantaneous. It starts to rise at 10:14pm and reaches 2 degrees higher by 10:19pm and the bump ends at 00:43 taking 3 minutes to drop the 2 degrees. There are no heaters or fans going off in that time that could affect the temperature.
Software-wise they're all driven by the same code-base using the arduino architecture.
Any ideas what could be causing this weird behaviour?
Sorry to turn this into a github issue. Would like to know your opinion as you're most likely an expert with AHT2x devices.
#https://www.reddit.com/r/homeassistant/comments/174ktva/weird_bug_observed_using_aht2x_temperature_sensors/
The platformIO plugin for VSCode can only find AHT10, but not this new library. Or can I import this lib to platformio?
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
Добрый день.
В системе установлено 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?
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
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.
This isn't a fault as your library is already wonderful, however, I was wondering if there was a reason for multiple Wire
reads to grab the raw data, as in:
/* read n-bytes from "wire.h" rxBuffer */
for (uint8_t i = 0; i < dataSize; i++)
{
_rawData[i] = Wire.read();
}
Tested only on the esp8266, the following appears to do the same without issue
Wire.readBytes(_rawData, dataSize);
Sorry if I have wasted your time, but thought this may be useful to eliminate 6-7 reads. .
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.
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?
There is no mention to this command in the AHT10 datasheet. In the AHT20 datasheet, it is not listed in the commands, there is only the note "you can get a byte of status word by sending 0x71". 0x71 happens to be the address of the sensor plus the read bit.
My take on this is that there is no need to send a command to get the status (and the readings), you just do an I2C read transaction. I tried this with an AHT10 and it worked. I do not have the other models, so cannot guarantee it will work for them.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.