Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Adafruit 9-DOF IMU L3GD20H + LSM303: Examples, Pinouts, and Specs

Image of Adafruit 9-DOF IMU L3GD20H + LSM303
Cirkit Designer LogoDesign with Adafruit 9-DOF IMU L3GD20H + LSM303 in Cirkit Designer

Introduction

The Adafruit 9-DOF IMU is a compact and versatile inertial measurement unit (IMU) that combines a 3-axis gyroscope (L3GD20H) with a 3-axis accelerometer and magnetometer (LSM303). This sensor is capable of providing nine degrees of freedom (DOF) by measuring linear acceleration, angular rate, and magnetic fields in all three dimensions. It is commonly used in applications such as drone flight control, robotics, motion sensing, and orientation tracking.

Explore Projects Built with Adafruit 9-DOF IMU L3GD20H + LSM303

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Raspberry Pi 5-Based Multi-Sensor IMU System with MPU-6050 and LSM303c
Image of GRS: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
This circuit integrates a Raspberry Pi 5 with multiple sensors, including an MPU-6050 accelerometer and gyroscope, and an LSM303c 6DOF IMU, to collect and process motion and orientation data. The Raspberry Pi serves as the central processing unit, interfacing with the sensors via GPIO pins and providing power to them.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Ethernet with LSM303DLHC Accelerometer and Compass Interface
Image of Compass: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
This circuit connects an Adafruit LSM303DLHC Triple-axis Accelerometer+Magnetometer (Compass) to an Arduino Board Ethernet using I2C communication protocol. The SCL and SDA pins of the sensor are connected to the A5 and A4 pins of the Arduino, respectively, for serial clock and data transfer. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Battery-Powered Arduino UNO with BNO085 IMU and Bluetooth HC-06 for Orientation Tracking
Image of bno085: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
This circuit integrates an Arduino UNO with an Adafruit BNO085 9-DOF Orientation IMU and a Bluetooth HC-06 module. The Arduino reads orientation data from the IMU via I2C and transmits it over Bluetooth, powered by a 7.4V battery.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Controlled Multi-MPU6050 and MPU9250 IMU Data Aggregator
Image of gant vr: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
This circuit features an ESP32 microcontroller interfaced with multiple MPU-6050 sensors and a single MPU-9250 sensor through an Adafruit TCA9548A I2C multiplexer, allowing for the reading of multiple inertial measurement units (IMUs) over the same I2C bus. The ESP32 collects and processes acceleration and gyroscopic data from the sensors to calculate angles in the X and Y axes. Power management is handled by a TP4056 charging module and an AMS1117 voltage regulator, which together with two 18650 Li-ion batteries, provide a stable power supply for the microcontroller and sensors.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Adafruit 9-DOF IMU L3GD20H + LSM303

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of GRS: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
Raspberry Pi 5-Based Multi-Sensor IMU System with MPU-6050 and LSM303c
This circuit integrates a Raspberry Pi 5 with multiple sensors, including an MPU-6050 accelerometer and gyroscope, and an LSM303c 6DOF IMU, to collect and process motion and orientation data. The Raspberry Pi serves as the central processing unit, interfacing with the sensors via GPIO pins and providing power to them.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Compass: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
Arduino Ethernet with LSM303DLHC Accelerometer and Compass Interface
This circuit connects an Adafruit LSM303DLHC Triple-axis Accelerometer+Magnetometer (Compass) to an Arduino Board Ethernet using I2C communication protocol. The SCL and SDA pins of the sensor are connected to the A5 and A4 pins of the Arduino, respectively, for serial clock and data transfer. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of bno085: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
Battery-Powered Arduino UNO with BNO085 IMU and Bluetooth HC-06 for Orientation Tracking
This circuit integrates an Arduino UNO with an Adafruit BNO085 9-DOF Orientation IMU and a Bluetooth HC-06 module. The Arduino reads orientation data from the IMU via I2C and transmits it over Bluetooth, powered by a 7.4V battery.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of gant vr: A project utilizing Adafruit 9-DOF IMU L3GD20H + LSM303 in a practical application
ESP32-Controlled Multi-MPU6050 and MPU9250 IMU Data Aggregator
This circuit features an ESP32 microcontroller interfaced with multiple MPU-6050 sensors and a single MPU-9250 sensor through an Adafruit TCA9548A I2C multiplexer, allowing for the reading of multiple inertial measurement units (IMUs) over the same I2C bus. The ESP32 collects and processes acceleration and gyroscopic data from the sensors to calculate angles in the X and Y axes. Power management is handled by a TP4056 charging module and an AMS1117 voltage regulator, which together with two 18650 Li-ion batteries, provide a stable power supply for the microcontroller and sensors.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

General Specifications

  • Supply Voltage (VDD): 2.16V to 3.6V
  • Interface: I2C/SPI (selectable)
  • Operating Temperature Range: -40°C to +85°C

L3GD20H Gyroscope Specifications

  • Sensitivity: ±245/±500/±2000 dps
  • Supply Voltage: 2.2V to 3.6V
  • Communication: I2C/SPI

LSM303 Accelerometer and Magnetometer Specifications

  • Accelerometer Sensitivity: ±2/±4/±8/±16 g
  • Magnetometer Sensitivity: ±1.3/±1.9/±2.5/±4.0/±4.7/±5.6/±8.1 gauss
  • Supply Voltage: 2.16V to 3.6V
  • Communication: I2C

Pin Configuration and Descriptions

Pin Number Name Description
1 VIN Supply voltage (2.16V to 3.6V)
2 GND Ground
3 SCL I2C clock / SPI clock
4 SDA I2C data / SPI data input (MOSI)
5 SA0 I2C address selection / SPI data output (MISO)
6 SDO SPI data output for gyroscope / I2C address selection for LSM303
7 CS_G Chip select for gyroscope (active low)
8 CS_XM Chip select for accelerometer/magnetometer (active low)

Usage Instructions

Integration with Arduino

To use the Adafruit 9-DOF IMU with an Arduino UNO, follow these steps:

  1. Connect the IMU pins to the Arduino:

    • VIN to 3.3V
    • GND to GND
    • SCL to A5 (SCL)
    • SDA to A4 (SDA)
    • SA0 to GND or 3.3V (depending on the desired I2C address)
    • CS_G and CS_XM are not used in I2C mode
  2. Install the Adafruit Unified Sensor and 9-DOF libraries using the Arduino Library Manager.

  3. Use the following sample code to read data from the sensor:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_L3GD20_U.h>
#include <Adafruit_LSM303_U.h>

/* Assign a unique ID to the sensors */
Adafruit_L3GD20_Unified gyro = Adafruit_L3GD20_Unified(20);
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30);
Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(40);

void setup(void) {
  Serial.begin(9600);
  if(!gyro.begin() || !accel.begin() || !mag.begin()) {
    /* There was a problem detecting the sensors ... check your connections */
    Serial.println("Ooops, no sensor detected ... Check your wiring!");
    while(1);
  }
}

void loop(void) {
  /* Get a new sensor event */
  sensors_event_t event;
  
  gyro.getEvent(&event);
  /* Display the results (gyroscope data is in degrees per second) */
  Serial.print("X: "); Serial.print(event.gyro.x); Serial.print(" ");
  Serial.print("Y: "); Serial.print(event.gyro.y); Serial.print(" ");
  Serial.print("Z: "); Serial.print(event.gyro.z); Serial.println(" dps");

  accel.getEvent(&event);
  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
  Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
  Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.println(" m/s^2");

  mag.getEvent(&event);
  /* Display the results (magnetic vector values are in micro-Tesla (uT)) */
  Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print(" ");
  Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" ");
  Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.println(" uT");

  delay(500);
}

Best Practices

  • Ensure that the power supply is stable and within the specified voltage range.
  • Use pull-up resistors on the I2C lines if multiple devices are connected to the bus.
  • Avoid placing the sensor near strong magnetic fields to prevent interference with the magnetometer.

Troubleshooting and FAQs

Common Issues

  • Sensor not detected: Check the wiring and ensure that the correct I2C address is being used.
  • Inaccurate readings: Calibrate the sensor as per the datasheet instructions, and ensure it's away from magnetic interference.

FAQs

Q: Can I use this sensor with a 5V microcontroller? A: Yes, but ensure that the logic levels are shifted down to 3.3V to avoid damaging the sensor.

Q: How do I change the I2C address? A: The I2C address can be changed by connecting the SA0 pin to either GND or 3.3V.

Q: What is the default I2C address? A: The default I2C address for the L3GD20H is 0x6B and for the LSM303 is 0x1E (accelerometer) and 0x1E (magnetometer) when SA0 is connected to GND.

For further assistance, consult the Adafruit support forums or the sensor datasheets.