Light Intensity is an important parameter. This could be measured by various components (eg. LDR) with proper calibration. This is why BH1750 is easy to use. It has an I2C interface so data could be extracted easily using the I2C Bus.
Things we need:
- BH1750
- Arduino
- Jumper Wires
- Bread Board (Optional)
Connection Diagram:
Connection is very simple, BH1750 has five pins Vcc, Gnd, SCL, SDA, Addr. Connect the pins accordingly.
- VCC pin to Arduino 5V
- GND pin to Arduino Ground
- SCL pin to Arduino A5
- SDA pin to Arduino A4
Once the connection is done open Arduino IDE and upload the code below.
Before you upload the code library needs to be installed. Please follow the below mention instruction to install the library.
https://creativestudio1973.blogspot.com/2019/11/introduction-to-arduino-library-manager.html
https://creativestudio1973.blogspot.com/2019/11/introduction-to-arduino-library-manager.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <BH1750.h> | |
BH1750 lightIntensity; | |
void setup(){ | |
Serial.begin(9600); | |
Serial.println(F("Testing of BH1750 by Project Hub")); | |
Wire.begin(); | |
Serial.println(F("I2C Communication Started")); | |
lightIntensity.begin(); | |
Serial.println(F("Light Intensity Meter Started")); | |
} | |
void loop() { | |
float lux = lightIntensity.readLightLevel(); | |
Serial.print("Light Intensity: "); | |
Serial.print(lux); | |
Serial.println(" lx"); | |
delay(2000); | |
} |
Video:
No comments:
Post a Comment