Hallo
Ich bin noch relativ neu in der Raspberry Pi Welt, habe bis jetzt haupsächlich mit Arduino gearbeitet...ich hab hier ein Problem und ich stehe irgendwie am Schlauch....
Ich hab einen Pi4 nach dieser Anleitung (https://gallaugher.com/makersnack-ins…a-raspberry-pi/) gebaut. Bulseye mit Circuitpython...
Mein Problem ist folgendes. Ich kann die BME280 am TCA9548A zwar die I2C Adresse abfragen aber sonst nichts.
Programm zu m abfragen der belegten Ports mit i2c Adresse:
# This example shows using TCA9548A to perform a simple scan for connected devices
import board
import busio
import adafruit_tca9548a
# Create I2C bus as normal
i2c = board.I2C() # uses board.SCL and board.SDA
# Create the TCA9548A object and give it the I2C bus
tca = adafruit_tca9548a.TCA9548A(i2c)
for channel in range(8):
if tca[channel].try_lock():
print("Channel {}:".format(channel), end="")
addresses = tca[channel].scan()
print([hex(address) for address in addresses if address != 0x70])
tca[channel].unlock()
Alles anzeigen
Ausgabe:
Channel 0:['0x76']
Channel 1:['0x76']
Channel 2:['0x76']
Channel 3:[]
Channel 4:[]
Channel 5:[]
Channel 6:[]
Channel 7:[]
Mein Code zum BME280 Abfragen von https://cdn-learn.adafruit.com/downloads/pdf/…i2c-devices.pdf
# SPDX-FileCopyrightText: 2022 Carter Nelson for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
import board
import adafruit_tca9548a
from adafruit_bme280 import basic as adafruit_bme280
# Create I2C bus as normal
i2c = board.I2C()
# Create the TCA9548A object and give it the I2C bus
tca = adafruit_tca9548a.TCA9548A(i2c)
#--------------------------------------------------------------------
# NOTE!!! This is the "special" part of the code
#
# Create each BME280 using the TCA9548A channel instead of the I2C object
bme1 = adafruit_bme280.Adafruit_BME280_I2C(tca[0]) # TCA Channel 0
bme2 = adafruit_bme280.Adafruit_BME280_I2C(tca[1]) # TCA Channel 1
bme3 = adafruit_bme280.Adafruit_BME280_I2C(tca[2]) # TCA Channel 2
#--------------------------------------------------------------------
print("3 BME280 Example")
while True:
# Access each sensor via its instance
pressure1 = bme1.pressure
pressure2 = bme2.pressure
pressure3 = bme3.pressure
temperature1 = bme1.temperature
temperature2 = bme2.temperature
temperature3 = bme3.temperature
print("-"*20)
print("BME280 #1 Pressure =", pressure1)
print("BME280 #2 Pressure =", pressure2)
print("BME280 #3 Pressure =", pressure3)
print("BME280 #1 temperature =", temperature1)
print("BME280 #2 temperature =", temperature2)
print("BME280 #3 temperature =", temperature3)
time.sleep(1)
Alles anzeigen
Fehlermeldung:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 176, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_tca9548a.py", line 72, in writeto
return self.tca.i2c.writeto(address, buffer, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 169, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 52, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 182, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_tca9548a.py", line 66, in readfrom_into
return self.tca.i2c.readfrom_into(address, buffer, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 159, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 59, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py", line 181, in read_bytes
return self._device.read(number)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/bmem.py", line 20, in <module>
bme1 = adafruit_bme280.Adafruit_BME280_I2C(tca[0]) # TCA Channel 0
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bme280/basic.py", line 370, in __init__
self._i2c = i2c_device.I2CDevice(i2c, address)
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 63, in __init__
self.__probe_for_device()
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 185, in __probe_for_device
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x77
Alles anzeigen
Was ich schon probiert habe, die Baudrate am i2c verringert; anderes Steckbrett; andere BME280; andere TCA9548A; andere Ports am TCA;
Laut Google ist der Error "OSError: [Errno 121] Remote I/O error" meistens ein Verdrahtungsfehler....glaub ich aber nicht, da ich alles schon irgendwie durchgetauscht habe.
Was kann es da haben?
Danke