The Pololu MinIMU-9 is an inertial measurement unit (IMU) that packs an L3G4200D 3-axis gyro and an LSM303DLH 3-axis accelerometer and 3-axis magnetometer onto a tiny 0.9″ × 0.6″ board. An I²C interface accesses nine independent rotation, acceleration, and magnetic measurements that can be used to calculate the sensor’s absolute orientation.

Discontinuation notice: This board has been replaced by the newer MinIMU-9 v2 L3GD20 and LSM303DLHC carrier, which offers improved magnetic sensing resolution, a wider acceleration measurement range, and gyro measurements that are more resistant to audio noise and vibrations. The new version is also 25% smaller than the original. The MinIMU-9 v2 is pin-compatible with the previous version, but the mounting hole location has changed, and the new ICs have different I²C addresses and configuration registers, so code written to interface with the MinIMU-9 will need to be modified to work with the MinIMU-9 v2.

Overview

The Pololu MinIMU-9 is a compact (0.9″ × 0.6″ × 0.1″) board that combines ST’s L3G4200D 3-axis gyroscope and LSM303DLH 3-axis accelerometer and 3-axis magnetometer to form an inertial measurement unit (IMU); we therefore recommend careful reading of the L3G4200D datasheet (1MB pdf) and the LSM303DLH datasheet (599k pdf) before using this product. These sensors are great ICs, but their small packages make them difficult for the typical student or hobbyist to use. They also operate on multiple voltage supplies that make interfacing with 3.3 or 5 V systems challenging. The MinIMU-9 addresses these issues by incorporating additional electronics, including two voltage regulators and a level-shifting circuit, while keeping the overall size as compact as possible. The board ships fully populated with its SMD components, including the L3G4200D and LSM303, as shown in the product picture.

The L3G4200D and the LSM303 have many configurable options, including dynamically selectable sensitivities for the gyro, accelerometer, and magnetometer, as well as a choice of output data rates for each sensor. The two ICs can be accessed through a shared I²C/TWI interface, allowing all three sensors to be addressed individually via a single clock line and a single data line. The nine independent rotation, acceleration, and magnetic readings (sometimes called 9DOF) provide all the data needed to make an attitude and heading reference system (AHRS). With an appropriate algorithm, a microcontroller or computer can use the data to calculate the orientation of the MinIMU-9 board; the gyro can be used to very accurately track rotation on a short timescale, while the accelerometer and compass can help compensate for gyro drift over time by providing an absolute frame of reference. The respective axes of the two chips are aligned on the board to facilitate these sensor fusion calculations. (For an example of such a system using an Arduino, see the picture below and the Sample Code section at the bottom of this page.)

Visualization of AHRS orientation calculated from MinIMU-9 readings.

The carrier board includes two voltage regulators that provide the 1.8 V and 3 V required by the L3G4200D and LSM303, allowing the module to be powered from a single 2.6 – 5.5 V supply. The regulator outputs are available on the 1V8 and 3V pins and can supply almost 150 mA and 300 mA, respectively, to external devices. The breakout board also includes a circuit that shifts the I²C clock and data lines to the same logic voltage level as the supplied VIN, making it simple to interface the board with 3.3 V or 5 V systems, and the board’s 0.1″ pin spacing makes it easy to use with standard solderless breadboards and 0.1″ perfboards.

Using the MinIMU-9

Connections

A minimum of four connections are necessary to use the MinIMU-9: VIN, GND, SCL, and SDA. VIN should be connected to a 2.6 – 5.5 V source, GND to 0 volts, and SCL and SDA should be connected to an I²C bus operating at the same logic level as VIN.

Pololu MinIMU-9 gyro, accelerometer, and compass, labeled top view.

Pololu MinIMU-9 gyro, accelerometer, and compass in a breadboard.

Pinout

PIN

Description

SCL

Level-shifted I²C clock line: HIGH is VIN, LOW is 0 V

SDA

Level-shifted I²C data line: HIGH is VIN, LOW is 0 V

GND

The ground (0 V) connection for your power supply. Your I²C control source must also share a common ground with this board.

VIN

