Skip to content

Ambient Light Sensor

The AmbientLight sensor class provides access to an ambient light sensor (lightmeter).

Creates a new AmbientLight object instance.

AmbientLight(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 light intensity data.

sample()

An object with the following property:

illuminance - A number that represents the sampled ambient light level in Lux.

const sensor = new device.sensor.AmbientLight({
sensor: {
io: device.io.I2C,
address: 0x23
}
});
const sample = sensor.sample();
console.log(`Illuminance: ${sample.illuminance} lux`);

Ambient Light