The BH1750 is a digital ambient light sensor that provides precise measurements of illuminance (light intensity) in the environment. It is capable of detecting illuminance levels ranging from 1 to 65535 lux, which makes it suitable for a wide range of applications. Commonly, the BH1750 is used in devices that require the adjustment of display backlighting or keypad lighting in response to changing light conditions, such as smartphones, tablets, digital cameras, and in various home automation systems.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (2.4V to 3.6V) |
2 | ADDR | Address pin to set sensor I2C address |
3 | SDA | I2C Data pin |
4 | SCL | I2C Clock pin |
5 | GND | Ground |
To use the BH1750 with an Arduino UNO, follow these steps:
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup(){
Wire.begin();
Serial.begin(9600);
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
Serial.println(F("BH1750 Advanced begin"));
} else {
Serial.println(F("Error initialising BH1750"));
}
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
delay(1000);
}
Q: Can the BH1750 be used with 5V systems? A: The BH1750 can be used with 5V systems, but a level shifter is recommended for the I2C lines, and the VCC should be connected to a 3.3V supply.
Q: How can I change the measurement mode of the BH1750? A: The measurement mode can be changed by sending the appropriate mode command to the sensor using the I2C protocol. The BH1750 library provides functions to do this easily.
Q: What is the maximum distance for the I2C connection to the BH1750? A: The maximum distance for I2C communication is typically about 1 meter, but it can vary depending on the bus capacitance and the environmental conditions. Use shorter connections for reliable communication.