MMA8452Q Accelerometer Reference¶
- class microstacknode.accelerometer.mma8452q.MMA8452Q(i2c_bus=1, i2c_address=29)¶
Freescale MMA8452Q accelerometer.
http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf
- get_xyz(raw=False, res12=True)¶
Returns the values of the XYZ registers. By default it returns signed values at 12-bit resolution. You can specify a lower resolution (8-bit) or request the raw register values. Signed values are between the range -1 to +1 which are relative to the configured Full Scale Range (FSR).
Since we can’t read arbitary registers from this chip over I2C (because there is no decent SMBus implementation, in Python 3 at least) we have to just read the first 7 registers and pull the XYZ data from that.
Notes:
12-bit resolution from OUT MSB and OUT LSB registers:
msb lsb 8 bits 4 bits 4 bits value (12 bits) unused 8-bit resolution just from OUT MSB:
msb lsb 8 bits 8 bits value unused
Parameters: - raw (boolean (default: False)) – If True: return raw, unsigned data, else: sign values
- res12 (boolean (default: True)) – If True: read 12-bit resolution, else: 8-bit
- class microstacknode.accelerometer.mma8452q.MMA8452QRegister(address, chip)¶
An 8 bit register inside an MMA8452Q. Since the native I2C driver does not support multiple starts (SMBus) we cannot fully implement register reads. Therefore the register value is stored locally.
- microstacknode.accelerometer.mma8452q.twos_complement(value, bits)¶
Signs a value with an arbitary number of bits.