Skip to content

Humidity Sensor

The Humidity sensor class provides access to a humidity sensor (hygrometer).

Creates a new Humidity object instance.

Humidity(options)

options

An object of properties used to construct the class.

sensor - The hardware connection definition.

interval (optional) - The sampling interval in milliseconds.

Returns a sample object containing the current humidity data.

sample()

An object with the following property:

humidity - A number that represents the sampled relative humidity as a percentage.

const sensor = new device.sensor.Humidity({
sensor: {
io: device.io.I2C,
address: 0x40
}
});
const sample = sensor.sample();
console.log(`Humidity: ${sample.humidity}%`);

Humidity