LSM6DSOX and ISM330DHC 6 DoF IMU Created by Bryan Siepert Last updated on 2020-01-28 01:19:32 AM UTC
Overview Behold, the ST LSM6DSOX: The latest in a long line of quality Accelerometer+Gyroscope 6-DOF IMUs from ST. Along with the LSM6DSOX, this guide will cover the industrial version, the ISM330DHCX. Both are pin-compatible and are nearly code-compatible - we'll be using the same library code and wiring diagrams to connect to both In the ISM330DHCX the sensing elements of the accelerometer and of the gyroscope are implemented on the same silicon die, thus guaranteeing superior stability and robustness.
Both sensors are great IMU sensors with 6 degrees of freedom - 3 degrees each of linear acceleration and angular velocity at varying rates within a respectable range. For the accelerometer: ±2/±4/±8/±16 g at 1.6 Hz to 6.7KHz update rate. For the gyroscope: ±125/±250/±500/±1000/±2000 dps (plus ±4000 dps for the ISM330) at 12.5 Hz to 6.7 KHz.
Additionally since it speaks I2C you can easily connect it up with two wires (plus power and ground!). We've even included SparkFun qwiic (https://adafru.it/Fpw) compatible STEMMA QT (https://adafru.it/Ft4) connectors for the I2C bus so you don't even need to solder! Just wire up to your favorite micro with a plug-and-play cable to get 6 DoF data ASAP. © Adafruit Industries https://learn.adafruit.
Pinouts Power Pins Vin - this is the power pin. Since the sensor chip uses 3 VDC, we have included a voltage regulator on board that will take 3-5VDC and safely convert it down. To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V microcontroller like Arduino, use 5V 3Vo - this is the 3.
SDI - this is also the Serial Data In / Master Out Slave In pin, for data sent from your processor to the LSM6DSOX or ISM330DHCX CS - this is the Chip Select pin, drop it low to start an SPI transaction. Its an input to the chip If you want to connect multiple LSM6DSOX's or ISM330DHCX's to one microcontroller, have them share the SDI, SDO and SCK pins. Then assign each one a unique CS pin. Other Pins INT1 -This is the primary interrupt pin.
Arduino I2C Wiring Use this wiring if you want to connect via I2C interface By default, theI2C address is 0x6A. If you add a jumper from DO to 3.3V the address will change to 0x6B Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
Connect Vin to the power supply, 3V or 5V is fine.
Finally follow the same process for the Adafruit Unified Sensor library: Load Example Open up File -> Examples -> Adafruit LSM6DS -> adafruit_lsm6dsox_test and upload to your Arduino wired up to the sensor. Depending on whether you are using I2C or SPI, change the pin names and comment or uncomment the following lines. if (!lsm6dsox.begin_I2C()) { //if (!lsm6dsox.begin_SPI(LPS_CS)) { //if (!lsm6dsox.
#define LSM_MISO 12 #define LSM_MOSI 11 Adafruit_LSM6DSOX sox; void setup(void) { Serial.begin(115200); while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens Serial.println("Adafruit LSM6DSOX test!"); if (!sox.begin_I2C()) { // if (!sox.begin_SPI(LSM_CS)) { // if (!sox.begin_SPI(LSM_CS, LSM_SCK, LSM_MISO, LSM_MOSI)) { // Serial.println("Failed to find LSM6DSOX chip"); while (1) { delay(10); } } Serial.println("LSM6DSOX Found!"); // sox.
} // sox.setAccelDataRate(LSM6DS_RATE_12_5_HZ); Serial.print("Accelerometer data rate set to: "); switch (sox.getAccelDataRate()) { case LSM6DS_RATE_SHUTDOWN: Serial.println("0 Hz"); break; case LSM6DS_RATE_12_5_HZ: Serial.println("12.5 Hz"); break; case LSM6DS_RATE_26_HZ: Serial.println("26 Hz"); break; case LSM6DS_RATE_52_HZ: Serial.println("52 Hz"); break; case LSM6DS_RATE_104_HZ: Serial.println("104 Hz"); break; case LSM6DS_RATE_208_HZ: Serial.println("208 Hz"); break; case LSM6DS_RATE_416_HZ: Serial.
break; case LSM6DS_RATE_416_HZ: Serial.println("416 Hz"); break; case LSM6DS_RATE_833_HZ: Serial.println("833 Hz"); break; case LSM6DS_RATE_1_66K_HZ: Serial.println("1.66 KHz"); break; case LSM6DS_RATE_3_33K_HZ: Serial.println("3.33 KHz"); break; case LSM6DS_RATE_6_66K_HZ: Serial.println("6.66 KHz"); break; } } void loop() { // /* Get a new normalized sensor event */ sensors_event_t accel; sensors_event_t gyro; sensors_event_t temp; sox.getEvent(&accel, &gyro, &temp); Serial.print("\t\tTemperature "); Seria
// // // // // // // Serial.print(","); Serial.print(accel.acceleration.z); Serial.print(","); Serial.print(gyro.gyro.x); Serial.print(","); Serial.print(gyro.gyro.y); Serial.print(","); Serial.print(gyro.gyro.z); Serial.println(); delayMicroseconds(10000); } © Adafruit Industries https://learn.adafruit.
Arduino Docs Arduino Docs (https://adafru.it/IAQ) © Adafruit Industries https://learn.adafruit.
Python & CircuitPython It's easy to use the LSM6DSOX or ISM330DHCX sensors with Python and CircuitPython, and the Adafruit CircuitPython LSM6DS (https://adafru.it/Iec) module. This module allows you to easily write Python code that reads measurements from the accelerometer and gyro, and will work with either sensor.
Pi 3V to sensor VCC (red wire) Pi GND to sensor GND (black wire) Pi SCL to sensor SCL (yellow wire) Pi SDA to sensor SDA (blue wire) CircuitPython Installation of LSM6DS Library You'll need to install the Adafruit CircuitPython LSM6DS (https://adafru.it/Iec) library on your CircuitPython board. This library works with the LSM6DSOX, LSM6DS33, or ISM330DHCX First make sure you are running the latest version of Adafruit CircuitPython (https://adafru.it/Amd) for your board.
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready (https://adafru.
import time import board import busio from adafruit_lsm6ds import LSM6DSOX i2c = busio.I2C(board.SCL, board.SDA) sensor = LSM6DSOX(i2c) while True: print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (sensor.acceleration)) print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s" % (sensor.gyro)) print("") time.sleep(0.5) © Adafruit Industries https://learn.adafruit.
Python Docs Python Docs (https://adafru.it/Igb) © Adafruit Industries https://learn.adafruit.
Downloads Files LSM6DSOX Datasheet (https://adafru.it/HFw) ISM330DHCX Datasheet (https://adafru.it/HFx) EagleCAD files on GitHub (https://adafru.it/HFy) Fritzing object in Adafruit Fritzing Library (https://adafru.it/HFz) Schematic The schematic is identical for the LSM6DSOX and ISM330DHCX Fab Print The fabrication print is identical for the LSM6DSOX and ISM330DHCX © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2020-01-28 01:19:32 AM UTC Page 23 of 23