Skip to content
Rick Waldron edited this page Oct 7, 2015 · 8 revisions

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

    Property Type Value/Description Default Required
    controller string HTU21D. The Name of the controller to use. no
    freq Number Milliseconds. The rate in milliseconds to emit the data event 25ms no

Shape

{ 
  id: A user definable id value. Defaults to a generated uid
  pin: The pins defined for X, Y, and Z.
  relativeHumidity: The relative humidity in percent. READONLY
  RH: A convenience alias for relativeHumidity. READONLY
}

Component Initialization

MPU6050

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

HTU21D

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)

Clone this wiki locally