Coder Social home page Coder Social logo

pimoroni / icm20948-python Goto Github PK

View Code? Open in Web Editor NEW
44.0 10.0 22.0 62 KB

Python library for the Pimoroni ICM20948 breakout

Home Page: https://shop.pimoroni.com/products/icm20948

License: MIT License

Python 45.60% Makefile 5.99% Shell 48.41%
pypi-package

icm20948-python's Introduction

ICM20948 9-DOF Accelerometer, Magnetometer and Gyroscope

Build Status Coverage Status PyPi Package Python Versions

Installing

If you've already set up a Python virtual environment, you can also install the stable library manually from PyPi:

pip install icm20948

Otherwise our install script will set one up for you.

Stable library from GitHub:

git clone https://github.com/pimoroni/icm20948-python
cd icm20948-python
./install.sh

Latest/development library from GitHub:

git clone https://github.com/pimoroni/icm20948-python
cd icm20948-python
./install.sh --unstable

Note Libraries will be installed in the "pimoroni" virtual environment, you will need to activate it to run examples:

icm20948-python's People

Contributors

dannystaple avatar dfluff avatar gadgetoid avatar ilouzl avatar kevwal avatar leosh64 avatar sandyjmacdonald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

icm20948-python's Issues

Github workflow breaking since Ubuntu 20.04

ubuntu-latest was recently changed to 20.04 which makes .github/workflows/test.yml fail for python 3.4.

The failing test reports the error:

Version 3.4 was not found in the local cache
Error: Version 3.4 with arch x64 not found

You can avoid this by either specifying ubuntu-18.04 in your workflow or removing python 3.4 for x64. See here for more information: actions/setup-python#185 (comment)

DMP With Arduino

Does anybody have Arduino code that downloads the DMP into the ICM-20948, and to get readings from the DMP?

Error gyro sample rate calculation

The library uses 1100Hz as a reference for the sample rate divider value
rate = int((1100.0 / rate) - 1) here
The datasheet seems to be ambiguous between 1100Hz
image
and 1125Hz
image

But in practice it looks like the actual number is 1125, because when you call set_gyro_sample_rate(rate=125)
you actually get a 140Hz sampling rate.

Magnetometer never ready with ICM20948 on Waveshare IMX219-83 Stereo Camera

Hello, first of all thanks for providing this great library!

I'm trying to access a ICM20948 on a Waveshare IMX219-83 Stereo Camera using your library. Unfortunately, the magnetometer is never marked as ready, e.g. calling read_magnetometer_data() gets stuck at

        while not self.magnetometer_ready():
            time.sleep(0.00001)

with the following stack trace:

  File "read-all.py", line 20, in <module>
    x, y, z = imu.read_magnetometer_data()
  File "/usr/local/lib/python3.6/dist-packages/icm20948/__init__.py", line 113, in read_magnetometer_data
    while not self.magnetometer_ready():
  File "/usr/local/lib/python3.6/dist-packages/icm20948/__init__.py", line 109, in magnetometer_ready
    return self.mag_read(AK09916_ST1) & 0x01 > 0
  File "/usr/local/lib/python3.6/dist-packages/icm20948/__init__.py", line 93, in mag_read
    self.write(ICM20948_I2C_SLV0_DO, 0xff)
  File "/usr/local/lib/python3.6/dist-packages/icm20948/__init__.py", line 61, in write
    self._bus.write_byte_data(self._addr, reg, value)

Reading accelerometer and gyro data with read_accelerometer_gyro_data works flawlessly though, so the connection to the sensor itself seems fine.

Using C code provided by Waveshare itself, all sensors including the magnetometer can be accessed.

Comparing the register values in Waveshare's C file with the ones in your Python library, I see subtle differences, could they be causing the issue?

/* define ICM-20948 MAG Register  */
#define REG_ADD_MAG_WIA1    0x00
    #define REG_VAL_MAG_WIA1    0x48
#define REG_ADD_MAG_WIA2    0x01
    #define REG_VAL_MAG_WIA2    0x09
#define REG_ADD_MAG_ST2     0x10
#define REG_ADD_MAG_DATA    0x11
#define REG_ADD_MAG_CNTL2   0x31
    #define REG_VAL_MAG_MODE_PD     0x00
    #define REG_VAL_MAG_MODE_SM     0x01
    #define REG_VAL_MAG_MODE_10HZ   0x02
    #define REG_VAL_MAG_MODE_20HZ   0x04
    #define REG_VAL_MAG_MODE_50HZ   0x05
    #define REG_VAL_MAG_MODE_100HZ  0x08
    #define REG_VAL_MAG_MODE_ST     0x10
