pyupm_lsm303d module

class pyupm_lsm303d.LSM303D(bus=0, addr=30)[source]

Bases: object

API for the LSM303D 3-Axis Geomagnetic Sensor.

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.

C++ includes: lsm303d.hpp

getAccelerometer(*args)[source]

std::vector< float > getAccelerometer()

Return acceleration data in gravities in the form of a floating point vector. update() must have been called prior to calling this method.

A floating point vector containing x, y, and z in that order

getMagnetometer(*args)[source]

std::vector< float > getMagnetometer()

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.

A floating point vector containing x, y, and z in that order

getTemperature()[source]

float getTemperature()

Return temperature data in degrees Celsius. NOTE: This is not the ambient room temperature. update() must have been called prior to calling this method.

Temperature in degrees Celsius

init(res)[source]

void init(LSM303D_M_RES_T 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.

res: One 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.

std::runtime_error: on failure

setAccelerometerFullScale(fs)[source]

void setAccelerometerFullScale(LSM303D_AFS_T fs)

Set the full scale (sensitivity) value for the accelerometer. This device supports 2G, 4G, 6G, 8G, and 16G full scale modes.

fs: One of the LSM303D_AFS_T values

std::runtime_error: on failure

setAccelerometerODR(odr)[source]

void setAccelerometerODR(LSM303D_AODR_T odr)

Set the accelerometer output data rate (ODR)

odr: One of the LSM303D_AODR_T values. The default set at initialization time is LSM303D_AODR_100HZ.

std::runtime_error: on failure

setMagnetometerFullScale(fs)[source]

void setMagnetometerFullScale(LSM303D_MFS_T fs)

Set the full scale (sensitivity) value for the magnetometer. This device supports 2, 4, 8, and 16 Gauss full scale modes.

fs: One of the LSM303D_MFS_T values

std::runtime_error: on failure

setMagnetometerODR(odr)[source]

void setMagnetometerODR(LSM303D_MODR_T odr)

Set the magnetometer output data rate (ODR)

odr: One of the LSM303D_MODR_T values. The default set at initialization time is LSM303D_MODR_12_5HZ.

std::runtime_error: on failure

update()[source]

void update()

Update the internal stored values from sensor data. This method must be called before querying the acceleration, magnetometer, or temperature.

std::runtime_error: on failure

class pyupm_lsm303d.SwigPyIterator(*args, **kwargs)[source]

Bases: object

advance(n)[source]
copy()[source]
decr(n=1)[source]
distance(x)[source]
equal(x)[source]
incr(n=1)[source]
next()[source]
previous()[source]
value()[source]
class pyupm_lsm303d.byteVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303d.doubleVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303d.floatVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303d.int16Vector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303d.intVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]