The Barometer class constructs objects that represent a single Barometer sensor attached to the physical board.

Supported Barometers:

This list will continue to be updated as more component support is implemented.

Parameters

  • General Options

    PropertyTypeValue/DescriptionDefaultRequired
    controllerstringBMP180, MPL115A2, MPL3115A2. The Name of the controller to useYes
    addressnumberAddress for I2C device.By DeviceNo
    freqnumberMilliseconds. The rate in ms of data events.25No

  • BMP180 Options (controller: "BMP180")

    PropertyTypeValue/DescriptionDefaultRequired
    modenumber0-3. Oversampling ratio mode.3No

Shape

Property NameDescriptionRead Only
idA user definable id value. Defaults to a generated uidNo
pressureThe current pressure value in kPa.Yes

Component Initialization

BMP180

new five.Barometer({
  controller: "BMP180"
});

BMP180

MPL115A2

new five.Barometer({
  controller: "MPL115A2"
});

MPL115A2

MPL3115A2

new five.Barometer({
  controller: "MPL3115A2"
});

MPL3115A2

MS5611

new five.Barometer({
  controller: "MS5611"
});

MS5611

Usage

var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {
  var barometer = new five.Barometer({
    controller: "MPL115A2"
  });

  barometer.on("data", function() {
    console.log("barometer");
    console.log("  pressure : ", this.pressure);
    console.log("--------------------------------------");
  });
});

API

There are no Barometer specific methods.

Events

  • change The "change" event is emitted whenever the value of the barometric pressure sensor changes.

  • data The "data" event is fired as frequently as the user defined freq will allow in milliseconds.

Examples

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