How To Connect BH1750 Light Sensor To Arduino

Table of contents:

How To Connect BH1750 Light Sensor To Arduino
How To Connect BH1750 Light Sensor To Arduino

Video: How To Connect BH1750 Light Sensor To Arduino

Video: How To Connect BH1750 Light Sensor To Arduino
Video: Light Sensor for Arduino- BH1750 Tutorial 2024, December
Anonim

This time we will connect the digital 16-bit light sensor BH1750 (luxometer), implemented on the GY-302 module, to the Arduino.

Light sensor BH1750
Light sensor BH1750

It is necessary

  • - Arduino;
  • - module GY-302 with a digital light sensor BH1750;
  • - Personal Computer.

Instructions

Step 1

Consider the GY-302 module with the BH1750 sensor. The BH1750 sensor is a digital 16-bit digital illumination sensor that sets its measurement range: from 1 to 65535 lux. The BH1750 sensor is sensitive to visible light and is virtually unaffected by infrared radiation, i.e. responds to the same spectral range as the human eye. As a result, such sensors are widely used in modern electronic equipment - mobile devices, photo and video cameras, smart home systems and many others.

The module is connected via a two-wire I2C interface, and power is supplied from +5 volts. The I2C interface in Arduino boards is implemented on analog pins A4 and A5, which are responsible for SDA (data bus) and SCL (clock bus), respectively. The ADDR pin of the GY-302 can be left unconnected or connected to ground.

Wiring diagram for light sensor BH1750 to Arduino
Wiring diagram for light sensor BH1750 to Arduino

Step 2

We will not delve into the intricacies of the implementation of the interface for the interaction of the BH1750 sensor with the Arduino, but we will use the ready-made library. You can download it here: https://github.com/claws/BH1750/archive/master.zip. Unpack the downloaded archive into the directory with the "Arduino IDE / libraries" development environment.

Let's write this sketch and upload it to the Arduino. In the sketch, every 100 ms we read the illumination readings in lux from the BH1750 sensor and output this data to the serial port.

Sketch of work with light sensor BH1750
Sketch of work with light sensor BH1750

Step 3

Let's connect the BH1750 light sensor to the Arduino as shown above. Let's connect the Arduino board to the computer. Launch the Arduino IDE and open the serial monitor with the "Ctrl + Shift + M" keyboard shortcut or through the "Tools" menu. In the monitor of the serial port, the illumination values from our BH1750 sensor will run. Point the sensor towards a light source, then block it from the light, and you will see how the reading changes.

Recommended: