AHT10 humidity sensor over Software I2C

What are you developing?
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

AHT10 humidity sensor over Software I2C

Post by blue-man »

The AHT10 humidity sensor has the problem that only one device of it can be connected with an I2C bus.
This is remarked in the datasheet. When you want to connect other I2C devices you must use an AHT20!

When you don't want to block an I2C bus for an AHT10 you can use a software I2C.

The Software-I2C is based on https://github.com/felias-fogg/SlowSoftI2CMaster
The used AHT-10 library is based on https://github.com/enjoyneering/AHT10

With this solution you can read an AHT10 with every two free port pins.
Attachments
AHTxx.zip
AHT10 driver for Software I2C
(7.54 KiB) Downloaded 430 times
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: AHT10 humidity sensor over Software I2C

Post by mrburnette »

Or, one could throw hardware at the problem:

https://learn.adafruit.com/adafruit-tca ... r-breakout
In theory, you could have 8 of these multiplexers on each of 0x70-0x77 addresses in order to control 64 of the same-I2C-addressed-part.
The software-only solution is less costly, but the hardware allows use of the internal microcontroller I2C hardware and "may" be more compatible with existing software (pre-written) code.
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: AHT10 humidity sensor over Software I2C

Post by blue-man »

mrburnette wrote: Fri Oct 22, 2021 11:24 pm The software-only solution is less costly, but the hardware allows use of the internal microcontroller I2C hardware and "may" be more compatible with existing software (pre-written) code.
It's less costly and more compatible to use an AHT20, if you want to use more then a humidity sensor.

The multiplexer is fine when you want to use a couple of the same sensors.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: AHT10 humidity sensor over Software I2C

Post by mrburnette »

blue-man wrote: Sun Oct 24, 2021 9:05 am ...
It's less costly and more compatible to use an AHT20, if you want to use more then a humidity sensor.
...
The term "more compatible" is far too broad to be used here without context and acknowledgment of limitations and caveats.
It is, a hack but a well executed one.

Nicely documented source code.
AndrewBCN
Posts: 105
Joined: Sun Apr 25, 2021 3:50 pm
Answers: 1
Location: Strasbourg, France

Re: AHT10 humidity sensor over Software I2C

Post by AndrewBCN »

blue-man wrote: Fri Oct 22, 2021 2:43 pm The AHT10 humidity sensor has the problem that only one device of it can be connected with an I2C bus.
This is remarked in the datasheet.
...
STrange:
1. I have been using an AHT10 with other I2C devices on the same I2C bus for months now.
2. I cannot find any mention of "the problem that only one device of it can be connected with an I2C bus" in the AHT10 datasheet.
https://server4.eca.ir/eshop/AHT10/Aoso ... aft_0c.pdf

Are you sure about that? What is the problem caused by the AHT10 on an I2C bus and where is it mentioned in the datasheet?
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: AHT10 humidity sensor over Software I2C

Post by blue-man »

mrburnette wrote: Sun Oct 24, 2021 1:46 pm The term "more compatible" is far too broad to be used here without context and acknowledgment of limitations and caveats.
It is, a hack but a well executed one.

Nicely documented source code.
Compatible with the (working) I2C-Standards.
The AHT20 is a true I2C-Device and the AHT10 can be interpreted as "like" an I2C-Device, that is not compatible with other devices on the bus.

Is this more exact? 8-)
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: AHT10 humidity sensor over Software I2C

Post by blue-man »

AndrewBCN wrote: Thu Oct 28, 2021 2:02 pm
blue-man wrote: Fri Oct 22, 2021 2:43 pm The AHT10 humidity sensor has the problem that only one device of it can be connected with an I2C bus.
This is remarked in the datasheet.
...
STrange:
1. I have been using an AHT10 with other I2C devices on the same I2C bus for months now.
2. I cannot find any mention of "the problem that only one device of it can be connected with an I2C bus" in the AHT10 datasheet.
https://server4.eca.ir/eshop/AHT10/Aoso ... aft_0c.pdf

Are you sure about that? What is the problem caused by the AHT10 on an I2C bus and where is it mentioned in the datasheet?
Look on page 8 top right of your linked datasheet, there you will find:
3, Only a single AHT10 can be connected to the I 2C bus and no other I 2 C devices can be connected .
What other I2C devices are you using?
I tried to connect an BMP280 parallel and the initialization of both devices failed.

I did not invest the time to analyze a bad chinese construction, after reading the comment in the datasheet.
It is easier to accept the reason why there is an AHT20 on the market. 8-)
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: AHT10 humidity sensor over Software I2C

Post by ag123 »

