COVID-19 impact: We are still operating and shipping all orders! We are operating with a reduced staff, so for critical requirements, including fighting COVID-19, please contact us so we can identify priorities. Click here for more info.

3.7. Inertial sensors

The Zumo 32U4 includes on-board sensors that can be used as an inertial measurement unit (IMU) for applications like helping your Zumo detect collisions and determine its own orientation.

The inertial sensors include a 3-axis accelerometer, 3-axis gyro, and 3-axis magnetometer, all connected to a shared I²C bus connected to the ATmega32U4’s I²C interface. The specific inertial sensor chips used on a Zumo 32U4 depend on its version:

Level shifters built into the main board allow the inertial sensors, which operate at 3.3 V, to be connected to the ATmega32U4 (operating at 5 V). The sensors, level shifters, and I²C pull-up resistors are connected to the SDA (digital pin 2, or PD1) and SCL (digital pin 3, or PD0) pins on the AVR by default, but they can be disconnected by cutting the surface-mount jumpers labeled “2 = SDA” and “3 = SCL” on the board to allow those pins to be used for other purposes.

We recommend carefully reading the datasheets listed above to understand how these sensors work and how to use them.

Using the sensors

The Zumo32U4 library (see Section 6) includes functions that help configure and read the inertial sensors, and it abstracts details of the specific sensor ICs to make it easier to write programs that will work on all versions of the Zumo 32U4. The library includes some example programs that demonstrate how to use the sensors.

For advanced applications, you can instead use some of the dedicated libraries that we have written for these sensor chips; these include our LSM6 Arduino library, LIS3MDL Arduino library, LSM303 Arduino library, and L3G Arduino library. The Zumo 32U4 main boards use the same inertial sensor ICs as some of our IMU boards, like the MinIMU-9 v5, so Arduino software written for the MinIMU-9 (such as our AHRS example) can also be adapted to work on a Zumo 32U4.

Notes on the magnetometer

Please note that the magnetometer on the Zumo 32U4 is affected by currents in the motors and buzzer when they are operating, as well as metal in the batteries, and the readings are easily influenced by magnetic distortions in the environment around the Zumo (such as rebar in a concrete floor). As a result, it is very hard to accurately determine the Zumo’s absolute heading based on the magnetometer data. However, in our tests, we found that the magnetometer could still be useful for rough measurements of relative orientation changes; for example, once the magnetic readings are compensated for a particular environment, they can be used to help the Zumo turn left or right by a specific angle instead of just timing how long to run the motors to make such a turn (although the gyro or encoders might be better suited for this particular purpose).

In our tests, we found that the batteries, motors, and motor current affect the z axis of the magnetometer much more strongly than the x and y axes, so you probably will want to ignore the z readings. We were generally able to get decent results using only the x and y magnetometer readings to determine heading. Additionally, you might need to decrease the magnetometer sensitivity; if the magnetometer returns a value of -4096, that is a sign that the sensitivity range is set too narrow for your particular environment.

Related Products

Zumo 32U4 Robot Kit (No Motors)
Zumo 32U4 Robot (Assembled with 50:1 HP Motors)
Zumo 32U4 Robot (Assembled with 75:1 HP Motors)
Zumo 32U4 Robot (Assembled with 100:1 HP Motors)
Zumo 32U4 Main Board v1.0
Zumo 32U4 Front Sensor Array
Zumo 32U4 Blade
Zumo 32U4 Main Board v1.1
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