This is the main 2.6 – 5.5 V power supply connection. The SCL and SDA level shifters pull the I²C bus high bits up to this level.

3V

Regulated 3.0 V output. Almost 300 mA is available to power external components.

1V8

Regulated 1.8 V output. Almost 150 mA is available to power external components.

The data ready and interrupt pins of the L3G4200D and the LSM303DLH are not accessible on the MinIMU-9; if you need these outputs, consider using our L3G4200D carrier and LSM303DLH carrier boards.

Schematic Diagram

The above schematic shows the additional components the carrier board incorporates to make the L3G4200D and LSM303 easier to use, including the voltage regulators that allow the board to be powered from a single 2.6 – 5.5 V supply and the level-shifter circuit that allows for I²C communication at the same logic voltage level as VIN. This schematic is also available as a downloadable pdf: MinIMU-9 schematic (36k pdf).

I²C Communication

The L3G4200D and LSM303DLH readings can be queried and the devices can be configured through the I²C bus. The three sensors (the L3G4200D gyro and the LSM303DLH accelerometer and magnetometer) act as slave devices on the same I²C bus (i.e. their clock and data lines are tied together to ease communication). Additionally, level shifters on the I²C clock (SCL) and data lines (SDA) enable I²C communication with microcontrollers operating at the same voltage as VIN (2.6 – 5.5V). A detailed explanation of the protocols used by each device can be found in the L3G4200D datasheet (1MB pdf) and the LSM303DLH datasheet (599k pdf), and more detailed information about I²C in general can be found in NXP’s I²C-bus specification (371k pdf).

The gyro, accelerometer, and magnetometer each have separate slave addresses on the I²C bus. The gyro and accelerometer’s 7-bit slave addresses have their least significant bit (LSb) determined by the voltage on the SA0_G and SA0_A pins, respectively. The carrier board pulls SA0_G to 1.8 V and SA0_A to ground through 4.7kΩ resistors, setting the gyro’s slave address to 1101001b and the accelerometer’s slave address to 0011000b by default. If the gyro’s selected slave address happens to conflict with some other device on your I²C bus, you can drive SA0_G low to set the LSb to 0; similarly, you can drive SA0_A high (by connecting it to 1.8 V) to set the LSb of the accelerometer’s slave address to 1. The magnetometer’s slave address is 0011110b and cannot be changed.

In our tests of the MinIMU-9, we were able to communicate with both chips at clock frequencies up to 400 kHz; higher frequencies might work but were not tested. The chips themselves and carrier board do not meet of some requirements to make the devices compliant with I²C fast mode. They are missing 50 ns spike suppression on the clock and data lines, and additional pull-ups on the clock and data lines might also be necessary to achieve compliant signal timing characteristics.

For a demonstration of what you can do with this data, you can turn an Arduino connected to a MinIMU-9 into an attitude and heading reference system, or AHRS, with this Arduino program. It uses the data from the MinIMU-9 to calculate estimated roll, pitch, and yaw angles, and you can visualize the output of the AHRS with a 3D test program on your PC (as shown in a screenshot above). This software is based on the work of Jordi Munoz, William Premerlani, Jose Julio, and Doug Weibel.

Protocol Hints

The datasheets provide all the information you need to use the sensors on the MinIMU-9, but picking out the important details can take some time. Here are some pointers for communicating with and configuring the L3G4200D and LSM303DLH that we hope will get you up and running a little bit faster:

The gyro, accelerometer, and magnetometer are all off by default. You have to turn them on by setting the correct configuration registers.

You can read or write multiple gyro or accelerometer registers in a single I²C command by asserting the most significant bit of the register address to enable address auto-increment.

The magnetometer will not update its data until all 6 data bytes have been read during a single I²C transfer. All the bytes can be read in the same transfer using the the magnetometer’s automatic sub-address updating feature (this feature is enabled by default).

The LSM303DLH combines an accelerometer and a magnetometer made by separate manufacturers into one IC, so there are fairly significant differences in their features, functionality, and interfaces. The interface of the L3G4200D is similar to that of the accelerometer in the LSM303DLH.

Product Comparison

We carry several inertial measurement and orientation sensors. The table below compares their capabilities: