Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for AHT30 Temperature and Humidity Sensor #19922

Merged
merged 9 commits into from
Apr 28, 2024

Conversation

legchenkov
Copy link
Contributor

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.

Support for AHT30 added. Fixed command for loading factory calibrated data and reset command, added needed delay after read command and increased measurement period to reduce heating of sensor.
@arendst
Copy link
Owner

arendst commented Nov 4, 2023

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 arendst added the on hold by dev team Result - Feature request put on hold by member of development team label Nov 4, 2023
@legchenkov
Copy link
Contributor Author

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.

The reset command is aligned with the AHT10/20/30 datasheet.
@legchenkov
Copy link
Contributor Author

legchenkov commented Nov 5, 2023

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.

@Tesla-HV
Copy link

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

@legchenkov
Copy link
Contributor Author

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.

Translated Dew Point to russian Точка росы for sensors
@legchenkov
Copy link
Contributor Author

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

@dadaweb77
Copy link

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

@Noschvie
Copy link
Contributor

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

@dadaweb77
Copy link

dadaweb77 commented Nov 27, 2023

@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

@Jason2866
Copy link
Collaborator

Jason2866 commented Dec 3, 2023

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?

Copy link
Collaborator

@s-hadinger s-hadinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. Can you please check the questions?

tasmota/tasmota_xsns_sensor/xsns_63_aht1x.ino Show resolved Hide resolved
tasmota/language/ru_RU.h Outdated Show resolved Hide resolved
tasmota/tasmota_xsns_sensor/xsns_63_aht1x.ino Show resolved Hide resolved
Copy link

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 github-actions bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Jan 27, 2024
@Jason2866 Jason2866 removed the stale Action - Issue left behind - Used by the BOT to call for attention label Jan 30, 2024
@legchenkov legchenkov requested a review from s-hadinger February 5, 2024 19:23
Copy link
Collaborator

@s-hadinger s-hadinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@legchenkov
Copy link
Contributor Author

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.

@tobiloeb
Copy link

tobiloeb commented Mar 16, 2024

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

@divadiow
Copy link

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

Copy link

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 github-actions bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Apr 12, 2024
@Jason2866 Jason2866 removed the stale Action - Issue left behind - Used by the BOT to call for attention label Apr 13, 2024
@Jason2866 Jason2866 merged commit ecf7d44 into arendst:development Apr 28, 2024
hawa-lc4 pushed a commit to hawa-lc4/Tasmota-dev that referenced this pull request May 7, 2024
* Update xsns_63_aht1x.ino

Support for AHT30 added. Fixed command for loading factory calibrated data and reset command, added needed delay after read command and increased measurement period to reduce heating of sensor.

* Update xsns_63_aht1x.ino

* Update xsns_63_aht1x.ino

The reset command is aligned with the AHT10/20/30 datasheet.

* Update ru_RU.h

Translated Dew Point to russian Точка росы for sensors

* Delete tasmota/language/ru_RU.h

Will go to separate PR

* Add files via upload

* Update ru_RU.h

Partial translation update

* Add files via upload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold by dev team Result - Feature request put on hold by member of development team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants