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!
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.
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.
This circuit integrates a Raspberry Pi Zero with an Adafruit ADS1115 16-bit ADC and an Adafruit BNO085 9-DOF Orientation IMU Fusion sensor. The Raspberry Pi reads analog signals from a flex resistor through the ADC and gathers orientation data from the IMU sensor, enabling it to process both analog and motion data.
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.
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:
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
Install the Adafruit Unified Sensor and 9-DOF libraries using the Arduino Library Manager.
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.