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 inertial sensors that can be used in advanced applications, such as helping your Zumo detect collisions and determine its own orientation by implementing an inertial measurement unit (IMU). The first chip, an ST LSM303D compass module, combines a 3-axis accelerometer and 3-axis magnetometer into a single package. The second chip is an ST L3GD20H 3-axis gyroscope. Both sensor chips share an I²C bus connected to the ATmega32U4’s I²C interface.

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 LSM303D datasheet (1MB pdf) and L3GD20H datasheet (3MB pdf) to understand how these sensors work and how to use them.

Using the sensors

The Zumo32U4 library (see Section 6) includes functions that make it easier to work with the sensors, as well as some example programs that demonstrate how to use them. (The software interface is identical to those of our LSM303 Arduino library and L3G Arduino library.)

In addition, the sensor ICs on the Zumo 32U4 are the same as those on our MinIMU-9 v3, so Arduino software written for the MinIMU-9 (such as our AHRS example) can also be adapted to work on a Zumo 32U4 robot.

Notes on the magnetometer

Please note that the magnetometer in the LSM303 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
Zumo 32U4 Front Sensor Array
Zumo 32U4 Blade
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