Fabio Bobrow / Cubli
Embed: (wiki syntax)

« Back to documentation index

LSM9DS1 Class Reference

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

float ax

Accelerometer data in x-axis [m/s^2].

Definition at line 120 of file LSM9DS1.h.

float ay

Accelerometer data in y-axis [m/s^2].

Definition at line 122 of file LSM9DS1.h.

float az

Accelerometer data in z-axis [m/s^2].

Definition at line 124 of file LSM9DS1.h.

float gx

Gyroscope data in x-axis [rad/s].

Definition at line 114 of file LSM9DS1.h.

float gy

Gyroscope data in y-axis [rad/s].

Definition at line 116 of file LSM9DS1.h.

float gz

Gyroscope data in z-axis [rad/s].

Definition at line 118 of file LSM9DS1.h.

float mx

Magnetometer data in x-axis [??].

Definition at line 126 of file LSM9DS1.h.

float my

Magnetometer data in y-axis [??].

Definition at line 128 of file LSM9DS1.h.

float mz

Magnetometer data in z-axis [??].

Definition at line 130 of file LSM9DS1.h.