Breadboard for "Compass - MAG3110"


Fritzing diagram: compass-MAG3110.fzz


Run this example from the command line with:

node eg/compass-MAG3110.js
var five = require("../");
var board = new five.Board();

board.on("ready", function() {

  var compass = new five.Compass({
    controller: "MAG3110",
    // Optionally pre-load the offsets
    offsets: {
      x: [-819, -335],
      y: [702, 1182],
      z: [-293, -13],

  compass.on("calibrated", function(offsets) {
    // Use this data with the optional "offsets" property above
    console.log("calibrated:", offsets);

  compass.on("change", function() {
    console.log("  heading : ", Math.floor(this.heading));
    console.log("  bearing : ",;


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