BH1750 - Ambient Light Sensor
The BH1750 is an ambient light sensor using the I2C-protocol for communication. For setting up the Raspberry Pi for I2C and connecting the sensor please check the example page.
BH1750_Open
BH1750_Open()
BH1750_Open(Address)
BH1750_Open(Address, Resolution)
Address: optional parameter, sets the I2C address (0x23 or 0x5C), default: 0x23
Resolution: optional parameter, 0 (low resolution) or 1 (high resolution), default: 1
Connects to the BH1750 sensor.
BH1750_Open() 'opens connetion with address 0x23 and high resolution
BH1750_Open(0x5C) 'opens connetion with address 0x5C and high resolution
BH1750_Open(0x23, 0) 'opens connetion with address 0x23 and low resolution
BH1750_Close
BH1750_Close()
Closes the connection to the BH1750 sensor
BH1750_GetLight
I = BH1750_GetLight()
I: Ambient light in Lux (lx)
Performs a single measurement of the ambient light and returns the value in Lux.
BH1750_SetResolution
BH1750_SetResolution(Resolution)
Resolution: 0: low resolution, 1: high resolution
Sets the resolution of the measurement.
Resolution | Measurement Time | |
---|---|---|
Low Resolution | 4lx | 24ms |
High Resolution | 1lx | 180ms |
BH1750_SetResolution(0) 'Sets low resolution
BH1750_SetResolution(1) 'Sets high resolution