/ examples / bno055_i2c-gpio_simpletest.py
bno055_i2c-gpio_simpletest.py
 1  """
 2  This example demonstrates how to instantiate the
 3  Adafruit BNO055 Sensor using this library and just
 4  the I2C bus number.
 5  This example will only work on a Raspberry Pi
 6  and does require the i2c-gpio kernel module to be
 7  installed and enabled. Most Raspberry Pis will
 8  already have it installed, however most do not
 9  have it enabled. You will have to manually enable it
10  """
11  
12  import time
13  from adafruit_extended_bus import ExtendedI2C as I2C
14  import adafruit_bno055
15  
16  # To enable i2c-gpio, add the line `dtoverlay=i2c-gpio` to /boot/config.txt
17  # Then reboot the pi
18  
19  # Create library object using our Extended Bus I2C port
20  # Use `ls /dev/i2c*` to find out what i2c devices are connected
21  i2c = I2C(1)  # Device is /dev/i2c-1
22  sensor = adafruit_bno055.BNO055_I2C(i2c)
23  
24  while True:
25      print("Temperature: {} degrees C".format(sensor.temperature))
26      print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
27      print("Magnetometer (microteslas): {}".format(sensor.magnetic))
28      print("Gyroscope (rad/sec): {}".format(sensor.gyro))
29      print("Euler angle: {}".format(sensor.euler))
30      print("Quaternion: {}".format(sensor.quaternion))
31      print("Linear acceleration (m/s^2): {}".format(sensor.linear_acceleration))
32      print("Gravity (m/s^2): {}".format(sensor.gravity))
33      print()
34  
35      time.sleep(1)