Description

⚙ Hardware Needed


📚 External Libraries Needed


None

📑 Code


Using only built-in libraries:

'''
Prints accelerometer data from the on-board Bosh BMX160 IMU device connected via I2C

M.Holliday 2019
'''

import time
import board
import busio
import adafruit_lsm9ds1

# I2C connection:
i2c = busio.I2C(board.SCL, board.SDA)
sensor = bmx160.BMX160_I2C(i2c)

while True:
	x, y, z = sensor.acceleration
	print('x:{}, y:{}, z:{}'.format(x,y,z))

Using the pycubed.py helper library:

See the Hardware Specific example: IMU

Details


I2C is a communication protocol using 2 wires. Read more here and here.

↩ Return Home

↩ Return to Resources

↩ Return to Code Examples