Ambient Light Sensor
The AmbientLight sensor class provides access to an ambient light sensor (lightmeter).
Constructor
Section titled “Constructor”AmbientLight(options)
Section titled “AmbientLight(options)”Creates a new AmbientLight object instance.
AmbientLight(options)Parameters
Section titled “Parameters”options
An object of properties used to construct the class.
sensor- The hardware connection definition.
interval(optional) - The sampling interval in milliseconds.
Instance Methods
Section titled “Instance Methods”sample()
Section titled “sample()”Returns a sample object containing the current light intensity data.
sample()Return Value
Section titled “Return Value”An object with the following property:
illuminance- A number that represents the sampled ambient light level in Lux.
Examples
Section titled “Examples”const sensor = new device.sensor.AmbientLight({ sensor: { io: device.io.I2C, address: 0x23 }});
const sample = sensor.sample();console.log(`Illuminance: ${sample.illuminance} lux`);