Using Multiple AHT10 sensors with Adafruit_Python_Extended_B

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
BerndPi
 
Posts: 2
Joined: Sun Jan 09, 2022 1:52 pm

Using Multiple AHT10 sensors with Adafruit_Python_Extended_B

Post by BerndPi »

Hi all,

I'm new here and also new on programming mirco devices (long experience with application programming).
My acutual issue is:
- I've setup a Raspberry 3b (with default Raspian OS)
- created two additional I2C busses (3 and 4)
- connected an AHT10 sensor on each I2C bus (one on bus 3 | one on bus 4)
-> both sensors are recognized well by i2cdetect
--> by using only one sensor my Phython prog works fine
--> by using 2 sensors it is running into an ERROR

So, i ask myself: What is wrong?
- Is it my Phython code?
- Is it impossible to have 2 "instances" of the same sensor?
-> if so: Is it a restriction of the sensor module code, or maybe a restriction in the Adafruit_Python_Extended_Bus lib?

This is my Python code:

Code: Select all

import adafruit_ahtx0
from adafruit_extended_bus import ExtendedI2C as I2C

i2c_bus_1 = I2C(3)
i2c_bus_2 = I2C(4)

sensor_innen = adafruit_ahtx0.AHTx0(i2c_bus_1)
sensor_aussen = adafruit_ahtx0.AHTx0(i2c_bus_2)
The Error Trace I've posted below

I would be pleased for any helping hint.
Thanks in advance and best regards
Bernd

Python Error trace:
>>> %Run aht21-0.py
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 154, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/home/pi/.local/lib/python3.9/site-packages/busio.py", line 166, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 49, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
self._device.write(buf)
OSError: [Errno 6] No such device or address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 160, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/home/pi/.local/lib/python3.9/site-packages/busio.py", line 156, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 56, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 181, in read_bytes
return self._device.read(number)
OSError: [Errno 6] No such device or address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/aht21-0.py", line 8, in <module>
sensor_aussen = adafruit_ahtx0.AHTx0(i2c_bus_2)
File "/usr/local/lib/python3.9/dist-packages/adafruit_ahtx0.py", line 83, in __init__
self.i2c_device = I2CDevice(i2c_bus, address)
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 50, in __init__
self.__probe_for_device()
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 163, in __probe_for_device
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x38
>>>

User avatar
BerndPi
 
Posts: 2
Joined: Sun Jan 09, 2022 1:52 pm

Re: Using Multiple AHT10 sensors with Adafruit_Python_Extend

Post by BerndPi »

DONE - error found -> issue solved
RCA:
One of the AHT10 sensors was a little bit crooked on the breadboard....
I pushed the sensor a little bit and it works....

The strange thing is: i2cdetect neverless showed any errors
-> everytime i double checked it with i2cdetect, i2cdetetct shows both sensors

Anyway: Now it works!

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”