The LSM9DS0 is a versatile 9 Degrees of Freedom (DOF) sensor module that integrates a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer. This sensor is capable of providing precise measurements of motion and orientation, making it an ideal choice for applications in robotics, drones, virtual reality, and other projects requiring motion detection and orientation tracking.
Pin Number | Pin Name | Description |
---|---|---|
1 | VDD | Power supply voltage (2.4V to 3.6V) |
2 | GND | Ground |
3 | SCL/SPC | I2C clock / SPI serial clock |
4 | SDA/SDI | I2C data / SPI serial data in |
5 | SA0/SDO | I2C address selection / SPI serial data out |
6 | CS_AG | Accelerometer and gyroscope chip select (active low) |
7 | CS_M | Magnetometer chip select (active low) |
8 | DRDY_M | Magnetometer data ready output (active high) |
9 | DRDY_AG | Accelerometer and gyroscope data ready output (active high) |
10 | DEN_AG | Accelerometer and gyroscope data enable (active high) |
#include <Wire.h>
#include <LSM9DS0.h>
LSM9DS0 sensor(Wire, 0x6B, 0x1D);
void setup() {
Serial.begin(9600);
sensor.begin();
}
void loop() {
sensor.readGyro();
sensor.readAccel();
sensor.readMag();
// Print the sensor values
Serial.print("Gyro (X, Y, Z): ");
Serial.print(sensor.gx); Serial.print(", ");
Serial.print(sensor.gy); Serial.print(", ");
Serial.println(sensor.gz);
Serial.print("Accel (X, Y, Z): ");
Serial.print(sensor.ax); Serial.print(", ");
Serial.print(sensor.ay); Serial.print(", ");
Serial.println(sensor.az);
Serial.print("Mag (X, Y, Z): ");
Serial.print(sensor.mx); Serial.print(", ");
Serial.print(sensor.my); Serial.print(", ");
Serial.println(sensor.mz);
delay(1000); // Update every second
}
Q: Can I use the LSM9DS0 with a 5V microcontroller like Arduino UNO? A: Yes, but ensure that the sensor's VDD is connected to a 3.3V output, and use logic level converters for I2C/SPI if necessary.
Q: How do I know if the sensor is functioning correctly? A: Run the example code provided and observe the serial output. If you receive data that changes when you move the sensor, it is functioning correctly.
Q: What is the default I2C address of the LSM9DS0? A: The default I2C address for the accelerometer and gyroscope is 0x6B, and for the magnetometer, it is 0x1D. The SA0/SDO pin can modify these addresses if required.