Light sensor BH1750 and Arduino

Using the module BH1750 we can measure the intensity of light. For the service module we use an Arduino Uno version.

 

In this example we used the following elements:

 

Connection BH1750 Arduino:

To operate a generator using a serial interface, connect the circuit with the Arduino in the following way:

 

Pin BH1750 Pin Arduino
VCC 5 V
GND GND
SCL A5
Traffic

A4

 

 

 

Diagram system connection BH1750 Arduino Uno.

Program for Arduino

At the beginning of the library you want to add to the environment of the Arduino (Sketch -> Include Library -> Add .ZIP Library...).

In the example, we used the following code:

#include  
#include  

BH1750 czujnikSwiatla; //variable that represents the sensor 

void setup(){ 
 Serial.begin(9600); //start the monitor serial port 
 czujnikSwiatla.begin(); 
 Serial.println("sensor is Running."); 
} 


void loop() { 
 uint16_t lux = czujnikSwiatla.readLightLevel(); //read the value from the sensor 
 Serial.print("the Value of intensity of light: "); //display result on the display consistent 
 Serial.print(Lux); 
 Serial.println(" lx"); 
 delay(500); //delay between consecutive readings 
} 

The result of the program can be viewed on the serial monitor:

 

A screenshot of the serial monitor.

Botland.store - shop for makers!