6.7. Inertial sensors

The Zumo 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 Zumo 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 Zumo 2040 can be affected by magnetic fields from the Zumo 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). This can make it difficult to accurately determine the Zumo’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 Zumo.)

Related Products

Zumo 2040 Robot Kit (No Motors)
Zumo 2040 Robot (Assembled with 50:1 HP Motors)
Zumo 2040 Robot (Assembled with 75:1 HP Motors)
Zumo 2040 Robot (Assembled with 100:1 HP Motors)
Zumo 2040 Main Board
Zumo 2040 Front Sensor Array
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors