The Hygrometer class constructs objects that represent a single Hygrometer sensor attached to the physical board. Hygrometers are used to measure absolute and relative humidity.

Supported Hygrometers:

This list will continue to be updated as more devices are confirmed.

Parameters

  • General Options

    PropertyTypeValue/DescriptionDefaultRequired
    controllerstringBME280, HTU21D, HIH6130, TH02, SI7020, SI7021, SHT31D. The Name of the controller to use.no
    freqNumberMilliseconds. The rate in milliseconds to emit the data event25msno

Shape

Property NameDescriptionRead Only
idA user definable id value. Defaults to a generated uidNo
relativeHumidityThe relative humidity in percent.Yes
RHA convenience alias for relativeHumidity.Yes

Component Initialization

HTU21D

new five.Hygrometer({
  controller: "HTU21D"
});

HTU21D HTU21D HTU21D HTU21D

HIH6130

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

HIH6130

SI7020

new five.Hygrometer({
  controller: "SI7020"
});

SI7020

SI7021

new five.Hygrometer({
  controller: "SI7021"
});

SI7021

TH02

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

TH02

DHT11_I2C_NANO_BACKPACK

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

DHT11_I2C_NANO_BACKPACK

DHT21_I2C_NANO_BACKPACK

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

DHT21_I2C_NANO_BACKPACK

DHT22_I2C_NANO_BACKPACK

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

DHT22_I2C_NANO_BACKPACK

Usage

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

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

  var hygrometer = new five.Hygrometer({
    controller: "HTU21D"
  });

  hygrometer.on("change", function() {
    console.log(this.relativeHumidity + " %");
  });
});

API

There are no special API functions for this class.

Events

  • change The "change" event is emitted whenever the value of the relative humidity changes.

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

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