#include #include #include #include #include LiquidCrystal_I2C lcd(0x27, 16, 2); Adafruit_LSM9DS1 lsm = Adafruit_LSM9DS1(); int degree = 0; sensors_event_t a, m, g, temp; void setupSensor() { // 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); } void setup() { Serial.begin(9600); while (!Serial) { delay(1); // will pause Zero, Leonardo, etc until serial console opens } Serial.println("LSM9DS1 data read demo"); // Try to initialise and warn if we couldn't detect the chip if (!lsm.begin()) { Serial.println("Oops ... unable to initialize the LSM9DS1. Check your wiring!"); while (1); } Serial.println("Found LSM9DS1 9DOF"); setupSensor(); lcd.init(); lcd.backlight(); } void loop() { lsm.read(); lsm.getEvent(&a, &m, &g, &temp); degree = temp.temperature/16 + 25 + 11; //Fabricant : output 0 at 25¡C + offset and 1 degree is 000F in hexadecimal lcd.setCursor(0, 0); lcd.print("A z : "); lcd.setCursor(5, 0); lcd.print(a.acceleration.z); lcd.setCursor(9,0); lcd.print(" m/s^2"); lcd.setCursor(0,1); lcd.print("Temp : "); lcd.setCursor(7, 1); lcd.print(degree); lcd.setCursor(10,1); lcd.print(" \337C"); delay(500); }