Light Up with Intelligence: Getting Started with GY-30 Light Sensor and Arduino Nano to Control an LED
- EmbeddedBrew
- 7 days ago
- 3 min read
What if your lights could think? Imagine your bedroom lamp turning on as dusk sets in or your streetlights switching off at sunrise—all without you lifting a finger. This project takes you a step closer to that future. Using the GY-30 Light Sensor (based on BH1750) and Arduino Nano, you’ll learn to automatically control an LED based on the ambient light intensity. This beginner-friendly yet powerful project introduces the fundamentals of sensor interfacing, analog-to-digital interaction, and threshold-based automation.
By the end of this tutorial, you’ll not only understand how to work with the BH1750 light sensor but also how to use it in real-world scenarios for smart automation projects.
1. Introduction
This project demonstrates how to control an LED based on the brightness of surrounding light using the GY-30 (BH1750) digital light sensor. It acts like an electronic eye, capable of measuring light in lux and sending this data to the Arduino. With a simple decision-making logic embedded in the code, the LED turns ON when the room gets dark and OFF when it's bright—perfect for automating lighting systems in homes, gardens, and greenhouses.
From automated home lighting systems to precision greenhouse farming, the ability to respond to changing light conditions opens the door to a wide array of smart applications. This setup is a foundational block for:
Smart streetlights that reduce energy consumption.
Indoor farming setups where plants receive light based on sunlight availability.
Wearable tech that adjusts screen brightness automatically.
Integration with IoT platforms to enable remote monitoring and control via the internet.
As technology moves toward intelligent environments, mastering such sensor-based projects builds a strong skill base in embedded systems and automation.
2. Components Required
To build this smart light control project, you’ll need the following tools and components:
Component | Description |
Arduino Nano | Compact microcontroller board for prototyping |
GY-30 Light Sensor (BH1750) | Digital ambient light sensor measuring lux |
LED | Output indicator that glows in the dark |
220Ω Resistor | Limits current to the LED |
Breadboard | For connecting components without soldering |
Jumper Wires | For making electrical connections |
USB Cable (Mini-B) | To program the Arduino Nano |
Arduino IDE | Software for writing and uploading code |
3. Step-by-Step Build Guide: From Setup to Coding
A. Circuit Diagram & Hardware Connections
Here’s how you should connect the GY-30 Light Sensor and the LED to the Arduino Nano:
GY-30 (BH1750) to Arduino Nano:
VCC → 3.3V
GND → GND
SDA → A4
SCL → A5
LED to Arduino Nano:
Anode (+) → Digital Pin D9 (through a 220Ω resistor)
Cathode (-) → GND
Note: BH1750 communicates via I2C protocol. The Nano’s dedicated I2C pins are A4 (SDA) and A5 (SCL). Ensure no other I2C device is interfering.
B. Software Setup & Arduino Code
1. Installing the BH1750 Library
To communicate with the GY-30, you’ll need the appropriate library. Follow these steps:
Open Arduino IDE.
Go to Sketch > Include Library > Manage Libraries.
Search for "BH1750".
Install the BH1750 by Christopher Laws library.
This library simplifies reading lux values from the sensor.
2. The Arduino Code
Here’s the complete code for our project:
a. For Checking Light Intensity on Serial Monitor
b. For controlling the LED according to a Threshold
c. For controlling LED Brightness according to threshold
3. Uploading Code and IDE Settings
Follow these steps to upload the code:
Connect Arduino Nano using the USB Mini-B cable.
Open Arduino IDE.
Select board: Arduino Nano from Tools > Board.
Select processor: ATmega328P (Old Bootloader) if you're facing upload issues.
Choose the correct COM Port.
Click the Upload button.
4. Results and Enhancements
Observed Behavior:
The serial monitor will display real-time lux readings.
When the ambient light falls below 100 lux, the LED turns ON.
When the light level exceeds the threshold, the LED turns OFF.
For the intensity control, you can notice a change in the LED Brightness with a change in the lux value.
How to Improve the Project:
Add an OLED Display: Show lux values visually in real-time.
Use a Relay Module: Control AC-powered devices like lamps.
Mobile Notifications: Integrate with NodeMCU/ESP32 to send alerts when light levels change.
Dynamic Threshold: Use a potentiometer or menu interface to change light sensitivity.
Data Logging: Store lux values over time on an SD card or cloud server.
These upgrades can transform a simple sensor project into a full-fledged automation system.
5. Conclusion
This project is more than just lighting an LED—it's about building systems that respond to the environment intelligently. By interfacing the GY-30 Light Sensor with the Arduino Nano, you’ve learned how to:
Read sensor data digitally using I2C.
Implement decision-making using thresholds.
Control output devices (LED) based on real-world inputs.
This is an excellent first step into sensor-driven automation, a core skill in today’s embedded and IoT industries.
👉 Looking to master more such skills?Explore hands-on courses and mini-projects at Skill-Hub by EmbeddedBrew and take your embedded journey to the next level.
Коментарі