How to install library for ICM20948 in Pico Explorer?

I have a Pi Pico in a Pico Explorer board. I’m trying to use a ICM20948motion sensor in one of the breakout slots and I’m having trouble installing the driver library. Where do I start?

Ahoy!
Have you looked at the devices github page, it’s linked at the bottom of the store page. Easy to miss.
Open a terminal window with ctrl+alt+t together and enter the text below.

sudo pip install icm20948

Hope this helps :o)

With that command I get an error:

Collecting icm20948
Using cached icm20948-0.0.2-py3-none-any.whl (5.2 kB)
Collecting smbus
Using cached smbus-1.1.post2.tar.gz (104 kB)
Using legacy ‘setup.py install’ for smbus, since package ‘wheel’ is not installed.
Installing collected packages: smbus, icm20948
Running setup.py install for smbus … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-te6qkqlj/smbus_2f901561354c4d43bf1d430506ccaa9b/setup.py’"’"’; file=’"’"’/tmp/pip-install-te6qkqlj/smbus_2f901561354c4d43bf1d430506ccaa9b/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-_dtra7fc/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.9/smbus
cwd: /tmp/pip-install-te6qkqlj/smbus_2f901561354c4d43bf1d430506ccaa9b/
Complete output (5 lines):
running install
running build
running build_ext
building ‘i2c’ library
error: [Errno 2] No such file or directory: ‘make’
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-te6qkqlj/smbus_2f901561354c4d43bf1d430506ccaa9b/setup.py’"’"’; file=’"’"’/tmp/pip-install-te6qkqlj/smbus_2f901561354c4d43bf1d430506ccaa9b/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-_dtra7fc/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.9/smbus Check the logs for full command output.

sudo pip install icm20948 installs for Python on a Pi running Pi OS.
Normally on a PICO, you install the custom Pimoroni uf2 file which has the libraries in it for a lot of the breakouts.
Issues · pimoroni/BreakoutGarden (github.com)
It appears that breakout hasn’t ben added to the uf2 just yet though.
ICM20948 (ICM20948 9-DOF Accelerometer, Magnetometer & Gyroscope) · Issue #15 · pimoroni/BreakoutGarden (github.com)

1 Like

If you can use Circuit Python there is this, that might work.
Python & CircuitPython | Adafruit TDK InvenSense ICM-20948 9-DoF IMU | Adafruit Learning System

1 Like

Looks like that’s the answer – it hasn’t been added yet. Thanks!

1 Like

I’ve just spotted my error, ha! You’re using a pico. Doh.
Thanks to alpha who’s been more helpful than me. ;o)

@fishgotnosole
Easy mistake to make, and I’ve made my fair share of them. ;)

1 Like

Any chance the icm20948 will be added to the uf2, anytime soon?
Is there a way to add the micropython module manually, without a script to actually add it to the uf2?

I don’t work for Pimoroni, or have anything to do with the uf2 file.
In Thonny, you can do a File > save as > Raspberry Pi Pico, to add files to the uf2. I’ve done it to add support for a device. The VEML6075 (UVA & UVB Light Sensor). I hunted up a Micro Python driver for it.