/* define ICM-20948 MAG Register  end */

OSError: [Errno 121] Remote I/O error

I'm trying to use your module on raspberry pi 3b+ under Raspbian Buster with desktop !

I obtain : OSError: [Errno 121] Remote I/O error

Vin = 5V
GND = GND
1V8 = 1V8
SDA = SDA
SCL = SCL

imu = ICM20948(i2c_addr=0x68)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.venv/jns/lib/python3.7/site-packages/icm20948/__init__.py", line 227, in __init__
    self.write(ICM20948_PWR_MGMT_1, 0x01)
  File "/home/pi/.venv/jns/lib/python3.7/site-packages/icm20948/__init__.py", line 61, in write
    self._bus.write_byte_data(self._addr, reg, value)
OSError: [Errno 121] Remote I/O error
>>> exit()
(jns) pi@raspberrypi:~/Desktop/centrale $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
(jns) pi@raspberrypi:~/Desktop/centrale $ 

Best Regards

Read data from DMP

Hello pimoroni team,

I would like to ask if there are any plans to enable DMP and read orientation data from this device, using this library, if possible! It will be for me the most amazing feature and a take-my-money move!

Thank you in advance.

OSError: [Errno 121] Remote I/O error

Hi guys, I followed this tutorial adafruit/Adafruit_CircuitPython_VEML6075#4
but when I'm trying to use the i2c I got the following error:
Traceback (mosr call recent call last)
OSError : [Error 121] Remote I/O error

  1. I use I2C0 to send command to a module and count it , but when count to a few moment will error.
  2. I change the I2c baud rate from config.txt and measure the frequency have not change.
    My module is Raspberry Pi 4 model B I2C0.

When i search many information to solve the problem, almost answer is Raspberry Pi 2/3 .
It can't help me to solve the Pi 4 OSEerror.
I checked the connections and enabled I2C from Raspi config.

Sparkfun SEN-15335 (icm-20948 board) Getting IOError: [Errno 121] Remote I/O error

Dear Colleagues:

I just hooked up a Sparkfun SEN-15335, which uses the ICM-20948 IMU. I am using Raspberry Buster on a raspberry pi 4b.

I am replacing a working MPU-9250 setup with the ICM-20948, since the MPU-9250 has been EOL'd.

Vin on the board is 3.3 Volts, SDA from the Sparkfun board is connected to physical pin 3 (SDA1) on the Pi and SCL from the Sparkfun board is connected directly to physical pin 5 (SCL1) on the Pi. i2c is enabled on the Pi and works (I have tested it with other i2c devices, including the mentioned MPU9250 IMU. Then I disconnected everything but the ICM-20948 to troubleshoot). Lead length is 21cm.

I am attempting to run read-all.py from the examples in this repository. I have not modified the code.

Here's what I get:

pi@antonio:~/icm20948-python/examples $ python read-all.py
read-all.py

Reads all ranges of movement: accelerometer, gyroscope and

compass heading.

Press Ctrl+C to exit!


Traceback (most recent call last):
  File "read-all.py", line 16, in <module>
    imu = ICM20948()
  File "build/bdist.linux-armv7l/egg/icm20948/__init__.py", line 254, in __init__
  File "build/bdist.linux-armv7l/egg/icm20948/__init__.py", line 89, in bank
  File "build/bdist.linux-armv7l/egg/icm20948/__init__.py", line 69, in write
IOError: [Errno 121] Remote I/O error

I am already aware that Errno 121 usually has to do with the I/O on the device. When I've had to fix this in the past, it has been a matter of the device not being detected. In this case, the device is detected:

pi@antonio:~/icm20948-python/examples $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

more tests:

pi@antonio:~/icm20948-python/examples $ i2cget -y 1 0x69 0
0xea
pi@antonio:~/icm20948-python/examples $ i2cget -y 1 0x69 4
0x00

The SEN-15335 has onboard logic level translation, to match the 3.3V to the new 1.9 max input voltage of the ICM-20948, without needing an external board for this.

I have no working hypotheses yet on what is going wrong.

Does anyone have any ideas how to make this work?
Thanks,
Mark

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.