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)
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
>>>