The SIP class constructs objects that represent a single "SiP" or "System-In-Package" module (eg. IMU, MEMS) attached to the physical board. An SiP may be made up of several components like Accelerometers, Gyroscopes, Thermometers, and Compass/Magnetometers.

Supported SiP sensor modules:

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

Parameters

  • General Options

    PropertyTypeValue/DescriptionDefaultRequired
    controllerstringBMP180, BMP280, BME280, HTU21D, HIH6130, MPL115A2, MPL3115A2, SI7020, SI7021, MS5611, TH02. The Name of the controller to useyes
    freqNumberIn milliseconds, how often data events should fire20no

In addition, anything in the options object passed to the SIP constructor will be passed along to each of its constituent component sensors (e.g. Thermometer, Altimeter, etc.). See relevant sensor component class documentation for more details about what options each takes.

Shape

Some of these properties may or may not exist depending on whether the multi sensor supports it.

Property NameDescriptionRead Only
accelerometerAn instance of Accelerometer class.Yes
altimeterAn instance of Altimeter class.Yes
barometerAn instance of Barometer class.Yes
gyroAn instance of Gyro class.Yes
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes
temperatureAn instance of Thermometer class.Yes

Component Initialization

BMP180

new five.SIP({
  controller: "BMP180"
});
Property NameDescriptionRead Only
barometerAn instance of Barometer class.Yes
thermometerAn instance of Thermometer class.Yes
temperatureAn instance of Thermometer class.Yes

HTU21D

new five.SIP({
  controller: "HTU21D"
});
Shape
Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes
temperatureAn instance of Thermometer class.Yes

HTU21D HTU21D HTU21D HTU21D

HIH6130

new five.SIP({
  controller: "HIH6130"
});

HIH6130

MPL115A2

new five.SIP({
  controller: "MPL115A2"
});
Property NameDescriptionRead Only
barometerAn instance of Barometer class.Yes
thermometerAn instance of Thermometer class.Yes
temperatureAn instance of Thermometer class.Yes

MPL3115A2

new five.SIP({
  controller: "MPL3115A2"
});
Property NameDescriptionRead Only
altimeterAn instance of Altimeter class.Yes
barometerAn instance of Barometer class.Yes
thermometerAn instance of Thermometer class.Yes
temperatureAn instance of Thermometer class.Yes

SI7020

new five.SIP({
  controller: "SI7020"
});
Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes

SI7021

new five.SIP({
  controller: "SI7021"
});
Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes

MS5611

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

MS5611

Property NameDescriptionRead Only
altimeterAn instance of Altimeter class.Yes
barometerAn instance of Barometer class.Yes
thermometerAn instance of Thermometer class.Yes

TH02

new five.SIP({
  controller: "TH02"
});

TH02

Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes

DHT11_I2C_NANO_BACKPACK

new five.SIP({
  controller: "DHT11_I2C_NANO_BACKPACK"
});

DHT11_I2C_NANO_BACKPACK

Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes

DHT21_I2C_NANO_BACKPACK

new five.SIP({
  controller: "DHT21_I2C_NANO_BACKPACK"
});

DHT21_I2C_NANO_BACKPACK

Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes

DHT22_I2C_NANO_BACKPACK

new five.SIP({
  controller: "DHT22_I2C_NANO_BACKPACK"
});

DHT22_I2C_NANO_BACKPACK

Property NameDescriptionRead Only
hygrometerAn instance of Hygrometer class.Yes
thermometerAn instance of Thermometer class.Yes

Usage

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

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

  const sip = new five.SIP({
    controller: "MPL115A2"
  });

  sip.on("data", () => {
    console.log("Barometer: %d", sip.barometer.pressure);
    console.log("Thermometer: %d", sip.thermometer.celsius);
  });
});
const five = require("johnny-five");
const board = new five.Board();

board.on("ready", () => {
  const sip = new five.SIP({
    controller: "HTU21D"
  });

  sip.on("change", () => {
    console.log("Thermometer");
    console.log("  celsius           : ", sip.thermometer.celsius);
    console.log("  fahrenheit        : ", sip.thermometer.fahrenheit);
    console.log("  kelvin            : ", sip.thermometer.kelvin);
    console.log("--------------------------------------");

    console.log("Hygrometer");
    console.log("  relative humidity : ", sip.hygrometer.relativeHumidity);
    console.log("--------------------------------------");
  });
});

API

The SIP class does not have an explicit API. Refer to the individual components for their APIs

Events

  • data The "data" event is fired as frequently as new data becomes available.

  • change The "change" event is fired whenever a corresponding "change" is fired from any constituent component.

Note: You may also bind to events on SIP object component sensors directly, e.g. sip.thermometer.on('change')

0

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