a google search turns this up
https://wiki.liutyi.info/display/ARDUINO/AHT10
i'd think some manufacturers makes 'partial' compliances of protocols such as i2c etc. We'd not know if after all they 'bit banged' that protocol from a small mcu. they probably breaks the ability to co-exist with other i2c devices. sometimes u'd wonder why they can't comply with a standard protocol, ignorance maybe. or intentional so that it alone can exist on the bus.
I've a am2302 which uses a funky '1 wire' protocol, adafruit shared a datasheet
https://cdn-shop.adafruit.com/datasheet ... AM2302.pdf

Thinking about this, has anyone got a decent idea how to do humidity as *analog*? after all stm32 has good ADCs ;)
It seemed quite possible with things like TiO2 powders.
https://www.mdpi.com/2227-9040/8/4/89/pdf
another one is with PLA (that 3d printing filament plastic)
https://www.mdpi.com/1424-8220/21/19/6557/pdf
the hard thing about analog stuff is calibrating them as they are really *analog*, as pure as it is.
that is 'labor intensive' and not easy to do well.
humidity and temperature is linked and that complicates things, i.e. u'd need to measure temperature.
And I'd guess it is a kind of temperature - humidity grid table to lookup and interpolate values.
The 2nd paper (latter) seemed to offer more data for an implementable approach.
oh in seemed in the 2nd paper, it suggests that you simply need a piece of *paper* yes, *paper* & u've got a humidity sensor (figure 6 graph c) :lol:

I'm kind of guessing how to calibrate it, so an 'innovative' solution for calibration may be:
- use a desiccant to dry up a fixed volume of air in containers
- then add control amount of water in each sealed container, heat them up so that all that water vaporizes
(maybe even this table is useful as an aid
https://en.wikipedia.org/wiki/Humidity# ... emperature)
- that could make for a way to take measurements, say capacitance for different temperature since u'd now know the water to air ratio

now you are left with the 'labor intensive' parts :lol:
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: AHT10 humidity sensor over Software I2C

Post by ag123 »

mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: AHT10 humidity sensor over Software I2C

Post by mrburnette »

My apologies to blue-man for being lighthearted about a serious post, but ag123 is kind of asking for this...
ag123 wrote: Fri Nov 12, 2021 1:40 pm ...
Thinking about this, has anyone got a decent idea how to do humidity as *analog*? after all stm32 has good ADCs ;)
...
Must be a slow day for microcontroller questions, but you bring up an interesting off-subject topic. As a young boy of 10, I remember finding a radiosonde... tube type with dry-cell batteries and various sensors, one being a humidity sensor. I found this description:
A 1950'S SYTLE OF AMERICAN RADIOSONDE CONTROLLED BY A BY A BAROSWITCH, WHICH HAS AN ANEROID SENSOR & ALSO SWITCHES IN THE CERAMIC RODTHERMISTOR (TEMPERATURE SENSOR) & ELECTROLYTIC PLASTIC STRIP HUMIDITY SENSOR & REFERENCE RESISTORS. THESE ELEMENTS ARE HOUSEDWITHIN A PLASTIC CASING WITH AN OUTRIGGER & TRANSMITTER CONE.
There seems to be a wealth of info on analog humidity sensors, but implementing such devices with a modern uC seems counter-intuitive in 2021. Still, I suspect the uC could drive a table lookup easily enough; I was able to implement the entire IEEE OUI-Vendor lookup in the ESP8266 using SPIFFS without any issues. Impractical for most needs, but a fun exercise.

Reference guide (free): http://blog.servoflo.com/humidity-senso ... -resistive

Remember the calendars that salesmen would give away? The ones with the humidity sensor that consisted of a circular paper sensor glued to the calendar with a small red-tinted thermometer? While those calendars may be lost to history, capitalists still sell the equivalent chemically treated paper indicators: https://humi-smart.com/product/humi-sma ... tor-cards/
I expect one of these colored circles could be scanned using a TCS34725 and then convert the color to humidity! The beginning to a Rube Goldberg weather station.

Here is a potential sensor, just monitor the dissipation of a static field based on the time-rate-of-change:
III MIL-HDBK-263 Standard
Humid air helps to dissipate electrostatic charges by keeping surfaces moist, therefore increasing surface conductivity. Substantial electrostatic voltage levels can accumulate with a decrease in relative humidity, see Table 1 above. However, it is also evident from Table 1 that significant electrostatic voltages can still be generated with relative humidity as high as 90 percent. Relative humidity between 40 percent and 60 percent in ESD protective areas is desirable as long as it does not result in corrosion or in other detrimental effects such as PWB delamination during soldering. Where high relative humidity levels cannot be maintained, ionized air can be used to dissipate electrostatic charges.
When I was in grade-school, we were shown an experiment where a human hair was used to determine change in humidity; the hair would change length on humidity changes. Just wrap a long hair around a precision potentiometer and you have your Analog input from the wiper connection. I guess that the old cuckcoo clocks used some change-of-length to rotate the weather platform between sun and rain.

And I could probably come uo with many more were I to have a 3rd cup of coffee. ;)
Post Reply

Return to “Projects”