Stufin
Home Quick Cart Profile

GY-302 BH1750 Light Intensity Module

Buy Now on Stufin

GND

Ground

SCL (I2C Clock)I2C Clock Line
SDA (I2C Data)I2C Data Line

Applications

The GY-302 BH1750 Light Intensity Module is suitable for a wide range of applications, including

Smart home automation systems

Environmental monitoring systems

Industrial lighting control systems

Automotive systems

Wearable devices

Robotics and automation

Conclusion

The GY-302 BH1750 Light Intensity Module is a high-performance, accurate, and easy-to-use light sensor module, ideal for various IoT applications. Its compact design, low power consumption, and digital output make it an excellent choice for developers and engineers working on projects that require ambient light intensity measurement.

Pin Configuration

  • GY-302 BH1750 Light Intensity Module Documentation
  • Overview
  • The GY-302 BH1750 Light Intensity Module is a digital light sensor module designed to measure ambient light intensity. It is based on the BH1750FVI chip, which is a digital light sensor with a high sensitivity and high resolution. The module is useful for a variety of applications, including IoT projects, robotics, and home automation.
  • Pin Description
  • The GY-302 BH1750 Light Intensity Module has 6 pins, which are described below:
  • 1. VCC (Power Supply)
  • Pin Type: Power Input
  • Description: This pin is used to supply power to the module. Typically, a voltage of 3.3V or 5V is used.
  • Connection: Connect to a power source (e.g., a microcontroller's VCC pin or a battery).
  • 2. GND (Ground)
  • Pin Type: Ground
  • Description: This pin is used to ground the module.
  • Connection: Connect to a ground pin on the microcontroller or a common ground point.
  • 3. SCL (Clock)
  • Pin Type: I2C Clock
  • Description: This pin is used for I2C communication and acts as a clock signal.
  • Connection: Connect to the SCL pin on a microcontroller (e.g., Arduino's SCL pin).
  • 4. SDA (Data)
  • Pin Type: I2C Data
  • Description: This pin is used for I2C communication and acts as a data signal.
  • Connection: Connect to the SDA pin on a microcontroller (e.g., Arduino's SDA pin).
  • 5. ADDR (Address)
  • Pin Type: I2C Address Select
  • Description: This pin is used to select the I2C address of the module. Connecting this pin to VCC or GND will change the I2C address.
  • Connection: Leave floating (unconnected) for default address, or connect to VCC or GND to change the address.
  • 6. Vin (Analog Output)
  • Pin Type: Analog Output
  • Description: This pin outputs an analog voltage proportional to the measured light intensity.
  • Connection: Connect to an analog input pin on a microcontroller (e.g., Arduino's A0 pin).
  • Connection Structure
  • To connect the GY-302 BH1750 Light Intensity Module to a microcontroller (e.g., Arduino), follow this structure:
  • VCC Microcontroller's VCC pin
  • GND Microcontroller's GND pin
  • SCL Microcontroller's SCL pin
  • SDA Microcontroller's SDA pin
  • ADDR Leave floating (unconnected) for default address, or connect to VCC or GND to change the address
  • Vin Microcontroller's Analog Input pin (e.g., A0)
  • Note: Make sure to use a proper power supply and grounding scheme to ensure reliable operation of the module.

Code Examples

GY-302 BH1750 Light Intensity Module Documentation
Overview
The GY-302 BH1750 Light Intensity Module is a digital light sensor module that measures the ambient light intensity in lux. It is based on the BH1750FVI, a digital ambient light sensor from Rohm Semiconductor. The module provides a simple way to measure light intensity in various applications, including IoT projects, robotics, and home automation.
Features
Measures light intensity in lux (0-65535 lux)
 Digital output via I2C interface
 Adjustable measurement resolution (1-128 lux) and measurement time (50-200 ms)
 Low power consumption (3.5 A typical)
 Operating voltage: 2.4-5.5 V
Pinout
VCC: Power supply (2.4-5.5 V)
 GND: Ground
 SCL: I2C clock line
 SDA: I2C data line
 ADDR: I2C address selection pin (default: 0x23)
Code Examples
### Example 1: Basic Light Intensity Measurement (Arduino)
This example demonstrates how to use the GY-302 BH1750 Light Intensity Module with an Arduino board to measure the ambient light intensity.
```c++
#include <Wire.h>
#define BH1750_ADDRESS 0x23
void setup() {
  Serial.begin(9600);
  Wire.begin();
}
void loop() {
  uint16_t lux = readLightIntensity();
  Serial.print("Light Intensity: ");
  Serial.print(lux);
  Serial.println(" lux");
  delay(1000);
}
uint16_t readLightIntensity() {
  Wire.beginTransmission(BH1750_ADDRESS);
  Wire.write(0x00); // Command to start measurement
  Wire.endTransmission();
  Wire.requestFrom(BH1750_ADDRESS, 2);
  uint16_t lux = Wire.read() << 8 | Wire.read();
  return lux;
}
```
### Example 2: IoT Application with ESP32 and Wi-Fi (MicroPython)
This example demonstrates how to use the GY-302 BH1750 Light Intensity Module with an ESP32 board and MicroPython to send the measured light intensity to a remote server using Wi-Fi.
```python
import machine
import ubinascii
from machine import I2C, Pin
import ujson
import wlan
# Initialize I2C and Wi-Fi
i2c = I2C(scl=machine.Pin(22), sda=machine.Pin(21))
wlan.connect('your_wifi_ssid', 'your_wifi_password')
# Define the GY-302 BH1750 module
bh1750 = I2C(BH1750_ADDRESS, freq=400000)
while True:
    # Measure light intensity
    bh1750.write(b'x00')  # Command to start measurement
    lux = bh1750.read(2, 'B')[0] << 8 | bh1750.read(2, 'B')[1]
# Create a JSON payload
    payload = {'device_id': 'ESP32_BH1750', 'light_intensity': lux}
    payload_json = ujson.dumps(payload)
# Send the payload to the remote server
    url = 'http://your_remote_server.com/light_intensity'
    headers = {'Content-Type': 'application/json'}
    response = wlan.post(url, headers, payload_json)
    print(response.json())
# Wait for 1 minute before taking the next measurement
    machine.sleep(60000)
```
Note: Ensure you replace the placeholders (`your_wifi_ssid`, `your_wifi_password`, and `your_remote_server.com`) with your actual Wi-Fi credentials and remote server URL.