6.6. Inertial sensors

The 3pi+ 2040 includes on-board inertial sensors that allow it to determine its own orientation by implementing an inertial measurement unit (IMU). The first chip, an ST LSM6DSO, combines a 3-axis accelerometer and 3-axis gyro into a single package. The second chip is an ST LIS3MDL 3-axis magnetometer.

The RP2040 can communicate with these two chips using I2C0, one of its two hardware I²C modules. The I²C clock lines (SCL) of both chips are connected to GP5 and pulled up by a 10 kΩ resistor. The I²C data lines (SDA) of both chips are connected to GP4 and pulled up by a 10 kΩ resistor.

Using the sensors

The example Python program imu_test.py in the 3pi+ 2040 Robot Libraries and Example Code shows how to configure the sensors, read data from them, and display the readings on the OLED display.

Notes on the magnetometer

Please note that the magnetometer on the 3pi+ 2040 can be affected by magnetic fields from the 3pi+ itself. These include magnets in the motors and encoders, electrical currents through the board, and hard iron distortions from metal (probably mostly from the batteries). The magnetometer is positioned as far away from the motors as possible to avoid interference from them, but hard iron distortions can still influence the readings significantly, making it difficult to accurately determine the 3pi+’s absolute heading based on the raw magnetometer data.

This post on the Pololu forum details a technique for correcting for hard iron distortions, making it possible to use the magnetometer as a compass for navigation in environments that are not dominated by magnetic interference. (It is written about our Balboa 32U4 robot, but the same principles apply to the 3pi+.)

Related Products

3pi+ 2040 Robot - Standard Edition (30:1 MP Motors), Assembled
3pi+ 2040 Robot - Turtle Edition (75:1 LP Motors), Assembled
3pi+ 2040 Robot - Hyper Edition (15:1 HPCB Motors), Assembled
3pi+ 2040 Robot Kit with 30:1 MP Motors (Standard Edition Kit)
3pi+ 2040 Robot Kit with 75:1 LP Motors (Turtle Edition Kit)
3pi+ 2040 Robot Kit with 15:1 HPCB Motors (Hyper Edition Kit)
3pi+ 2040 Control Board
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors