diff --git a/README.rst b/README.rst index a1dc9e1..5a93375 100644 --- a/README.rst +++ b/README.rst @@ -54,33 +54,31 @@ Usage Notes Of course, you must import the library to use it: -.. code:: python +.. code:: python3 import adafruit_bno055 -This driver takes an instantiated and active I2C object (from the `busio` or -the `bitbangio` library) as an argument to its constructor. The way to create -an I2C object depends on the board you are using. For boards with labeled SCL -and SDA pins, you can: +This driver takes an instantiated and active I2C object as an argument to its +constructor. The way to create an I2C object depends on the board you are +using. For boards with labeled SCL and SDA pins, you can: -.. code:: python +.. code:: python3 - from busio import I2C - from board import SDA, SCL + import board - i2c = I2C(SCL, SDA) + i2c = board.I2C() Once you have the I2C object, you can create the sensor object: -.. code:: python +.. code:: python3 sensor = adafruit_bno055.BNO055_I2C(i2c) And then you can start reading the measurements: -.. code:: python +.. code:: python3 print(sensor.temperature) print(sensor.euler) diff --git a/adafruit_bno055.py b/adafruit_bno055.py index 39d7e78..86bb17e 100755 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -3,13 +3,30 @@ # SPDX-License-Identifier: MIT """ -``adafruit_bno055`` - Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 +`adafruit_bno055` ======================================================================================= This is a CircuitPython driver for the Bosch BNO055 nine degree of freedom inertial measurement unit module with sensor fusion. * Author(s): Radomir Dopieralski + + +**Hardware:** + +* Adafruit `9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 + `_ (Product ID: 4646) + + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + +* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice + +* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register + """ import time import struct @@ -164,6 +181,31 @@ def __set__(self, obj, value): class BNO055: # pylint: disable=too-many-public-methods """ Base class for the BNO055 9DOF IMU sensor. + + **Quickstart: Importing and using the device** + + Here is an example of using the :class:`BNO055` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import adafruit_bno055 + + Once this is done you can define your `board.I2C` object and define your sensor object + + .. code-block:: python + + i2c = board.I2C() # uses board.SCL and board.SDA + sensor = adafruit_bno055.BNO055_I2C(i2c) + + + Now you have access to the :attr:`acceleration` attribute among others + + .. code-block:: python + + sensor = accelerometer.acceleration + """ def __init__(self): @@ -227,11 +269,11 @@ def mode(self): | NDOF_MODE | X | X | X | X | - | +------------------+-------+---------+------+----------+----------+ - The default mode is ``NDOF_MODE``. + The default mode is :const:`NDOF_MODE`. | You can set the mode using the line below: | ``sensor.mode = adafruit_bno055.ACCONLY_MODE`` - | replacing ``ACCONLY_MODE`` with the mode you want to use + | replacing :const:`ACCONLY_MODE` with the mode you want to use .. data:: CONFIG_MODE @@ -662,7 +704,7 @@ def axis_remap(self): @axis_remap.setter def axis_remap(self, remap): - """Pass a tuple coinsidting of x, y, z, x_sign, y-sign, and z_sign. + """Pass a tuple consisting of x, y, z, x_sign, y-sign, and z_sign. Set axis remap for each axis. The x, y, z parameter values should be set to one of AXIS_REMAP_X (0x00), AXIS_REMAP_Y (0x01), or diff --git a/docs/examples.rst b/docs/examples.rst index ee220e5..9bbfd02 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,3 +6,15 @@ Ensure your device works with this simple test. .. literalinclude:: ../examples/bno055_simpletest.py :caption: examples/bno055_simpletest.py :linenos: + + +Raspberry PI I2C GPIO Simpletest +-------------------------------- + +This example demonstrates how to instantiate the +Adafruit BNO055 Sensor using this library and just +the I2C bus number. + +.. literalinclude:: ../examples/bno055_i2c-gpio_simpletest.py + :caption: examples/bno055_i2c-gpio_simpletest.py + :linenos: diff --git a/docs/index.rst b/docs/index.rst index 7100f90..a222f3e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,10 +23,12 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 Learning Guide + .. toctree:: :caption: Related Products - Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 + Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 .. toctree:: :caption: Other Links diff --git a/examples/bno055_simpletest.py b/examples/bno055_simpletest.py index a199e0c..42e2a9f 100644 --- a/examples/bno055_simpletest.py +++ b/examples/bno055_simpletest.py @@ -3,15 +3,14 @@ import time import board -import busio import adafruit_bno055 -# Use these lines for I2C -i2c = busio.I2C(board.SCL, board.SDA) + +i2c = board.I2C() sensor = adafruit_bno055.BNO055_I2C(i2c) -# User these lines for UART -# uart = busio.UART(board.TX, board.RX) +# If you are going to use UART uncomment these lines +# uart = board.UART() # sensor = adafruit_bno055.BNO055_UART(uart) last_val = 0xFFFF