Home Sensor Projects Arduino and BH1750FVI digital Ambient Light Sensor

Arduino and BH1750FVI digital Ambient Light Sensor

by shedboy71

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 exactly 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 examples 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

bh1750-2

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

bh1750-module-schematic

 

Layout

Here is a layout drawn up in fritzing

arduino-and-bh1750_bb

 

 

Code

This code example purposefully did not use any third party libraries, sometimes its nice to see how to work with I2C devices just by using the Arduino wire library

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <math.h> 
int BH1750address = 0x23; //i2c address

byte buff[2];
void setup()
{
  Wire.begin();
  Serial.begin(57600);
}

void loop()
{
  int i;
  uint16_t val=0;
  BH1750_Init(BH1750address);
  delay(200);

  if(2==BH1750_Read(BH1750address))
  {
    val=((buff[0]<<8)|buff[1])/1.2;
    Serial.print(val,DEC);     
    Serial.println("lux"); 
  }
  delay(150);
}

int BH1750_Read(int address) //
{
  int i=0;
  Wire.beginTransmission(address);
  Wire.requestFrom(address, 2);
  while(Wire.available()) //
  {
    buff[i] = Wire.read();  // receive one byte
    i++;
  }
  Wire.endTransmission();  
  return i;
}

void BH1750_Init(int address) 
{
  Wire.beginTransmission(address);
  Wire.write(0x10);//1lx reolution 120ms
  Wire.endTransmission();
}

[/codesyntax]

 

Testing

Open the serial monitor and change the light intensity, here is what I saw

1070 lux
5006 lux
7427 lux
8200 lux
8996 lux
8656 lux
6569 lux
150 lux
5 lux
2 lux
2 lux
3 lux
2 lux
10 lux
38 lux
266 lux
259 lux

 

 

Links
BH1750 BH1750FVI light intensity illumination module 3V-5V

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More