Home ArduinoB4R B4R Arduino and BH1750 Ambient Light Sensor example

B4R Arduino and BH1750 Ambient Light Sensor example

BH1750FVI is an digital Ambient Light Sensor IC for I2C bus interface. This IC is the most suitable to obtain the ambient light data for adjusting LCD and Keypad backlight power of Mobile phone. It is possible to detect wide range at High resolution.  1 – 65535 lux (lx).

Features

1) I2C bus Interface ( f / s Mode Support )
2) Spectral responsibility is approximately human eye response
3) Illuminance to Digital Converter
4) Wide range and High resolution. ( 1 – 65535 lx )
5) Low Current by power down function
6) 50Hz / 60Hz Light noise reject-function
7) 1.8V Logic input interface
8) No need any external parts
9) Light source dependency is little. ( ex. Incandescent Lamp. Fluorescent Lamp. Halogen Lamp. White LED. Sun Light )
10) It is possible to select 2 type of I2C slave-address.
11) Adjustable measurement result for influence of optical window ( It is possible to detect min. 0.11 lx, max. 100000 lx by using this function. )
12) Small measurement variation (+/- 20%)
13) The influence of infrared is very small.

What is lux

The lux (symbol: lx) is the SI unit of illuminance and luminous emittance, measuring luminous flux per unit area. It is equal to one lumen per square metre. In photometry, this is used as a measure of the intensity, as perceived by the human eye, of light that hits or passes through a surface. It is analogous to the radiometric unit watts per square metre, but with the power at each wavelength weighted according to the luminosity function, a standardized model of human visual brightness perception. In English, “lux” is used in both singular and plural

Typical Lux values

These were taken from Wikipedia

Examples
Illuminance Surfaces illuminated by:
0.0001 lux Moonless, overcast night sky (starlight)
0.002 lux Moonless clear night sky with airglow
0.27–1.0 lux Full moon on a clear night[3][4]
3.4 lux Dark limit of civil twilight under a clear sky
50 lux Family living room lights (Australia, 1998)
80 lux Office building hallway/toilet lighting]
100 lux Very dark overcast day
320–500 lux Office lighting
400 lux Sunrise or sunset on a clear day.
1000 lux Overcast day; typical TV studio lighting
1000025000 lux Full daylight (not direct sun)
32000100000 lux Direct sunlight

Typically to use this sensor you will need to purchase a module, here is a picture of one

 

For those that are interested this is a schematic of the module

 

 

Layout

An easy module to connect being an I2C one

 

Code

The library and this code example are available from – https://www.b4x.com/android/forum/threads/rbh1750fvi-digital-ambient-light-sensor.75663/

[codesyntax lang=”cpp”]

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

[/codesyntax]

 

Testing

108 lx
102 lx
358 lx
357 lx
7 lx
1 lx
1 lx
167 lx

 

Links

BH1750 BH1750FVI light intensity illumination module 3V-5V

You may also like