Kaluma library for BH1750 light sensor
npm install https://github.com/rossdoker/bh1750| Pi Pico | BH1750 |
|---|---|
| VBUS | VCC |
| GND | GND |
| SCL | SCL |
| SDA | SDA |
const { I2C } = require('i2c');
const BH1750 = require('bh1750')
const bus = new I2C(1, { mode: I2C.MASTER });
const bh1750 = new BH1750(bus);
bh1750.setContinuousMode(BH1750.CONTINUOUS_HIGH_RES_MODE_1);
setInterval(() => {
console.log(bh1750.getResult());
}, 1000);A class for bh1750 sensor communicating with I2C interface.
Create an instance of bh1750 sensor.
bus<I2C>An instance ofI2Cto communicate.address<number>I2C slave address. (7bit). Default:0x23.
Turns off the bh1750 sensor.
Turns on the bh1750 sensor.
Resets the bh1750 sensor.
Sets bh1750 to work in continuous measurement mode.
mode<string>Continuous measurement mode. Use one of next:BH1750.CONTINUOUS_LOW_RES_MODE,BH1750.CONTINUOUS_HIGH_RES_MODE_1,BH1750.CONTINUOUS_HIGH_RES_MODE_2.
Sets bh1750 to work in one time measurement mode.
mode<string>One time measurement mode. Use one of next:BH1750.ONE_TIME_LOW_RES_MODE,BH1750.ONE_TIME_HIGH_RES_MODE_1,BH1750.ONE_TIME_HIGH_RES_MODE_2.
Sets sensitivity of measurement.
v<number>Min:31. Max:254. Default:69.
Returns result of measurement.
Returns<number>Result of measurement in lx.
Sets bh1750 to work in one time measurement mode and returns result of measurement.
mode<string>One time measurement mode. Use one of next:BH1750.ONE_TIME_LOW_RES_MODE,BH1750.ONE_TIME_HIGH_RES_MODE_1,BH1750.ONE_TIME_HIGH_RES_MODE_2.additionalTime<number>Additional time in millisecond to wait before read the result of measurement. Default:0.