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:

Software and Dependencies:

class adafruit_fxos8700.FXOS8700(i2c: I2C, address: int = 31, accel_range: int = 0)[source]

Driver for the NXP FXOS8700 accelerometer and magnetometer.

Parameters:
  • i2c (I2C) – The I2C bus the device is connected to

  • address (int) – The I2C device address. Defaults to 0x1F

  • accel_range (int) – Device range. Defaults to 0x00.

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 sensor

import board
import adafruit_fxos8700

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = adafruit_fxos8700.FXOS8700(i2c)

Now you have access to the accelerometer and magnetometer attributes

accel_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!