Datasheet
Begin!
To initialize the sensor, call lsm.begin() which will check the sensor can be found. It returns true/false depending on
these checks. We suggest you wrap begin() in a statement that will check if the sensor was located:
Set Ranges
These chips have tons of registers, we basically provide interface code for the most useful stuff, such as setting the
range. Each subsensor has it's own range. Higher ranges have less precision but can measure larger movements!
Set up the ranges with the setup functions:
Choose whichever range you like, after you begin() the sensor!
Read data
Read data using the Adafruit_Sensor API by first creating four events, one for each sub-sensor:
Then pass these into the getEvent function
The data is snapshotted at once, so you can read and manage the data later.
Adafruit_LSM9DS1 lsm = Adafruit_LSM9DS1(LSM9DS1_SCK, LSM9DS1_MISO, LSM9DS1_MOSI, LSM9DS1_XGCS, LSM9DS1_MCS);
if(!lsm.begin())
{
/* There was a problem detecting the LSM9DS1 ... check your connections */
Serial.print(F("Ooops, no LSM9DS1 detected ... Check your wiring!"));
while(1);
}
// 1.) Set the accelerometer range
lsm.setupAccel(lsm.LSM9DS1_ACCELRANGE_2G);
//lsm.setupAccel(lsm.LSM9DS1_ACCELRANGE_4G);
//lsm.setupAccel(lsm.LSM9DS1_ACCELRANGE_8G);
//lsm.setupAccel(lsm.LSM9DS1_ACCELRANGE_16G);
// 2.) Set the magnetometer sensitivity
lsm.setupMag(lsm.LSM9DS1_MAGGAIN_4GAUSS);
//lsm.setupMag(lsm.LSM9DS1_MAGGAIN_8GAUSS);
//lsm.setupMag(lsm.LSM9DS1_MAGGAIN_12GAUSS);
//lsm.setupMag(lsm.LSM9DS1_MAGGAIN_16GAUSS);
// 3.) Setup the gyroscope
lsm.setupGyro(lsm.LSM9DS1_GYROSCALE_245DPS);
//lsm.setupGyro(lsm.LSM9DS1_GYROSCALE_500DPS);
//lsm.setupGyro(lsm.LSM9DS1_GYROSCALE_2000DPS);
sensors_event_t accel, mag, gyro, temp;
lsm.getEvent(&accel, &mag, &gyro, &temp);
© Adafruit Industries
https://learn.adafruit.com/adafruit-lsm9ds1-accelerometer-plus-gyro-plus-
magnetometer-9-dof-breakout
Page 14 of 23










