adafruit_fxos8700
¶
CircuitPython module for the NXP FXOS8700 accelerometer and magnetometer. Based on the driver from: https://github.com/adafruit/Adafruit_FXOS8700
See examples/simpletest.py for a demo of the usage.
Author(s): Tony DiCola
Implementation Notes¶
Hardware:
Adafruit Precision NXP 9-DOF Breakout Board - FXOS8700 + FXAS21002 (Product ID: 3463)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_fxos8700.FXOS8700(i2c: I2C, address: int = 31, accel_range: int = 0)[source]¶
Driver for the NXP FXOS8700 accelerometer and magnetometer.
- Parameters:
Quickstart: Importing and using the device
Here is an example of using the
FXOS8700
class. First you will need to import the libraries to use the sensorimport board import adafruit_fxos8700
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA sensor = adafruit_fxos8700.FXOS8700(i2c)
Now you have access to the
accelerometer
andmagnetometer
attributesaccel_x, accel_y, accel_z = sensor.accelerometer mag_x, mag_y, mag_z = sensor.magnetometer
- property accelerometer: List[float]¶
Read the acceleration from the accelerometer and return its X, Y, Z axis values as a list of length 3 in \(m/s^2\).
- property magnetometer: List[float]¶
Read the magnetometer values and return its X, Y, Z axis values as a list of length 3 in μTeslas.
- read_raw_accel_mag() Tuple[Tuple[int, int, int], Tuple[int, int, int]] [source]¶
Read the raw accelerometer and magnetometer readings. Returns a 2-tuple of 3-tuples:
Accelerometer X, Y, Z axis 14-bit signed raw values
Magnetometer X, Y, Z axis 16-bit signed raw values
If you want the acceleration or magnetometer values in friendly units consider using the accelerometer and magnetometer properties!