http://raspberrypi.stackexchange.com/qu ... spberry-pi
I now have a device at /dev/i2c-3, so the above steps work. I can also identify the BNO055 on the i2c-3 bus:
Code: Select all
pi@robotpi:~/projects/Adafruit_Python_BNO055 $ i2cdetect 3
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-3.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
https://github.com/adafruit/Adafruit_Python_BNO055
I downloaded and installed that library. Using the simpletest.py app, I ran into the following expected problem:
pi@robotpi:~/projects/Adafruit_Python_BNO055/examples $ python simpletest.py
Traceback (most recent call last):
File "simpletest.py", line 46, in <module>
if not bno.begin():
File "build/bdist.linux-armv7l/egg/Adafruit_BNO055/BNO055.py", line 383, in begin
File "build/bdist.linux-armv7l/egg/Adafruit_BNO055/BNO055.py", line 359, in _config_mode
File "build/bdist.linux-armv7l/egg/Adafruit_BNO055/BNO055.py", line 417, in set_mode
File "build/bdist.linux-armv7l/egg/Adafruit_BNO055/BNO055.py", line 312, in _write_byte
File "build/bdist.linux-armv7l/egg/Adafruit_BNO055/BNO055.py", line 259, in _serial_send
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 484, in write
raise writeTimeoutError
serial.serialutil.SerialTimeoutException: Write timeout
Obviously this is expected because I knew I needed to tell it not to use the default for Raspberry PI (serial bus), and I knew that I needed to tell itwhat I2C bus to use. So, I attempted to do this in simpletest.py:
Code: Select all
# Create and configure the BNO sensor connection. Make sure only ONE of the
# below 'bno = ...' lines is uncommented:
# Raspberry Pi configuration with serial UART and RST connected to GPIO 18:
#bno = BNO055.BNO055(serial_port='/dev/ttyAMA0', rst=18)
bno = BNO055.BNO055(i2c=3, rst=18)
Code: Select all
pi@robotpi:~/projects/Adafruit_Python_BNO055/examples $ python simpletest.py
Traceback (most recent call last):
File "simpletest.py", line 35, in <module>
bno = BNO055.BNO055(i2c=3, rst=18)
File "build/bdist.linux-armv7l/egg/Adafruit_BNO055/BNO055.py", line 246, in __init__
AttributeError: 'int' object has no attribute 'get_i2c_device'
Code: Select all
if serial_port is not None:
# Use serial communication if serial_port name is provided.
# Open the serial port at 115200 baud, 8N1. Add a 5 second timeout
# to prevent hanging if device is disconnected.
self._serial = serial.Serial(serial_port, 115200, timeout=serial_timeout_sec,
writeTimeout=serial_timeout_sec)
else:
# Use I2C if no serial port is provided.
# Assume we're using platform's default I2C bus if none is specified.
if i2c is None:
import Adafruit_GPIO.I2C as I2C
i2c = I2C
# Save a reference to the I2C device instance for later communication.
self._i2c_device = i2c.get_i2c_device(address, **kwargs)
I've modified the device to use i2c as a bus number and pass that to the initialization function for the BNO055. This allows the bus to be overridden.
https://github.com/johnweber/Adafruit_P ... 2c70e7f56f
After doing this, the SOC on the Raspberry Pi can now communicate with the BNO055 using the i2c-gpio device driver. However, this is my first experience with this code and I'm not sure if the below output is completely good.
Code: Select all
pi@robotpi:~/projects/Adafruit_Python_BNO055/examples $ python simpletest.py
System status: 5
Self test result (0x0F is normal): 0x0D
Software version: 785
Bootloader version: 21
Accelerometer ID: 0xFB
Magnetometer ID: 0x32
Gyroscope ID: 0x0F
Reading BNO055 data, press Ctrl-C to quit...
Heading=0.00 Roll=0.00 Pitch=0.00 Sys_cal=0 Gyro_cal=0 Accel_cal=0 Mag_cal=0
Heading=0.00 Roll=-1.56 Pitch=0.25 Sys_cal=0 Gyro_cal=3 Accel_cal=0 Mag_cal=0
Heading=0.00 Roll=-1.56 Pitch=0.25 Sys_cal=0 Gyro_cal=3 Accel_cal=0 Mag_cal=0
Heading=0.00 Roll=-1.56 Pitch=0.25 Sys_cal=0 Gyro_cal=3 Accel_cal=0 Mag_cal=0
Heading=0.00 Roll=-1.56 Pitch=0.25 Sys_cal=0 Gyro_cal=3 Accel_cal=0 Mag_cal=0