Features:
- Power Supply: 3V to 5V
- Illumination Range: 0 - 65,535 lux
- Built-in 16-bit ADC for high precision
- Close to human visual sensitivity spectrum
- High accuracy measurement down to 1 lux
- Direct digital output for reliable readings
Typical Light Intensity Examples (lux):
- Night: 0.001 - 0.02
- Moonlight night: 0.02 - 0.3
- Cloudy indoor: 5 - 50
- Cloudy outdoor: 50 - 500
- Sunny indoor: 100 - 1000
- Summer afternoon sunlight: ~1,000,000
- Reading light intensity: 50 - 60
- Home video standard intensity: 1400
Pinout and Connections:
Pin |
Description |
GND |
Ground |
ADDR |
I2C Address Select: 0x23 (default) or 0x5C if connected to 3.3V |
SDA |
I2C Data |
SCL |
I2C Clock |
VCC |
3.3V to 5V Power Supply |
On Arduino Uno, connect SDA to A4 and SCL to A5. On ESP8266 (Wemos D1 Mini), SDA is D2 and SCL is D1. You can manually assign I2C pins using Wire.begin(SDA_pin, SCL_pin);
in your setup.
Arduino / ESP8266 Code Example:
#include <Wire.h>
#include <BH1750.h>
#define _TOOLOW 25
#define _LOW 50
#define _HIGH 500
#define _TOOHIGH 750
#define LEVEL_TOOLOW "Too low"
#define LEVEL_LOW "Low"
#define LEVEL_OPTIMAL "Ideal"
#define LEVEL_HIGH "High"
#define LEVEL_TOOHIGH "Too high"
BH1750 lightMeter(0x23); // Default I2C address. Change to 0x5C if ADD pin connected to 3.3V.
void setup() {
Serial.begin(115200);
Wire.begin();
lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
Serial.println(F("BH1750 Light Sensor Test"));
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
String luxMessage;
int luxLevel;
if (lux <= _TOOLOW) {
luxLevel = 1; luxMessage = LEVEL_TOOLOW;
} else if (lux <= _LOW) {
luxLevel = 2; luxMessage = LEVEL_LOW;
} else if (lux <= _HIGH) {
luxLevel = 3; luxMessage = LEVEL_OPTIMAL;
} else if (lux < _TOOHIGH) {
luxLevel = 4; luxMessage = LEVEL_HIGH;
} else {
luxLevel = 5; luxMessage = LEVEL_TOOHIGH;
}
Serial.print("Light: "); Serial.print(lux);
Serial.print(" lx, Level: "); Serial.print(luxLevel);
Serial.print(", Quality: "); Serial.println(luxMessage);
delay(1000);
}
This code reads the ambient light level in lux and categorizes it into five levels from "Too low" to "Too high," helping you evaluate the lighting quality easily.
For more advanced usage, refer to the BH1750 library on GitHub.
Features:
- Power Supply: 3V to 5V
- Illumination Range: 0 - 65,535 lux
- Built-in 16-bit ADC for high precision
- Close to human visual sensitivity spectrum
- High accuracy measurement down to 1 lux
- Direct digital output for reliable readings
Typical Light Intensity Examples (lux):
- Night: 0.001 - 0.02
- Moonlight night: 0.02 - 0.3
- Cloudy indoor: 5 - 50
- Cloudy outdoor: 50 - 500
- Sunny indoor: 100 - 1000
- Summer afternoon sunlight: ~1,000,000
- Reading light intensity: 50 - 60
- Home video standard intensity: 1400
Pinout and Connections:
Pin |
Description |
GND |
Ground |
ADDR |
I2C Address Select: 0x23 (default) or 0x5C if connected to 3.3V |
SDA |
I2C Data |
SCL |
I2C Clock |
VCC |
3.3V to 5V Power Supply |
On Arduino Uno, connect SDA to A4 and SCL to A5. On ESP8266 (Wemos D1 Mini), SDA is D2 and SCL is D1. You can manually assign I2C pins using Wire.begin(SDA_pin, SCL_pin);
in your setup.
Arduino / ESP8266 Code Example:
#include <Wire.h>
#include <BH1750.h>
#define _TOOLOW 25
#define _LOW 50
#define _HIGH 500
#define _TOOHIGH 750
#define LEVEL_TOOLOW "Too low"
#define LEVEL_LOW "Low"
#define LEVEL_OPTIMAL "Ideal"
#define LEVEL_HIGH "High"
#define LEVEL_TOOHIGH "Too high"
BH1750 lightMeter(0x23); // Default I2C address. Change to 0x5C if ADD pin connected to 3.3V.
void setup() {
Serial.begin(115200);
Wire.begin();
lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
Serial.println(F("BH1750 Light Sensor Test"));
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
String luxMessage;
int luxLevel;
if (lux <= _TOOLOW) {
luxLevel = 1; luxMessage = LEVEL_TOOLOW;
} else if (lux <= _LOW) {
luxLevel = 2; luxMessage = LEVEL_LOW;
} else if (lux <= _HIGH) {
luxLevel = 3; luxMessage = LEVEL_OPTIMAL;
} else if (lux < _TOOHIGH) {
luxLevel = 4; luxMessage = LEVEL_HIGH;
} else {
luxLevel = 5; luxMessage = LEVEL_TOOHIGH;
}
Serial.print("Light: "); Serial.print(lux);
Serial.print(" lx, Level: "); Serial.print(luxLevel);
Serial.print(", Quality: "); Serial.println(luxMessage);
delay(1000);
}
This code reads the ambient light level in lux and categorizes it into five levels from "Too low" to "Too high," helping you evaluate the lighting quality easily.
For more advanced usage, refer to the BH1750 library on GitHub.