ADXL343 using i2c not working on Pi 400
by jamestutt on Thu Jan 20, 2022 9:57 am
I am trying to read the ADXL343 sensor on a raspberry pi 400 using the circuit python wiring and code. When I run "i2cdetect -y 1" I see that the sensor is connected, but when I run the code in Python I get this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 154, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 166, 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 49, 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 160, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 156, 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 56, 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/RISE/ADXL_test_code.py", line 11, in <module>
accelerometer = adafruit_adxl34x.ADXL343(i2c)
File "/usr/local/lib/python3.9/dist-packages/adafruit_adxl34x.py", line 174, in __init__
self._i2c = i2c_device.I2CDevice(i2c, address)
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 50, in __init__
self.__probe_for_device()
File "/usr/local/lib/python3.9/dist-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: 0x53
0x53 is the location that i2cdetect shows the sensor as being in. I ran code for the BMP388 sensor on a Raspberry Pi Zero last year and it worked fine, but now this doesn't work either on the Pi 400. The code is directly copied from the Circuit Python page for this sensor, I have updated my Pi, all of the packages have been installed, and i2c has been enabled.
I am going to try to get things running on a Pi Zero.