Introduction
Welcome to the world of light sensing with Arduino! In this guide, we’ll explore How to Measure the Number of Luxes with Arduino and the BH1750 Lux Meter. The BH1750 Sensor offers a convenient and accurate way to measure light levels, making it suitable for applications such as ambient light sensing, brightness control, and energy management. Let’s delve into the details of the BH1750 lux meter sensor and learn how to integrate it with Arduino for precise lux measurements.
Hardware Required
You will require the following Hardware Components for How to Interface the BH1750 Light Sensor with Arduino.
Components | # | Buy From Amazon |
---|---|---|
Arduino UNO | 1 | Buy Link |
BH1750 Light Sensor | 1 | Buy Link |
9v DC Adapter (Optional) | 1 | Buy Link |
Jumper Wires | 4 | Buy Link |
Breadboard | 1 | Buy Link |
What is BH1750 Light Sensor?
The BH1750 is a digital light level sensor compatible with controllers like Arduino, allowing for the creation of a lux meter.
In contrast to other light level measurement systems such as LDR resistors, the BH1750’s spectral response is tailored to mimic that of the human eye, enabling accurate lux measurements.
Lux is the unit used to measure illuminance, representing the relationship between luminous flux (light emitted by a source) and the surface area it illuminates.
For reference, here are some typical examples of illuminance levels.
Situation | Luxes |
---|---|
Evening | 0.001-0.02 |
full moon | 0.2-0.6 |
Cloudy day, indoors | 5-50 |
Cloudy day, outdoors | 50-500 |
Sunny day, indoors | 100-1000 |
Under direct sunlight | 100,000 |
Bedroom, living room | 150-300 |
Office/reading table | 500-700 |
Supermarkets/exhibitions | 750-1000 |
Drawing/work tables | 1000-1500 |
The BH1750 offers a versatile measurement range spanning from 0.11 to 100,000 lux, catering to various lighting conditions. Its 16-bit ADC ensures high-resolution measurements with 65535 levels.
Moreover, the sensor exhibits minimal interference from the infrared spectrum, effectively filters out 50/60 Hz noise from artificial light sources, and maintains consistent performance across different light sources, including natural light, halogens, LEDs, and incandescent bulbs.
![arduino-luxometer-bh1750-interior-circuit](http://www.arduinocircuit.com/wp-content/uploads/2024/02/arduino-luxometer-bh1750-interior-circuit.webp)
The BH1750 communicates via the I2C bus, simplifying data retrieval. It operates within a low voltage range of 2.4 to 3.6V and is often integrated into modules with built-in electronics for easy Arduino connection, including voltage regulators for direct 5V input.
Primarily, the BH1750 finds application in regulating LCD and keypad backlighting in mobile devices, as well as in digital camera lighting control.
In our projects, we can utilize it to build a cost-effective lux meter, automate home blinds or awnings, or manage lighting systems efficiently.
Pinout
![BH1750-Lux-Meter-Light-Intensity-Sensor-Module-Pinout](http://www.arduinocircuit.com/wp-content/uploads/2024/02/BH1750-Lux-Meter-Light-Intensity-Sensor-Module-Pinout.webp)
Pin Configuration of BH1750 Sensor
Pin | Description |
---|---|
VCC | Module power supply: 2.4V to 3.6V, typically 3.0V. |
GND | Ground, connected to ground of the circuit |
SCL | Serial Clock Line provides clock pulses for I2C communication. |
SDA | Serial Data Address for data transfer in I2C communication. |
ADD | Address pin selects module address in a multi-module setup. |
Features
- Digital Output: Provides digital output data representing the intensity of ambient light for easy integration with microcontrollers like Arduino.
- Low Power Consumption: Designed for low power operation, making it suitable for battery-powered applications.
- Compact Design: Compact and lightweight design for easy integration into electronic projects.
- High Sensitivity: Offers high sensitivity to detect subtle changes in light intensity.
- Adjustable Sensitivity: Allows for adjustment of sensitivity settings to optimize light sensing performance in different environments.
Specifications
- Measurement Range:
- Wide measurement range suitable for detecting various light levels.
- Resolution:
- High resolution for accurate lux measurements.
- Accuracy:
- Precise light intensity measurement accuracy for reliable results.
- Communication Interface:
- I2C (Inter-Integrated Circuit) interface for communication with Arduino.
- Operating Voltage:
- Wide operating voltage range compatible with Arduino and other microcontroller platforms.
Circuit Diagram
The following circuit shows you the connection of the How to Measure the Number of Luxes with Arduino and the BH1750 Lux Meter, Please make the connection carefully
![How-to-Measure-the-Number-of-Luxes-with-Arduino-and-the-BH1750-Lux-Meter-Circuit](http://www.arduinocircuit.com/wp-content/uploads/2024/02/How-to-Measure-the-Number-of-Luxes-with-Arduino-and-the-BH1750-Lux-Meter-Circuit.webp)
Circuit Connections
Arduino | BH1750 Sensor |
---|---|
+5V | VCC |
GND | GND |
A4 | SDA |
A5 | SCL |
Installing Arduino IDE Software
First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow
Installing Libraries
Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow
Code Examples
The sensor offers three resolution modes, with the default being “High Resolution Mode.”
Mode | Resolution | Measurement time |
---|---|---|
High resolution Mode2 | 0.5 lux | 120ms |
High Resolution Mode | 1 lx | 120ms |
Low Resolution Mode | 4 lux | 16ms |
Furthermore, there are two operation modes: “Continuous” and “One Time.” In continuous mode, the BH1750 continuously takes measurements, while in single shot mode, it takes measurements on demand, switching to low-energy mode between requests.
Show lux level
In this example, we utilize the BH1750 to measure illuminance levels and then output the lux value through the serial port.
//For more Projects: www.arduinocircuit.com
#include <Wire.h>
#include <BH1750.h>
BH1750 luxometer;
const byte luxMode = BH1750_CONTINUOUS_HIGH_RES_MODE;
// BH1750_CONTINUOUS_HIGH_RES_MODE
// BH1750_CONTINUOUS_HIGH_RES_MODE_2
// BH1750_CONTINUOUS_LOW_RES_MODE
// BH1750_ONE_TIME_HIGH_RES_MODE
// BH1750_ONE_TIME_HIGH_RES_MODE_2
// BH1750_ONE_TIME_LOW_RES_MODE
void setup() {
Serial.begin(9600);
Serial.println(F("Initializing sensor..."));
luxometer.begin(luxMode); // Initialize BH1750
}
void loop() {
uint16_t lux = luxometer.readLightLevel(); // BH1750 reading
Serial.print(F("Illuminance: "));
Serial.print(lux);
Serial.println(" lx");
delay(500);
}
Turn on a Device with the Lux Meter
In this example, we utilize the illumination level reading in conjunction with upper and lower thresholds to control the activation and deactivation of a device.
While the integrated LED on the board is used for verification purposes, such as covering the BH1750 with a hand to observe the LED turning on and off accordingly, in practical applications, we would employ the digital output to trigger actions such as opening an awning or closing a blind. This can be achieved using components like BJT transistors, MOSFET transistors, or relay outputs.
//For more Projects: www.arduinocircuit.com
#include <Wire.h>
#include <BH1750.h>
BH1750 luxometer;;
const byte luxMode = BH1750_CONTINUOUS_HIGH_RES_MODE;
const uint16_t lowThreshold = 20;
const uint16_t highThreshold = 50;
const int pinOut = LED_BUILTIN;
void setup() {
Serial.begin(9600);
Serial.println(F("Initializing sensor..."));
luxometer.begin(luxMode); // Start BH1750
}
void setup() {
Serial.begin(9600);
Serial.println(F("Initializing sensor..."));
luxometer.begin(BH1750_CONTINUOUS_HIGH_RES_MODE); // Start sensing the sensor
pinMode(pinOut, OUTPUT);
digitalWrite(pinOut, LOW);
}
void loop() {
uint16_t lux = luxometer.readLightLevel(); // Illuminance reading
if (lux < lowThreshold)
{
digitalWrite(pinOut, HIGH);
}
else if (lux > highThreshold)
{
digitalWrite(pinOut, LOW);
}
delay(500);
}
Applications
- Ambient Light Sensing: Use the BH1750 sensor for ambient light sensing applications to measure light levels in indoor and outdoor environments.
- Brightness Control: Integrate the BH1750 sensor into brightness control systems for adjusting the brightness of displays, LED lighting, and backlighting based on ambient light levels.
- Energy Management: Incorporate the BH1750 sensor into energy management systems for optimizing energy consumption in buildings, offices, and smart homes by adjusting lighting levels based on natural light conditions.
- Smart Agriculture: Utilize the BH1750 sensor in smart agriculture systems for monitoring light levels in greenhouses and indoor farms to optimize plant growth and productivity.
- Safety and Security: Integrate the BH1750 sensor into safety and security systems for detecting changes in ambient light levels and triggering alarms or alerts in applications such as outdoor lighting control and surveillance.
Conclusion
With its advanced features and versatile applications, the BH1750 lux meter sensor offers endless possibilities for light intensity measurement in Arduino projects. Whether you’re sensing ambient light, controlling brightness, managing energy, monitoring agriculture, or enhancing safety and security, the BH1750 provides accurate and reliable lux measurements for enhanced functionality and performance. Let’s embark on the journey of measuring lux with Arduino and unlock the potential of light sensing technology!