adafruit / Adafruit_CircuitPython_BNO055

CircuitPython driver for BNO055 absolute orientation sensor
MIT License
85 stars 51 forks source link

How to get output in LSB for Python application? #89

Closed dimitrigrigoriev closed 1 year ago

dimitrigrigoriev commented 2 years ago

Currently, the Python library gives an output for accelerations and g-components as floats with two-digit accuracy. Is it possible to get actual output in LSB to convert to m/s2 using range and with better accuracy?

tekktrik commented 2 years ago

You can check the underscore attributes for the class and use the registers mentioned there to directly read the registers. For example:

class BNO055_I2C(BNO055):
    """
    Driver for the BNO055 9DOF IMU sensor via I2C.
    """

    _temperature = _ReadOnlyUnaryStruct(0x34, "b")
    _acceleration = _ScaledReadOnlyStruct(0x08, "<hhh", 1 / 100)

    ...

In this case, the register for temperature is 0x34 and the register for acceleration is 0x08. If you're familiar with how the struct module works, that string is the format of the return (https://docs.python.org/3/library/struct.html).

caternuson commented 1 year ago

Closing. Above is the answer.