Open hu-lm opened 2 months ago
I have not touched this code in 9 years, and I do not even have a Berry IMU any more to test with, so I am afraid I am of little use here.
But as you say, OS error 121 is a I2C communication error: https://stackoverflow.com/questions/52735862/getting-ioerror-errno-121-remote-i-o-error-with-smbus-on-python-raspberry-w
Hi,
I am getting an OS Error 121 when trying to read data with BerryIMUClient by:
from pyberryimu.client import BerryIMUClient
with BerryIMUClient(bus=1) as c: acc = c.read_accelerometer() gyro = c.read_gyroscope() mag = c.read_magnetometer() pr = c.read_pressure() temp = c.read_temperature()
And the it triggered the error:
Traceback (most recent call last): File "/home/DataProcessing/PyBIMU/test.py", line 3, in
with BerryIMUClient(bus=1) as c:
File "/home/DataProcessing/.venv/lib/python3.11/site-packages/pyberryimu/client.py", line 154, in enter
self.open()
File "/home/DataProcessing/.venv/lib/python3.11/site-packages/pyberryimu/client.py", line 140, in open
self._init_accelerometer()
File "/home/DataProcessing/.venv/lib/python3.11/site-packages/pyberryimu/client.py", line 186, in _init_accelerometer
self._write(LSM9DS0.ACC_ADDRESS, LSM9DS0.CTRL_REG1_XM, int(reg1_value, 2))
File "/home/DataProcessing/.venv/lib/python3.11/site-packages/pyberryimu/client.py", line 336, in _write
self.bus.write_byte_data(address, register, value)
File "/home/DataProcessing/.venv/lib/python3.11/site-packages/smbus/util.py", line 59, in validator
return fn(*args, **kwdefaults)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/DataProcessing/.venv/lib/python3.11/site-packages/smbus/smbus.py", line 145, in write_byte_data
raise IOError(ffi.errno)
OSError: 121
The I2C can still recognise sensors address correctly and the tutorial code from BerryIMU can read fine, so I am guessing the hardware set up is not the issue. Maybe it has something to do with my other SPI device connected when using Python to read from I2C, but I am not sure how to set up the overlay configuration correctly in this situation. Any help would be much appreciated! Thanks.