Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LSM9DS1 Class Reference
LSM9DS1 (IMU sensor) class. More...
#include <LSM9DS1.h>
Public Member Functions | |
| LSM9DS1 (PinName sda, PinName scl) | |
| Class constructor. | |
| bool | init () |
| Initialize sensor. | |
| void | read () |
| Read sensor data. | |
Data Fields | |
| float | gx |
| Gyroscope data in x-axis [rad/s]. | |
| float | gy |
| Gyroscope data in y-axis [rad/s]. | |
| float | gz |
| Gyroscope data in z-axis [rad/s]. | |
| float | ax |
| Accelerometer data in x-axis [m/s^2]. | |
| float | ay |
| Accelerometer data in y-axis [m/s^2]. | |
| float | az |
| Accelerometer data in z-axis [m/s^2]. | |
| float | mx |
| Magnetometer data in x-axis [??]. | |
| float | my |
| Magnetometer data in y-axis [??]. | |
| float | mz |
| Magnetometer data in z-axis [??]. | |
Detailed Description
LSM9DS1 (IMU sensor) class.
Example code (print accelerometer and gyroscope data on serial port every 0.2 seconds):
#include "mbed.h" #include "USBSerial.h" #include "LSM9DS1.h" USBSerial pc; LSM9DS1 imu(A4,A5); int main() { imu.init(); while(1) { imu.read(); pc.printf("Acc [m/s^2]: %.1f | %.1f | %.1f \n", imu.ax, imu.ay, imu.az); pc.printf("Gyr [rad/s]: %.1f | %.1f | %.1f \n", imu.gx, imu.gy, imu.gz); pc.printf("Mag [uT]: %.1f | %.1f | %.1f \n\n", imu.mx, imu.my, imu.mz); wait(0.2); } }
Definition at line 101 of file LSM9DS1.h.
Constructor & Destructor Documentation
| LSM9DS1 | ( | PinName | sda, |
| PinName | scl | ||
| ) |
Class constructor.
Definition at line 4 of file LSM9DS1.cpp.
Member Function Documentation
| bool init | ( | ) |
Initialize sensor.
Try to initialize sensor (return true if succeed and false if failed)
Definition at line 9 of file LSM9DS1.cpp.
| void read | ( | ) |
Read sensor data.
Definition at line 27 of file LSM9DS1.cpp.
Field Documentation
Generated on Mon Jul 18 2022 10:36:03 by
1.7.2