$ cat acc-example.py
from sense_hat import SenseHat
sense = SenseHat()
while True:
acceleration = sense.get_accelerometer_raw()
x = acceleration['x']
y = acceleration['y']
z = acceleration['z']
x=round(x, 0)
y=round(y, 0)
z=round(z, 0)
print("x={0}, y={1}, z={2}".format(x, y, z))
Results in:
$ python acc-example.py
Traceback (most recent call last):
File "acc-example.py", line 6, in <module>
acceleration = sense.get_accelerometer_raw()
File "/home/jwhendy/.local/lib/python3.8/site-packages/sense_hat/sense_hat.py", line 844, in get_accelerometer_raw
raw = self._get_raw_data('accelValid', 'accel')
File "/home/jwhendy/.local/lib/python3.8/site-packages/sense_hat/sense_hat.py", line 703, in _get_raw_data
if self._read_imu():
File "/home/jwhendy/.local/lib/python3.8/site-packages/sense_hat/sense_hat.py", line 684, in _read_imu
self._init_imu() # Ensure imu is initialised
File "/home/jwhendy/.local/lib/python3.8/site-packages/sense_hat/sense_hat.py", line 648, in _init_imu
raise OSError('IMU Init Failed')
OSError: IMU Init Failed
Trying to do something like this:
Results in:
Info
From looking at the code, seems like this is not playing nice with RTIMUlib. I installed/built it from source as described here.
Thanks.