LSM303D Class
- ID: lsm303d
- Name: Ultra-compact high-performance eCompass module
- Category: compass
- Manufacturer: stmicro
- Connection: i2c gpio
- Link: http://www.st.com/en/mems-and-sensors/lsm303d.html
The LSM303D is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303D has linear acceleration full scales of 2g/4g/8g/16g and a magnetic field dynamic range of 50 Gauss.
Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports only I2C operation.
This device requires 3.3v operation.
Item Index
Methods
LSM303D
-
bus
-
addr
LSM303D constructor
This driver only supports I2C.
Due to the fact that this chip is currently obsolete, we only support minimum functionality.
Parameters:
-
bus
NumberI2C bus to use
-
addr
NumberThe I2C address of the device
Returns:
The device context, or NULL if an error occurred
update
()
Update the internal stored values from sensor data. This method must be called before querying the acceleration, magnetometer, or temperature.
getMagnetometer
-
x
-
y
-
z
Return magnetometer data in micro-Teslas (uT). update() must have been called prior to calling this method.
Parameters:
-
x
Float *Pointer to a floating point value that will have the current x component placed into it
-
y
Float *Pointer to a floating point value that will have the current y component placed into it
-
z
Float *Pointer to a floating point value that will have the current z component placed into it
getMagnetometer
()
Std::vector float
Return magnetometer data in micro-Teslas (uT) in the form of a floating point vector. update() must have been called prior to calling this method.
Returns:
A floating point vector containing x, y, and z in that order
getAccelerometer
-
x
-
y
-
z
Return acceleration data in gravities. update() must have been called prior to calling this method.
Parameters:
-
x
Float *Pointer to a floating point value that will have the current x component placed into it
-
y
Float *Pointer to a floating point value that will have the current y component placed into it
-
z
Float *Pointer to a floating point value that will have the current z component placed into it
getAccelerometer
()
Std::vector float
Return acceleration data in gravities in the form of a floating point vector. update() must have been called prior to calling this method.
Returns:
A floating point vector containing x, y, and z in that order
getTemperature
()
Number
Return temperature data in degrees Celsius. NOTE: This is not the ambient room temperature. update() must have been called prior to calling this method.
Returns:
Temperature in degrees Celsius
init
-
res
Initialize the device and start operation. This function is called from the constructor so it will not typically need to be called by a user unless the device is reset. It will initialize the accelerometer and magnetometer (if enabled) to certain default running modes.
Parameters:
-
res
LSM303D_M_RES_TOne of the LSM303D_M_RES_T values. This value sets the resolution of the magnetometer. At init time, this value is set to LSM303D_M_RES_HIGH.
setAccelerometerFullScale
-
fs
Set the full scale (sensitivity) value for the accelerometer. This device supports 2G, 4G, 6G, 8G, and 16G full scale modes.
Parameters:
-
fs
LSM303D_AFS_TOne of the LSM303D_AFS_T values
setMagnetometerFullScale
-
fs
Set the full scale (sensitivity) value for the magnetometer. This device supports 2, 4, 8, and 16 Gauss full scale modes.
Parameters:
-
fs
LSM303D_MFS_TOne of the LSM303D_MFS_T values
setAccelerometerODR
-
odr
Set the accelerometer output data rate (ODR)
Parameters:
-
odr
LSM303D_AODR_TOne of the LSM303D_AODR_T values. The default set at initialization time is LSM303D_AODR_100HZ.
setMagnetometerODR
-
odr
Set the magnetometer output data rate (ODR)
Parameters:
-
odr
LSM303D_MODR_TOne of the LSM303D_MODR_T values. The default set at initialization time is LSM303D_MODR_12_5HZ.