The Adafruit 10-DOF IMU is a compact and versatile sensor module that integrates four key sensors: a gyroscope (L3GD20H), an accelerometer and magnetometer combo (LSM303), and a barometric pressure sensor (BMP180). This Inertial Measurement Unit (IMU) is designed to provide precise motion and environmental data, making it ideal for a wide range of applications including robotics, drones, navigation systems, and motion tracking.
Pin Number | Name | Description |
---|---|---|
1 | VIN | Supply voltage (3.3V to 5V) |
2 | 3Vo | 3.3V output from the voltage regulator |
3 | GND | Ground |
4 | SCL | I2C clock |
5 | SDA | I2C data |
6 | SDO/SA0 | SPI Serial Data Output (also I2C address selection for LSM303) |
7 | CS | SPI Chip Select (active low) |
To use the Adafruit 10-DOF IMU in a circuit:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_L3GD20_U.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_BMP085_U.h>
// Create sensor instances.
Adafruit_L3GD20_Unified gyro = Adafruit_L3GD20_Unified(20);
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301);
Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(30302);
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(18001);
void setup() {
Serial.begin(9600);
// Initialize the sensors.
if(!gyro.begin() || !accel.begin() || !mag.begin() || !bmp.begin()) {
Serial.println("Ooops, no sensor detected ... Check your wiring!");
while(1);
}
}
void loop() {
// Read and print the sensor values.
sensors_event_t event;
gyro.getEvent(&event);
Serial.print("Gyro X: "); Serial.print(event.gyro.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.gyro.y); Serial.print(" ");
Serial.print("Z: "); Serial.println(event.gyro.z);
accel.getEvent(&event);
Serial.print("Accel X: "); Serial.print(event.acceleration.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
Serial.print("Z: "); Serial.println(event.acceleration.z);
mag.getEvent(&event);
Serial.print("Mag X: "); Serial.print(event.magnetic.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" ");
Serial.print("Z: "); Serial.println(event.magnetic.z);
bmp.getEvent(&event);
if (event.pressure) {
float temperature;
bmp.getTemperature(&temperature);
Serial.print("Pressure: "); Serial.print(event.pressure); Serial.print(" hPa ");
Serial.print("Temp: "); Serial.println(temperature);
}
delay(500);
}
Q: Can I use this sensor with a 5V microcontroller? A: Yes, but ensure that the I2C lines are level-shifted to 3.3V.
Q: How do I change the I2C address of the LSM303? A: The I2C address can be changed by connecting the SDO/SA0 pin to either ground or VCC.
Q: What is the default I2C address for each sensor? A: The default I2C addresses are:
Q: Can I use this sensor outdoors? A: The sensor can operate in a wide range of temperatures, but it should be protected from the elements, such as water and dust.