Tasmota icon indicating copy to clipboard operation
Tasmota copied to clipboard

Add Support for AHT30 Temperature and Humidity Sensor

Open legchenkov opened this issue 2 years ago • 11 comments

Description:

Implemented sensor detection, initialization, and data reading based on both the AHT20 and the AHT30 datasheet specifications. Configured the sensor polling interval to 10 seconds to prevent sensor heating.

Checklist:

  • [+] The pull request is done against the latest development branch
  • [+] Only relevant files were touched
  • [+] Only one feature/fix was added per PR and the code change compiles without warnings
  • [+] The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • [+] The code change is tested and works with Tasmota core ESP32 V.2.0.14
  • [+] I accept the CLA.

legchenkov avatar Nov 04 '23 11:11 legchenkov

In addition to the datasheet, did you TEST if your changes work? I see you also change AHT1x reset command. Did you test AHT1x functionality?

arendst avatar Nov 04 '23 14:11 arendst

In addition to the datasheet, did you TEST if your changes work? I see you also change AHT1x reset command. Did you test AHT1x functionality?

I tested the code on two ESP32 boards: 1)UICPAL Type-C ESP32-C3 16Pin Development Board Mini 2)WeAct ESP32 Development Board TYPE-C CH340K WiFi+Bluetooth Dual Core ESP32-DOWD-V3 In both cases, it works without any problems. But the reset command is really different from the one in the datasheet. And if it is wrong, it means it has no noticeable effect. Initially, the AHT30 sensor didn't work because of an incorrect initialization command in the code for AHT20. After fixing the initialization command, it worked, but it was getting 3 degrees hotter due to frequent measurements. So I had to reduce their frequency. Now the measurements are accurate. Anyway, I will do some more testing.

legchenkov avatar Nov 04 '23 15:11 legchenkov

The reset command in my code did not match the AHT10/20/30 datasheets. I have corrected it. However, the reset function is not used in the driver, so the error did not affect the driver. Apparently, the initialization function is sufficient for the sensor to work.

legchenkov avatar Nov 05 '23 18:11 legchenkov

This PR also fixes work with AHT20+BMP280 module from aliexpress. The AHT20 part of module does not work with #define AHTX_CMD 0xB1 and works with #define AHTX_CMD 0xBE

Tesla-HV avatar Nov 14 '23 17:11 Tesla-HV

This PR also fixes work with AHT20+BMP280 module from aliexpress. The AHT20 part of module does not work with #define AHTX_CMD 0xB1 and works with #define AHTX_CMD 0xBE

Very good! I'm just waiting for the AHT20+BMP280 to be delivered.

legchenkov avatar Nov 14 '23 19:11 legchenkov

Added Russian translation of untranslated element "Dew point" for AHTxx sensors.

legchenkov avatar Nov 22 '23 18:11 legchenkov

I tested the code to ESP32 boards: Sonoff Extreme mini R4. It works without any problems. Good work

dadaweb77 avatar Nov 25 '23 19:11 dadaweb77

@dadaweb77 how have you connected the sensor to the "Sonoff Extreme mini R4"? Thanks!

Noschvie avatar Nov 27 '23 07:11 Noschvie

@dadaweb77 how have you connected the sensor to the "Sonoff Extreme mini R4"? Thanks!

Simple: R4mini-------AHT30 u2 (+3.3V) ------- Vin (red wire) GND ------- GND (white wire) TX ------- SCL (yellow wire) RX ------- SDA (green wire)

Use this template {"NAME":"Sonoff MINIR4","GPIO":[32,608,0,640,0,0,0,0,0,0,0,0,0,0,0,576,0,0,0,0,0,0,224,160,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

P_20231127_091330

dadaweb77 avatar Nov 27 '23 08:11 dadaweb77

The code changes need to be tested with an AHT25 too. Furthermore all language translation files has to be included in the PR (providing all not known languages in English) Maybe it is possible to send all the different CMD sequences to the AHTs? So no need for an compile time setting for the different types?

Jason2866 avatar Dec 03 '23 12:12 Jason2866

This PR has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 27 '24 01:01 github-actions[bot]

Ok to merge as-is, but I would largely prefer a future version that unifies ATH10/20/30 into a single code base, and dynamic selection

To make a universal driver that will work for all versions of this sensor seems realistic to me. But it will be possible to distinguish only AHT10, because it has a different code for sending a command. The other versions of AHT I do not know how to distinguish from each other programmatically. Anyway, I'll give it a try.

legchenkov avatar Mar 03 '24 23:03 legchenkov

Will this feature be merged and available? I would like to use the AHT30 as well. :)

tobiloeb avatar Mar 16 '24 08:03 tobiloeb

is there a test bin somewhere? i can't seem to find a workflow creation from PR

divadiow avatar Mar 18 '24 21:03 divadiow

This PR has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 12 '24 22:04 github-actions[bot]