IMU - BNO055 (Orientation)

imu-bno055.png

Fritzing diagram: imu-bno055.fzz

 

Run this example from the command line with:

node eg/imu-bno055-orientation.js
const {Board, IMU} = require("../");
const board = new Board();

board.on("ready", () => {

  // Borrowed from
  // https://github.com/adafruit/Adafruit_BNO055/blob/master/examples/bunny/bunny.ino
  //
  // Calibration: https://www.youtube.com/watch?v=uH7iQrH3GpA&feature=youtu.be

  const layout = `
  Board layout:
      +----------+
      |         *| RST   PITCH  ROLL  HEADING
  ADR |*        *| SCL
  INT |*        *| SDA     ^            /->
  PS1 |*        *| GND     |            |
  PS0 |*        *| 3VO     Y    Z-->    \-X
      |         *| VIN
      +----------+
  `;

  console.log(layout);

  const imu = new IMU({
    controller: "BNO055",
    enableExternalCrystal: false // this can be turned on for better performance if you are using the Adafruit board
  });


  imu.orientation.on("change", () => {

    console.log("orientation");
    console.log("  w            : ", imu.quarternion.w);
    console.log("  x            : ", imu.quarternion.x);
    console.log("  y            : ", imu.quarternion.y);
    console.log("  z            : ", imu.quarternion.z);

    console.log("  heading      : ", imu.euler.heading);
    console.log("  roll         : ", imu.euler.roll);
    console.log("  pitch        : ", imu.euler.pitch);

    console.log("--------------------------------------");

  });
});

 

Component Classes in this example:

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub