The SparkFun Qwiic 6DoF LSM6DSO is a versatile and powerful sensor module that combines a 3-axis accelerometer and a 3-axis gyroscope into a single package. This sensor is ideal for applications requiring motion detection, such as gesture control, gaming, inertial measurement units (IMUs), and navigation systems. Its Qwiic connector system enables easy daisy-chaining and quick prototyping without the need for soldering.
Pin Name | Description |
---|---|
GND | Ground |
VCC | Supply Voltage (1.71V to 3.6V) |
SDA | I2C Data Line |
SCL | I2C Clock Line |
INT1 | Interrupt 1 (configurable) |
INT2 | Interrupt 2 (configurable) |
AD0/SDO | I2C Address Selection/Serial Data Out for SPI |
CS | Chip Select for SPI (not used in Qwiic) |
0x6A
. If you need to change the address, you can connect the AD0/SDO pin to VCC or GND.#include <Wire.h> // Include the I2C library (required)
// LSM6DSO I2C address is 0x6A if SA0 pin is GND, 0x6B if SA0 pin is VCC
#define LSM6DSO_ADDRESS 0x6A
// Register addresses
#define WHO_AM_I_REG 0x0F
#define CTRL1_XL 0x10
#define CTRL2_G 0x11
#define OUTX_L_G 0x22
// Initialize I2C communication
void setup() {
Wire.begin(); // Join the I2C bus as master
Serial.begin(9600); // Start serial communication at 9600 baud rate
// Check if LSM6DSO is connected properly
Wire.beginTransmission(LSM6DSO_ADDRESS);
Wire.write(WHO_AM_I_REG);
Wire.endTransmission();
Wire.requestFrom(LSM6DSO_ADDRESS, 1);
if(Wire.read() == 0x6C) {
Serial.println("LSM6DSO is online...");
} else {
Serial.println("Device not found. Check wiring.");
}
// Configure the accelerometer and gyroscope
Wire.beginTransmission(LSM6DSO_ADDRESS);
Wire.write(CTRL1_XL);
Wire.write(0x50); // 1.66 kHz, 2g, normal mode
Wire.write(CTRL2_G);
Wire.write(0x50); // 1.66 kHz, 250 dps, normal mode
Wire.endTransmission();
}
// Read sensor data
void loop() {
int16_t gx, gy, gz;
Wire.beginTransmission(LSM6DSO_ADDRESS);
Wire.write(OUTX_L_G);
Wire.endTransmission();
Wire.requestFrom(LSM6DSO_ADDRESS, 6);
if(Wire.available() == 6) {
gx = Wire.read() | Wire.read() << 8;
gy = Wire.read() | Wire.read() << 8;
gz = Wire.read() | Wire.read() << 8;
// Print the readings
Serial.print("Gx: "); Serial.print(gx); Serial.print(" ");
Serial.print("Gy: "); Serial.print(gy); Serial.print(" ");
Serial.print("Gz: "); Serial.println(gz);
}
delay(1000); // Wait for a second before the next reading
}
Q: Can I use the LSM6DSO with a 5V microcontroller? A: Yes, but ensure that the sensor's VCC is connected to a voltage within its operating range (1.71V to 3.6V). Use logic level converters for I2C lines if necessary.
Q: How can I change the I2C address of the sensor? A: The I2C address can be changed by connecting the AD0/SDO pin to VCC or GND.
Q: What is the purpose of the INT1 and INT2 pins? A: These pins can be configured to output interrupt signals for various functions such as data ready, free-fall detection, or orientation change.
Q: How do I calibrate the sensor? A: Calibration involves capturing readings at a known orientation and adjusting subsequent readings accordingly. This process can be complex and may require additional software or algorithms.
For further assistance, please refer to the SparkFun Qwiic 6DoF LSM6DSO datasheet or contact technical support.