Qwiic 6DoF (LSM6DSO) Breakout Hookup Guide
Examples
Basic Readings
There are a few examples in the library but we recommend using the Basic Readings in I2C mode to get started.
Hook up the LSM6DSO to the I2C bus, and click "File > Examples > SparkFun Qwiic 6 DoF - LSM6DSO > Basic_Readings". This example demonstrates the highest level of usage. Besides setting up the Wire library and bus, you will you have to do is create a variable of the type "LSM6DSO
", set it to .begin();
, and initialize the BASIC_SETTINGS
. To read the accelerometer, gyro, or temperature sensor using the Arduino Serial Monitor.
We'll assume that you have selected the board (in this case the Arduino Uno), COM port at this point. If you have the code open, hit the upload button. Otherwise, copy and paste the following into the Arduino IDE.
language:c
/******************************************************************************
Basic_Readings.ino
https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO
https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO_Arduino_Library
Description:
Most basic example of use.
Example using the LSM6DSO with basic settings. This sketch collects Gyro and
Accelerometer data every second, then presents it on the serial monitor.
Development environment tested:
Arduino IDE 1.8.2
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
Please review the LICENSE.md file included with this example. If you have any questions
or concerns with licensing, please contact techsupport@sparkfun.com.
Distributed as-is; no warranty is given.
******************************************************************************/
#include "SparkFunLSM6DSO.h"
#include "Wire.h"
//#include "SPI.h"
LSM6DSO myIMU; //Default constructor is I2C, addr 0x6B
void setup() {
Serial.begin(115200);
delay(500);
Wire.begin();
delay(10);
if( myIMU.begin() )
Serial.println("Ready.");
else {
Serial.println("Could not connect to IMU.");
Serial.println("Freezing");
}
if( myIMU.initialize(BASIC_SETTINGS) )
Serial.println("Loaded Settings.");
}
void loop()
{
//Get all parameters
Serial.print("\nAccelerometer:\n");
Serial.print(" X = ");
Serial.println(myIMU.readFloatAccelX(), 3);
Serial.print(" Y = ");
Serial.println(myIMU.readFloatAccelY(), 3);
Serial.print(" Z = ");
Serial.println(myIMU.readFloatAccelZ(), 3);
Serial.print("\nGyroscope:\n");
Serial.print(" X = ");
Serial.println(myIMU.readFloatGyroX(), 3);
Serial.print(" Y = ");
Serial.println(myIMU.readFloatGyroY(), 3);
Serial.print(" Z = ");
Serial.println(myIMU.readFloatGyroZ(), 3);
Serial.print("\nThermometer:\n");
Serial.print(" Degrees F = ");
Serial.println(myIMU.readTempF(), 3);
delay(1000);
}
After uploading, open the Serial Monitor and set it at 115200.