Ambient Light Sensor BH1750FVI Library using I2C communication.
Based on this open source project: https://github.com/Genotronex/BH1750FVI_Master
I2C addresses supported: 0x23 or 0x5C.
Various resolution modes possible - recommended is mode Continuous_H_resolution.
Tested sensor model GY-301 BH1750FVI connected to an Arduino MEGA
Wiring
BH1750 = Arduino
VCC = 3.3v
GND = GND
SCL = SCL
SDA = SDA
ADDR to A3 or GND = address 0x23
OR
ADDR to Vin = address 0x5C
Timer Example
Output
492lx
6lx
115lx
55lx
ChangeLog
20170215 v1.01 - property change GetLightIntensity to getLightIntensity (bh.LightIntensity); added code examples.
20170127 v1.0
Based on this open source project: https://github.com/Genotronex/BH1750FVI_Master
I2C addresses supported: 0x23 or 0x5C.
Various resolution modes possible - recommended is mode Continuous_H_resolution.
Tested sensor model GY-301 BH1750FVI connected to an Arduino MEGA
Wiring
BH1750 = Arduino
VCC = 3.3v
GND = GND
SCL = SCL
SDA = SDA
ADDR to A3 or GND = address 0x23
OR
ADDR to Vin = address 0x5C
Timer Example
B4X:
Sub Process_Globals
Public Serial1 As Serial
Private bh As BH1750FVI
Private Timer1 As Timer
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'Init the sensor with low I2C address 0x23 and the recommended high resolution mode
bh.Initialize(bh.Device_Address_L, bh.Continuous_H_resolution_Mode)
Timer1.Initialize("Timer1_Tick", 1000)
Timer1.Enabled = True
End Sub
Sub Timer1_Tick
Log(bh.LightIntensity, "lx")
End Sub
Output
492lx
6lx
115lx
55lx
ChangeLog
20170215 v1.01 - property change GetLightIntensity to getLightIntensity (bh.LightIntensity); added code examples.
20170127 v1.0
Attachments
Last edited: