How to Measure the Number of Luxes with Arduino and the BH1750 Lux Meter

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 UNO1Buy Link
BH1750 Light Sensor1Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper Wires4Buy Link
Breadboard1Buy 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.

SituationLuxes
Evening0.001-0.02
full moon0.2-0.6
Cloudy day, indoors5-50
Cloudy day, outdoors50-500
Sunny day, indoors100-1000
Under direct sunlight100,000
Bedroom, living room150-300
Office/reading table500-700
Supermarkets/exhibitions750-1000
Drawing/work tables1000-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

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

Pin Configuration of BH1750 Sensor

PinDescription
VCCModule power supply: 2.4V to 3.6V, typically 3.0V.
GNDGround, connected to ground of the circuit
SCLSerial Clock Line provides clock pulses for I2C communication.
SDASerial Data Address for data transfer in I2C communication.
ADDAddress pin selects module address in a multi-module setup.

Features

  1. Digital Output: Provides digital output data representing the intensity of ambient light for easy integration with microcontrollers like Arduino.
  2. Low Power Consumption: Designed for low power operation, making it suitable for battery-powered applications.
  3. Compact Design: Compact and lightweight design for easy integration into electronic projects.
  4. High Sensitivity: Offers high sensitivity to detect subtle changes in light intensity.
  5. Adjustable Sensitivity: Allows for adjustment of sensitivity settings to optimize light sensing performance in different environments.

Specifications

  1. Measurement Range:
    • Wide measurement range suitable for detecting various light levels.
  2. Resolution:
    • High resolution for accurate lux measurements.
  3. Accuracy:
    • Precise light intensity measurement accuracy for reliable results.
  4. Communication Interface:
    • I2C (Inter-Integrated Circuit) interface for communication with Arduino.
  5. 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

Circuit Connections

ArduinoBH1750 Sensor
+5VVCC
GNDGND
A4SDA
A5SCL

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.”

ModeResolutionMeasurement time
High resolution Mode20.5 lux120ms
High Resolution Mode1 lx120ms
Low Resolution Mode4 lux16ms

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

  1. Ambient Light Sensing: Use the BH1750 sensor for ambient light sensing applications to measure light levels in indoor and outdoor environments.
  2. 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.
  3. 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.
  4. 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.
  5. 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!

Leave a Comment


error: