Characteristic Locus
Inheritance System.Object > BNO055
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Sensors.Motion
Assembly BNO055.dll

Syntax

public class BNO055

Remarks

BNO055 is a 9-axis absolute orientation sensor. The three sensors (accelerometer, gyroscope and magnetometer) with a 32-bit cortex M0 microcontroller.

Purchasing

Examples

The application below will send serial data to the cuberotate application on the Adafruit web site. Rotating the board will rotate the figure on the screen.

using System.Threading;
using Meadow;
using Meadow.Foundation.Sensors.Motion;

namespace BNO055_Sample
{
    public class Program
    {
        static IApp _app; 
        public static void Main()
        {
            _app = new App();
        }
    }

    public class App : AppBase<F7Micro, App>
    {
        /// <summary>
        /// Pin used to reset the BNO055.
        /// </summary>
        private static DigitalOutputPort _resetPort = new DigitalOutputPort(Device.Pins.D02, true);

        /// <summary>
        /// Serial port used to send data to the computer.
        /// </summary>
        private static SerialPort _comPort = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One);

        /// <summary>
        /// Convert a boolean value to text for the calibration messages.
        /// </summary>
        public static string BooleanToIntString(bool b)
        {
            return b ? "1" : "0";
        }

        /// <summary>
        ///  Write a message to the com port terminated with '\n'
        /// </summary>
        private static void WriteText(string text)
        {
            string message = text + "\n";
            _comPort.Write(Encoding.UTF8.GetBytes(message), 0, message.Length);
        }

        public App ()
        {
            Console.WriteLine("BNO055 Test Application.");

            _resetPort.Write(false);
            Thread.Sleep(10);
            _resetPort.Write(true);
            Thread.Sleep(50);

            _comPort.Open();
            WriteText("Orientation Sensor Test");
            WriteText("");
            WriteText("Sensor:       BNO050");
            WriteText("Driver Ver:   1");
            WriteText("Unique ID:    ");
            WriteText("Max Value:    0.0");
            WriteText("Min Value:    0.0");
            WriteText("Resolution:   0.01");
            WriteText("");
            Thread.Sleep(500);

            var bno055 = new BNO055(0x29);
            bno055.DisplayRegisters();
            bno055.PowerMode = BNO055.PowerModes.Normal;
            bno055.OperatingMode = BNO055.OperatingModes.ConfigurationMode;
            bno055.OperatingMode = BNO055.OperatingModes.InertialMeasurementUnit;
            bno055.DisplayRegisters();

            Console.WriteLine("Current temperature: " + bno055.Temperature.ToString("f2"));

            while (true)
            {
                bno055.Read();
                var reading = bno055.EulerOrientation;
                string orientationMessage = "Orientation: " + reading.Roll + " " + reading.Pitch + " " + reading.Heading;
                string calibrationMessage = "Calibration: " + BooleanToIntString(bno055.IsSystemCalibrated) + " " +
                            BooleanToIntString(bno055.IsGyroscopeCalibrated) + " " +
                            BooleanToIntString(bno055.IsAccelerometerCalibrated) + " " +
                            BooleanToIntString(bno055.IsMagnetometerCalibrated);
                Console.WriteLine(orientationMessage);
                Console.WriteLine(calibrationMessage);
                WriteText(orientationMessage);
                WriteText(calibrationMessage);

                Thread.Sleep(100);
            }
        }
    }
}
Example Circuit

The following diagram shows the BNO055 configured for bas

Constructors

View Source

BNO055(II2cBus, Byte)

Create a new BNO055 object using the default parameters for the component.

Declaration
public BNO055(II2cBus i2cBus, byte address = 40)

Parameters

Type Name Description
II2cBus i2cBus

I2C bus (default = 400 KHz).

System.Byte address

Address of the BNO055 (default = 0x28).

Properties

View Source

AccelerometerReading

Get the accelerometer readings from the last call to Read().

Declaration
public Vector AccelerometerReading { get; }

Property Value

Type Description
Vector
View Source

EulerOrientation

Orientation in Euler angles.

Declaration
public EulerAngles EulerOrientation { get; }

Property Value

Type Description
EulerAngles
View Source

GravityVector

Retrieve the gravity vector (fusion mode only).

Declaration
public Vector GravityVector { get; }

Property Value

Type Description
Vector
View Source

GyroscopeReading

Get the gyroscope readings.

Declaration
public Vector GyroscopeReading { get; }

Property Value

Type Description
Vector
View Source

IsAccelerometerCalibrated

Get the accelerometer calibration status.

Declaration
public bool IsAccelerometerCalibrated { get; }

Property Value

Type Description
System.Boolean
View Source

IsFullyCalibrated

Is the system fully calibrated?

Declaration
public bool IsFullyCalibrated { get; }

Property Value

Type Description
System.Boolean

Remarks

The sensor is fully calibrated if the system, accelerometer, gyroscope and megnetometer are all calibrated.

View Source

IsGyroscopeCalibrated

Get the gyroscope calibration status.

Declaration
public bool IsGyroscopeCalibrated { get; }

Property Value

Type Description
System.Boolean
View Source

IsInFusionMode

Check if sensor is currently working in Fusion mode.

Declaration
public bool IsInFusionMode { get; }

Property Value

Type Description
System.Boolean
View Source

IsMagnetometerCalibrated

Get the magnetometer status.

Declaration
public bool IsMagnetometerCalibrated { get; }

Property Value

Type Description
System.Boolean
View Source

IsSystemCalibrated

Get the system calibration status.

Declaration
public bool IsSystemCalibrated { get; }

Property Value

Type Description
System.Boolean
View Source

LinearAcceleration

Retrieve the linear acceleration vector (fusion mode only).

Declaration
public Vector LinearAcceleration { get; }

Property Value

Type Description
Vector
View Source

MagnetometerReading

Get the magnetometer readings.

Declaration
public Vector MagnetometerReading { get; }

Property Value

Type Description
Vector
View Source

OperatingMode

Get / set the current operating mode for the sensor.

Declaration
public byte OperatingMode { get; set; }

Property Value

Type Description
System.Byte

Remarks

Mode change takes 7-19 ms.

View Source

PowerMode

Get or set the power mode for the sensor.

Declaration
public byte PowerMode { get; set; }

Property Value

Type Description
System.Byte
View Source

QuaternionOrientation

Get the Quaterion orientation.

Declaration
public Quaternion QuaternionOrientation { get; }

Property Value

Type Description
Quaternion
View Source

Temperature

Get the temperature from the currently selected sensor.

Declaration
public int Temperature { get; }

Property Value

Type Description
System.Int32
View Source

TemperatureSource

Select the source of the Temperatute property.

Declaration
public BNO055.Sensor TemperatureSource { get; set; }

Property Value

Type Description
BNO055.Sensor

Methods

View Source

DisplayRegisters()

Read all of the registers and display their values on the Debug output.

Declaration
public void DisplayRegisters()
View Source

Read()

Force the sensor to make a reading and update the relevant properties.

Declaration
public void Read()

Remarks

This method reads ony the sensor motion / orientation registers. When accessing the data from a register it is necessary to subtract the accress of the start of the sensor registers from the register required in order to get the correct offset into the _sensorReadings array.