Datasheet
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require
enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux
changes often, please visit the CircuitPython on Linux guide to get your computer ready (https://adafru.it/BSN)!
Once that's done, from your command line run the following command:
sudo pip3 install adafruit-circuitpython-l3gd20
If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use
CircuitPython on Python 2.x, it isn't supported!
CircuitPython & Python Usage
To demonstrate the usage of the sensor we'll initialize it and read the angular momentum values from the board's
Python REPL.
If you're using an I2C connection run the following code to import the necessary modules and initialize the I2C
connection with the sensor:
Or if you're using a SPI connection run this code instead to setup the SPI connection and sensor:
Now you're ready to read values from the sensor using any of these properties:
gyro - The x, y, z angular momentum tuple floats, rescaled appropriately for range selected.
For example to print angular momentum:
That's all there is to using the L3GD20 sensor with CircuitPython!
Full Example Code
import time
import board
import busio
import adafruit_l3gd20
I2C = busio.I2C(board.SCL, board.SDA)
SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C)
import time
import board
import busio
import digitalio
import adafruit_l3gd20
CS = digitalio.DigitalInOut(board.D5)
SPIB = busio.SPI(board.SCK, board.MOSI, board.MISO)
SENSOR = adafruit_l3gd20.L3GD20_SPI(SPIB, CS)
print('Angular momentum (rad/s): {}'.format(SENSOR.gyro))
© Adafruit Industries https://learn.adafruit.com/adafruit-triple-axis-gyro-breakout Page 13 of 18