Measurement of illuminance with a BH1750FVI Breakout Board (GY-30) and an Arduino Uno

In this simple circuit, we use a small BH1750FVI sensor on a breakout board and an Arduino to measure the illuminance in lux. Besides the application to measure the illumination of objects in the photography, you can – with an extension of this circuit – also easily make an adapted illumination of rooms or gardens. It is also possible to realize an automatic brightness control for displays.

Measurement of illuminance with a BH1750FVI Breakout Board (GY-30) and an Arduino - blog.simtronyx.de.jpg

Measurement of illuminance with a BH1750FVI Breakout Board (GY-30) and an Arduino

We connect our Arduino – in this case an Arduino Uno – with the (GY-30) breakout board as follows:

Zoom level:

ATMega328P1afbgchdie1j55101015152020252530afbgchdie30j
Move over elements (parts, jumper cable etc.) for more information (or tap in touch mode)...

Arduino
(NanoUno, Pro Mini)
Arduino
(Mega, Mega 2560)
GY-30
BH1750FVI breakout board
5V oder 3.3V (VCC) 5V oder 3.3V (VCC) VCC
GND GND GND
A4 (SDA) D20 (SDA) SDA
A5 (SCL) D21 (SCL) SCL

Source code (Sketch):

As an additional library is not necessary, we only need to upload the following sketch to our Arduino:

#include <Wire.h>

int BH1750_address = 0x23; // i2c Addresse
byte buff[2];

void setup(){
  
  Wire.begin();
  BH1750_Init(BH1750_address);
  
  delay(200);
  Serial.begin(9600);
  Serial.println("Starte Beleuchtungsstaerkemessung - blog.simtronyx.de");
}

void loop(){
  
  float valf=0;

  if(BH1750_Read(BH1750_address)==2){
    
    valf=((buff[0]<<8)|buff[1])/1.2;
    
    if(valf<0)Serial.print("> 65535");
    else Serial.print((int)valf,DEC); 
    
    Serial.println(" lx"); 
  }
  delay(1000);
}

void BH1750_Init(int address){
  
  Wire.beginTransmission(address);
  Wire.write(0x10); // 1 [lux] aufloesung
  Wire.endTransmission();
}

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

Download Source Code

and then start the serial monitor:

Illuminance measurement with a BH1750FVI and an Arduino Uno - serial monitor-blog.simtronyx.de

Illuminance measurement with a BH1750FVI and an Arduino Uno – Serial monitor

Now we should get a similar output as shown above. In this case, the sensor was moved in sunny weather between shadow (temporarily covered with the hand at a short distance) and direct sunlight. It can be seen that in direct sunlight the value range of the sensor is very quickly exceeded.

An overview with examples of common illumination levels for comparison can be found here in Wikipedia.

Components:

eBay: Arduino
BH1750FVI
Breadboard
Breadboard jumper wires
Amazon: Arduino
BH1750FVI
Breadboard
Breadboard jumper wires

Good?

Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail