Pico 10DOF IMU
| ||
Overview
The Pico-10DOF-IMU is an IMU sensor expansion module specialized for Raspberry Pi Pico. It incorporates sensors including a gyroscope, accelerometer, magnetometer, and baroceptor, and uses an I2C bus for communication.
Combined with the Raspberry Pi Pico, it can be used to collect environment sensing data like temperature and barometric pressure or to easily DIY a robot that detects motion gestures and orientations.
Feature
- Standard Raspberry Pi Pico header supports Raspberry Pi Pico series.
- Onboard MPU9250 (3-axis gyroscope, 3-axis accelerometer, and 3-axis magnetometer) for detecting motion gesture, orientation, and magnetic field.
- Onboard LPS22HB barometric pressure sensor, for sensing the atmospheric pressure of the environment.
- Provides online complete manual and resources (example programs such as Raspberry Pi Pico C/C++ and Micro Python).
Specifications
Sensor | Parameters |
Acceslerometer | Resolution: 16 bits Measuring range (optional): ±2, ±4, ±8, ±16g Operating current: 450uA |
Gyroscope | Resolution: 16 bits Measuring range (optional): ±250, ±500, ±1000, ±2000°/sec Operating current: 3.2mA |
Magnetometer | Resolution: 14 bits Measuring range: ±4800µT(MPU9250) / ±4900µT(ICM20948) Operating current: 280uA |
Baroceptor | Measuring range: 260 ~ 1260hPa Measuring accuracy (ordinary temperature): ±0.025hPa Measuring speed: 1Hz - 75Hz |
Electric | Parameters |
Operating voltage | 5V |
Hardware Description
- Pico-10DOF-IMU has three revisions:
- 1. USB silkscreen update, add XYZ axis silkscreen and add 0R resistor for power management.
- 2. The FSYNC, ICM.INT, and LPS.INT pins are respectively connected to two groups of GPIOs with 0-ohm resistors to avoid GPIO conflicts when sharing with other modules.
- 3. Use MPU9250 instead of ICM20948, and change the silkscreen name to Pico-10DOF-IMU Rev2.1.
- 4. Reuse ICM20948, change silkscreen name to Pico-10DOF-IMU Rev3.1.
Hardware Connection
1. Note that the USB Logo on the Pico-10DOF-IMU Rev2.1 corresponds to the USB connection direction of the Raspberry Pi Pico.
2. When downloading the C demo, be sure to press and hold the BOOT key before connecting the USB cable.
Axial Description
The axes of the accelerometer, gyroscope, and magnetometer on the MPU9250 are shown in the figure below. The magnetometer on the MPU9250 will be interfered with by hard magnetic, so when the data read by the magnetometer is fitted with an ellipsoid, the sphere is off-center and does not Circle. This will bring an initial magnetic field offset to the magnetometer, making the magnetometer data eccentric. The magnetometer needs to be initialized when the power is turned on. Please refer to the initialization chapter below.
Pinout
1. Pico-10DOF-IMU Rev2.1 uses GPIO as shown in the figure above, in which SDA (GPIO6), SCL (GPIO7) pins are fixedly connected, MPU9250 INT (GPIO4), FSYNC (GPIO22), LPS22HB INT (GPIO5) can be connected through 0R The resistance change connection pins are MPU9250 INT (GPIO22), FSYNC (GPIO16), LPS22HB INT (GPIO3), click to view the schematic diagram for details.
2. The 40Pin of Pico-10DOF-IMU Rev2.1 is powered by the VSYS pin of Raspberry Pi Pico by default. If you want to turn off the 10DOS power supply, you can solder the 0R of R13 to R15 so that you can use the GPIO14 of Raspberry Pi Pico to turn on /off the 10DOF power supply. Please click to view the schematic diagram for details.
3. If you want to use the 3.3V of Pico as the power supply, you can solder the 0R of R13 to R12. Please click to view the schematic diagram for details.
4. If you want to remove the LED of Pico-10DOF-IMU Rev2.1 and the 0R on the R11, you can click to view the schematic diagram for details.
I2C Bus
- The Pico-10DOF-IMU onboard MPU9250 uses the I2C bus for communication. The read and write timing diagram is shown in the figure below. For more details, please refer to datasheet.
- Raspberry Pi Pico, as the Master device, pulls down SDA successively, and the SCL pin initiates the START condition of the I2C bus, and then writes the device address (7bits) and write command (1bit) with a total of 8 bits of data. If the pin is connected correctly, 10ODF is used as the slave device. Send an ACK response.
- Raspberry Pi Pico continues to write the register address (RA) and register value (DATA) respectively and waits for the ACK response. After writing, the Raspberry Pi Pico pulls up SCL successively, and the SDA pin sends a STOP condition.
- If the Raspberry Pi Pico reads the DATA of the register (RA), when writing RA and waiting for the ACK response, it re-initiates the START condition, and then writes the device address (7bits) and the read command (1bit) for a total of 8bits and waits for the ACK response. 10DOF returns to DATA. After Pico receives DATA, keep SDA high.
- Please refer to the burst Read/Write Sequence in the figure above for the continuous write register value.
Outline Dimensions
Environment Building
- We test the code with Arduino IDE and Thony, click to download the related IDE, and open them after installation.
1. Install Pico SDK on Arduino IDE, click Tools->Board->Boards Manager, then search "Raspberry Pi Pico", and find the corresponding libraries to install.
2. Please refer to Micropython official document and set up python environment, select the Raspberry Pi Pico device in Thonny's Tools->Options->Interprete, as shown as below.
Demo Download
- Click to download sample demo.
- Unzip the sample demo, click .ino directly to open the Arduino sample demo, and upload the Micorpython sample demo to the Pico file system, as shown in the figure.
Demo Usage
Arduino
1. Press and hold the BOOT button on the Pico and then connect the USB cable, open the .ino sample demo, click the menu bar, and select Tools -> Board -> Raspberry Pi Pico. As shown in the figure below.
2. Click Upload under Edit to download the code to Pico. After downloading, open the device manager to view the virtual COM number of Pico, and then select the corresponding COM number in Tools -> Ports.
3. Click to open Monitor Serial at the top right of the Arduino IDE, and follow the serial port prompts to initialize the Pico-10DOF-IMU. For details, please refer to the Pico-10DOF-IMU initialization chapter.
Micropython
- Please Install Thonny Python IDE (Windows V3.3.3)
- Open the mpu9250.py, lps22hb.py scripts in the Pico file system, and click Run to run, where mpu9250.py will output relevant information to initialize the configuration of Pico-10DOF-IMU, as shown in the figure below, please refer to Pico-10DOF for the detailed process -IMU initialization chapter.
Initialization
- The magnetometer on the MPU9250 will be interfered with by the hard magnetic field. When the ellipsoid fitting is performed on the data read by the magnetometer, the sphere is off-center and not round. This will bring an initial magnetic field offset to the magnetometer, making the magnetometer Data eccentricity, as shown in the figure below:
- After power-on, initialize according to the prompt information sent by the serial port. Calculate the eccentric offset value of the magnetometer, as shown in the following figure:
Demo Analysis
This section briefly analyzes the mpu9250.py sample program.
- mpu9250 = MPU9250() instantiates the MPU9250 class. The instantiation process will include gyroscope initialization and geomagnetic calibration.
- mpu9250.readAccel() , mpu9250.readGyro() , mpu9250.readMagnet() respectively read raw data such as accelerometer, gyroscope, geomagnetometer, etc.
- mpu9250.imuAHRSupdate() is the mahony algorithm used to convert the values of the accelerometer, gyroscope and geomagnetometer into Euler angles (pitch, roll, yaw). Please click the link to view the detailed process of the mahony algorithm
- Euler angles are shown in the figure below:
mpu9250 = MPU9250() try: while True: mpu9250.readAccel() mpu9250.readGyro() mpu9250.readMagnet() mpu9250.imuAHRSupdate(Gyro[0]/32.8*0.0175, Gyro[1]/32.8*0.0175,Gyro[2]/32.8*0.0175, Accel[0],Accel[1],Accel[2], Mag[0], Mag[0], Mag[2]) pitch = math.asin(-2 * q1 * q3 + 2 * q0* q2)* 57.3 roll = math.atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1)* 57.3 yaw = math.atan2(-2 * q1 * q2 - 2 * q0 * q3, 2 * q2 * q2 + 2 * q3 * q3 - 1) * 57.3 print("\r\n /-------------------------------------------------------------/ \r\n") print('\r\n Roll = %.2f , Pitch = %.2f , Yaw = %.2f\r\n'%(roll,pitch,yaw)) print('\r\nAcceleration: X = %d , Y = %d , Z = %d\r\n'%(Accel[0],Accel[1],Accel[2])) print('\r\nGyroscope: X = %d , Y = %d , Z = %d\r\n'%(Gyro[0],Gyro[1],Gyro[2])) print('\r\nMagnetic: X = %d , Y = %d , Z = %d'%((Mag[0]),Mag[1],Mag[2])) time.sleep(0.1) except KeyboardInterrupt: sys.exit()
Resource
Documents
- Rev2.1 Schematic Diagram
- Rev3.1 Schematic Diagram
- ICM20948 Datasheet
- LPS22HB Specification
- LSF0204d Specification
- MPU9250
Demo Codes
- Demo code
- Rev3.1 shared demo with Rev1.0.
Development Software
- Zimo221.7z
- Image2Lcd.7z
- Font Library Tutorial
- Image Extraction Tutorial
- Thonny Python IDE (Windows V3.3.3)
Pico Getting Started
Firmware Download
Introduction
MicroPython Series
Install Thonny IDE
In order to facilitate the development of Pico/Pico2 boards using MicroPython on a computer, it is recommended to download the Thonny IDE
- Download Thonny IDE and follow the steps to install, the installation packages are all Windows versions, please refer to Thonny's official website for other versions
- After installation, the language and motherboard environment need to be configured for the first use. Since we are using Pico/Pico2, pay attention to selecting the Raspberry Pi option for the motherboard environment
- Configure MicroPython environment and choose Pico/Pico2 port
- Connect Pico/Pico2 to your computer first, and in the lower right corner of Thonny left-click on the configuration environment option --> select Configture interpreter
- In the pop-up window, select MicroPython (Raspberry Pi Pico), and choose the corresponding port
Flash Firmware
- Click OK to return to the Thonny main interface, download the corresponding firmware library and burn it to the device, and then click the Stop button to display the current environment in the Shell window
- Note: Flashing the Pico2 firmware provided by Micropython may cause the device to be unrecognized, please use the firmware below or in the package
- How to download the firmware library for Pico/Pico2 in windows: After holding down the BOOT button and connecting to the computer, release the BOOT button, a removable disk will appear on the computer, copy the firmware library into it
- How to download the firmware library for RP2040/RP2350 in windows: After connecting to the computer, press the BOOT key and the RESET key at the same time, release the RESET key first and then release the BOOT key, a removable disk will appear on the computer, copy the firmware library into it (you can also use the Pico/Pico2 method)
MicroPython Series
【MicroPython】 machine.Pin class function details
【MicroPython】machine.PWM class function details
【MicroPython】machine.ADC class function details
【MicroPython】machine.UART class function details
【MicroPython】machine.I2C class function details
【MicroPython】machine.SPI class function details
【MicroPython】rp2.StateMachine class function details
C/C++ Series
For C/C++, it is recommended to use Pico VS Code for development. This is a Microsoft Visual Studio Code extension designed to make it easier for you to create, develop, and debug projects for the Raspberry Pi Pico series development boards. No matter if you are a beginner or an experienced professional, this tool can assist you in developing Pico with confidence and ease. Here's how to install and use the extension.
- Official website tutorial: https://www.raspberrypi.com/news/pico-vscode-extension/
- This tutorial is suitable for Raspberry Pi Pico, Pico2 and the RP2040 and RP2350 series development boards developed by Waveshare
- The development environment defaults to Windows11. For other environments, please refer to the official tutorial for installation
Install VSCode
-
First, click to download pico-vscode package, unzip and open the package, double-click to install VSCode
Note: If vscode is installed, check if the version is v1.87.0 or later
Install Extension
-
Click Extensions and select Install from VSIX
-
Select the package with the vsix suffix and click Install
-
Then vscode will automatically install raspberry-pi-pico and its dependency extensions, you can click Refresh to check the installation progress
-
The text in the right lower corner shows that the installation is complete. Close VSCode
Configure Extension
-
Open directory C:\Users\username and copy the entire .pico-sdk to that directory
-
The Copy is completed
-
Open vscode and configure the paths for the Raspberry Pi Pico extensions
The configuration is as follows:Cmake Path: ${HOME}/.pico-sdk/cmake/v3.28.6/bin/cmake.exe Git Path: ${HOME}/.pico-sdk/git/cmd/git.exe Ninja Path: ${HOME}/.pico-sdk/ninja/v1.12.1/ninja.exe Python3 Path: ${HOME}/.pico-sdk/python/3.12.1/python.exe
New Project
-
The configuration is complete, create a new project, enter the project name, select the path, and click Create to create the project
To test the official example, you can click on the Example next to the project name to select
-
The project is created successfully
-
Select the SDK version
-
Select Yes for advanced configuration
-
Choose the cross-compilation chain, 13.2.Rel1 is applicable for ARM cores, RISCV.13.3 is applicable for RISCV cores. You can select either based on your requirements
-
Select default for CMake version (the path configured earlier)
-
Select default for Ninjaversion
-
Select the development board
-
Click Complie to compile
-
The uf2 format file is successfully compiled
Import Project
- The Cmake file of the imported project cannot have Chinese (including comments), otherwise the import may fail
-
To import your own project, you need to add a line of code to the Cmake file to switch between pico and pico2 normally, otherwise even if pico2 is selected, the compiled firmware will still be suitable for pico
set(PICO_BOARD pico CACHE STRING "Board type")
Update Extension
-
The extension version in the offline package is 0.15.2, and you can also choose to update to the latest version after the installation is complete
Arduino IDE Series
Install Arduino IDE
-
First, go to Arduino official website to download the installation package of the Arduino IDE.
-
Here, you can select Just Download.
-
Once the download is complete, click Install.
Notice: During the installation process, it will prompt you to install the driver, just click Install
600px
Arduino IDE Interface
-
After the first installation, when you open the Arduino IDE, it will be in English. You can switch to other languages in File --> Preferences, or continue using the English interface.
-
In the Language field, select the language you want to switch to, and click OK.
Install Arduino-Pico Core in the Arduino IDE
-
Open the Arduino IDE, click on the file in the top left corner, and select Preferences
-
Add the following link to the attached board manager URL, and then click OK
https://github.com/earlephilhower/arduino-pico/releases/download/4.0.2/package_rp2040_index.json
Note: If you already have an ESP32 board URL, you can use a comma to separate the URLs as follows:https://dl.espressif.com/dl/package_esp32_index.json,https://github.com/earlephilhower/arduino-pico/releases/download/4.0.2/package_rp2040_index.json
-
Click Tools > Development Board > Board Manager > Search pico, as my computer has already been installed, it shows that it is installed
Upload Demo at the First Time
-
Press and hold the BOOTSET button on the Pico board, connect the pico to the USB port of the computer via the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
- Download the program and open D1-LED.ino under the arduino\PWM\D1-LED path
-
Click Tools --> Port, remember the existing COM, do not click this COM (the COM displayed is different on different computers, remember the COM on your own computer)
-
Connect the driver board to the computer using a USB cable. Then, go to Tools > Port. For the first connection, select uf2 Board. After uploading, when you connect again, an additional COM port will appear
-
Click Tools > Development Board > Raspberry Pi Pico > Raspberry Pi Pico or Raspberry Pi Pico 2
- After setting it up, click the right arrow to upload the program
- If issues arise during this period, and if you need to reinstall or update the Arduino IDE version, it is necessary to uninstall the Arduino IDE completely. After uninstalling the software, you need to manually delete all contents within the C:\Users\[name]\AppData\Local\Arduino15 folder (you need to show hidden files to see this folder). Then, proceed with a fresh installation.
Open Source Demos
MircoPython video demo (github)
MicroPython firmware/Blink demos (C)
Raspberry Pi official C/C++ demo (github)
Raspberry Pi official micropython demo (github)
Arduino official C/C++ demo (github)
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)