Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using GY-302 Digital Light Intensity Sensor Module with Arduino

Contents

Introduction

In this tutorial, we will learn about the GY-302 module, what is a BH1750 light sensor and we will build a simple project using the GY-302 module and an Arduino.

Digital Light Intensity Sensor Module GY-302

The GY-302 Module will be our main component for this tutorial. This module has a BH1750 light sensor IC mounted on a breakout board. Figure 1 shows the module as seen in fritzing.

GY-302-article image1
Figure 1: GY-302 Digital Light Intensity Sensor Module

Pinout

The GY-302 module has five pins.

PinDescription
ADDRI2C Device Address:
0x23 (when ADDR = LOW) or 0x5c (when ADDR = HIGH)
SDAI2C
SCLI2C
GNDGround
VCC+3.3V

What is a BH1750 Light Sensor

A BH1750 light sensor senses the amount of ambient light and gives out the light intensity via the i2c interface.

Project - Arduino Light Sensor

Our project will get the analog and digital signals from the GY-302 module, and display it on the serial monitor.

Components

For this project, we need the following components:

Wiring Diagram

GY-302-article image2
Figure 2: Connection Diagram

Figure 2 shows the connection between the Arduino Uno and the GY-302 Digital Light Intensity Sensor Module.

The GY-302 module pins are connected to the Arduino Uno board as follows:

PinDescription
ADDRNo Connection
SDAA4
SCLA5
GNDGround
VCC+3.3V

Library

To make our Arduino more simple, we will use the BH1750.h library. Use the built-in Library Manager to download and install the library.

GY-302-article image3
Arduino IDE Library Manager

The Code

Below is the Arduino sketch for our project. I have added comments to explain important parts of the code. Save the code as GY-302.ino and upload it to your Arduino board.

				
					// Arduino and GY-302 module
#include <Wire.h>
#include <BH1750.h>
BH1750 GY302; // initialize BH1750 object
void setup() {
Serial.begin(9600); // initialize serial
GY302.begin(); // initialize GY-302 module
}
void loop() {
// get reading from module
uint16_t lux = GY302.readLightLevel();
// display to Serial Monitor
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
// pause for 1 second
delay(1000);
}
				
			

Project Test

Apply power to your Arduino Uno board and open the Serial Monitor in the Arduino IDE. Arduino will output the values sent by the module to the serial monitor.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top