The Adafruit LIS3MDL + LSM6DS33 is a comprehensive 9 Degrees of Freedom (DoF) Inertial Measurement Unit (IMU) that integrates a 3-axis accelerometer, 3-axis gyroscope, and 3-axis magnetometer. This module is designed for motion tracking and orientation sensing in a wide range of applications, including robotics, drones, gaming devices, and virtual reality systems. Its small form factor and low power consumption make it ideal for portable and battery-powered devices.
Pin Number | Name | Description |
---|---|---|
1 | VIN | Supply voltage (1.9V to 3.6V) |
2 | GND | Ground connection |
3 | SCL | I2C clock line |
4 | SDA | I2C data line |
5 | INT1 | Interrupt output for LSM6DS33 |
6 | INT2 | Interrupt output for LIS3MDL |
7 | ADDR | I2C address selection for LSM6DS33 |
8 | ID | Device identification pin |
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LIS3MDL.h>
#include <Adafruit_LSM6DS33.h>
// Create sensor instances
Adafruit_LIS3MDL lis3mdl = Adafruit_LIS3MDL();
Adafruit_LSM6DS33 lsm6ds33 = Adafruit_LSM6DS33();
void setup() {
Serial.begin(115200);
// Initialize the LIS3MDL magnetometer
if (!lis3mdl.begin_I2C()) {
Serial.println("Failed to initialize LIS3MDL!");
while (1);
}
// Initialize the LSM6DS33 accelerometer and gyroscope
if (!lsm6ds33.begin_I2C()) {
Serial.println("Failed to initialize LSM6DS33!");
while (1);
}
}
void loop() {
// Read and print accelerometer and gyroscope data
lsm6ds33.read();
Serial.print("Accel X: "); Serial.print(lsm6ds33.acceleration.x);
Serial.print(" Y: "); Serial.print(lsm6ds33.acceleration.y);
Serial.print(" Z: "); Serial.println(lsm6ds33.acceleration.z);
Serial.print("Gyro X: "); Serial.print(lsm6ds33.gyro.x);
Serial.print(" Y: "); Serial.print(lsm6ds33.gyro.y);
Serial.print(" Z: "); Serial.println(lsm6ds33.gyro.z);
// Read and print magnetometer data
lis3mdl.read();
Serial.print("Mag X: "); Serial.print(lis3mdl.magnetic.x);
Serial.print(" Y: "); Serial.print(lis3mdl.magnetic.y);
Serial.print(" Z: "); Serial.println(lis3mdl.magnetic.z);
delay(1000); // Delay for readability
}
Q: Can I use this IMU module with a 5V microcontroller? A: While the IMU module operates at 1.9V to 3.6V, many 5V microcontrollers have I2C lines that are 3.3V tolerant. Use a logic level converter if necessary.
Q: How do I change the I2C address of the LSM6DS33? A: The I2C address can be changed by connecting the ADDR pin to either GND or VIN, depending on the desired address.
Q: What is the default I2C address for the sensors? A: The default I2C address for the LIS3MDL is 0x1E and for the LSM6DS33 is 0x6B (ADDR pin to GND) or 0x6A (ADDR pin to VIN).
Q: How do I calibrate the magnetometer? A: Calibration typically involves rotating the sensor in various orientations and using software to record and compensate for any biases or distortions. Refer to the Adafruit guide for detailed calibration instructions.
For further assistance, consult the Adafruit support forums or the detailed datasheets for the LIS3MDL and LSM6DS33 sensors.