-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Hygrometer
Rick Waldron edited this page Mar 22, 2023
·
17 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:
- BME280
- HTU21D
- HIH6130
- TH02
- SI7020
- SI7021
- SHT31D
- DHT11 (Via I2C Backpack)
- DHT21 (Via I2C Backpack)
- DHT22 (Via I2C Backpack)
This list will continue to be updated as more devices are confirmed.
-
General Options
Property Type Value/Description Default Required controller string BME280, HTU21D, HIH6130, TH02, SI7020, SI7021, SHT31D. The Name of the controller to use. no freq Number Milliseconds. The rate in milliseconds to emit the data event 25ms no
Property Name | Description | Read Only |
---|---|---|
id |
A user definable id value. Defaults to a generated uid | No |
relativeHumidity |
The relative humidity in percent. | Yes |
RH |
A convenience alias for relativeHumidity. | Yes |
new five.Hygrometer({
controller: "HTU21D"
});
new five.Hygrometer({
controller: "HIH6130"
});
new five.Hygrometer({
controller: "SI7020"
});
new five.Hygrometer({
controller: "SI7021"
});
new five.Hygrometer({
controller: "TH02"
});
new five.Hygrometer({
controller: "DHT11_I2C_NANO_BACKPACK"
});
new five.Hygrometer({
controller: "DHT21_I2C_NANO_BACKPACK"
});
new five.Hygrometer({
controller: "DHT22_I2C_NANO_BACKPACK"
});
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 + " %");
});
});
There are no special API functions for this class.
-
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)