Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-fxas21002c
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-fxas21002c
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-fxas21002c
Usage Example¶
import time
import board
import busio
import adafruit_fxas21002c
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_fxas21002c.FXAS21002C(i2c)
while True:
gyro_x, gyro_y, gyro_z = sensor.gyroscope
print('Gyroscope (radians/s): ({0:0.3f}, {1:0.3f}, {2:0.3f})'.format(gyro_x, gyro_y, gyro_z))
time.sleep(1.0)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Simple demo of the FXAS21002C gyroscope.
# Will print the gyroscope values every second.
import time
import board
import busio
import adafruit_fxas21002c
# Initialize I2C bus and device.
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_fxas21002c.FXAS21002C(i2c)
# Optionally create the sensor with a different gyroscope range (the
# default is 250 DPS, but you can use 500, 1000, or 2000 DPS values):
# sensor = adafruit_fxas21002c.FXAS21002C(i2c, gyro_range=adafruit_fxas21002c.GYRO_RANGE_500DPS)
# sensor = adafruit_fxas21002c.FXAS21002C(i2c, gyro_range=adafruit_fxas21002c.GYRO_RANGE_1000DPS)
# sensor = adafruit_fxas21002c.FXAS21002C(i2c, gyro_range=adafruit_fxas21002c.GYRO_RANGE_2000DPS)
# Main loop will read the gyroscope values every second and print them out.
while True:
# Read gyroscope.
gyro_x, gyro_y, gyro_z = sensor.gyroscope
# Print values.
print(
"Gyroscope (radians/s): ({0:0.3f}, {1:0.3f}, {2:0.3f})".format(
gyro_x, gyro_y, gyro_z
)
)
# Delay for a second.
time.sleep(1.0)
|
adafruit_fxas21002c
¶
CircuitPython module for the NXP FXAS21002C gyroscope. Based on the driver from: https://github.com/adafruit/Adafruit_FXAS21002C
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 (2.2.0+) for the ESP8622 and M0-based boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice