Table of Contents
- Introduction
- Components and Hardware Setup
- Wiring Diagram and Connections
- Complete Code with Explanation
- Customization and Improvements
- Troubleshooting Common Issues
- Advanced Features and Extensions
- Frequently Asked Questions
- Conclusion
Introduction
The arduino street light ldr project is one of the most popular Arduino builds among Indian engineering students and electronics hobbyists. This comprehensive guide covers every aspect of building a Automatic Street Light with LDR Sensor system — from component selection and wiring to complete code and real-world deployment tips.
Automatic street lights that turn on at dusk and off at dawn are a practical energy-saving application that demonstrates light sensor interfacing, threshold-based control, and relay switching. The LDR (Light Dependent Resistor) changes resistance based on ambient light — high resistance in darkness, low resistance in bright light. The Arduino reads this change and controls a relay to switch the street light.
This project is commonly submitted for diploma and B.Tech projects in electrical and electronics engineering. The commercial version of this technology is used in street lighting across Indian cities, saving significant electricity by ensuring lights operate only when needed.
Components and Hardware Setup
- Arduino Uno
- LDR (Light Dependent Resistor) + 10K ohm resistor (voltage divider)
- 5V single-channel relay module
- 12V LED lamp or bulb (for demonstration)
- 12V power supply
- 16×2 I2C LCD (optional, for displaying light level)
The LDR and 10K resistor form a voltage divider connected to analog pin A0. In bright light, the LDR resistance drops to ~1K, giving a high voltage reading. In darkness, resistance rises to ~1M, giving a low voltage reading. The Arduino compares this reading to a threshold to decide when to turn the light on or off.
Wiring Diagram and Connections
// LDR voltage divider: 5V -> LDR -> A0 -> 10K -> GND
// Relay: IN -> pin 7, VCC -> 5V, GND -> GND
// Lamp: Connected through relay COM and NO terminals
const int LDR_PIN = A0;
const int RELAY_PIN = 7;
const int THRESHOLD = 300; // Adjust based on your environment
void setup() {
Serial.begin(9600);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); // Relay OFF (active LOW)
}
void loop() {
int lightLevel = analogRead(LDR_PIN);
Serial.print("Light: "); Serial.println(lightLevel);
if (lightLevel < THRESHOLD) {
// Dark - turn light ON
digitalWrite(RELAY_PIN, LOW);
Serial.println("Street light ON");
} else {
// Bright - turn light OFF
digitalWrite(RELAY_PIN, HIGH);
Serial.println("Street light OFF");
}
delay(1000);
}
Complete Code with Explanation
// Advanced automatic street light with hysteresis and timing
const int LDR_PIN = A0;
const int RELAY_PIN = 7;
const int ON_THRESHOLD = 250; // Turn ON below this
const int OFF_THRESHOLD = 400; // Turn OFF above this
bool lightOn = false;
unsigned long lastChange = 0;
const unsigned long DEBOUNCE = 5000; // 5-second delay prevents flickering
void setup() {
Serial.begin(9600);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH);
}
void loop() {
int lightLevel = analogRead(LDR_PIN);
// Hysteresis prevents rapid on/off at threshold
if (!lightOn && lightLevel DEBOUNCE) {
lightOn = true;
digitalWrite(RELAY_PIN, LOW);
lastChange = millis();
} else if (lightOn && lightLevel > OFF_THRESHOLD && millis() - lastChange > DEBOUNCE) {
lightOn = false;
digitalWrite(RELAY_PIN, HIGH);
lastChange = millis();
}
Serial.print("Light:"); Serial.print(lightLevel);
Serial.print(" State:"); Serial.println(lightOn ? "ON" : "OFF");
delay(500);
}
The hysteresis (different ON and OFF thresholds) prevents the light from flickering when ambient light is near the threshold. The 5-second debounce delay adds further stability against transient light changes (car headlights, cloud shadows).
Customization and Improvements
- Add wireless connectivity: Integrate an ESP8266 WiFi module to send sensor data to a cloud dashboard for remote monitoring
- Data logging: Add an SD card module and DS3231 RTC for timestamped data recording over days or weeks
- OLED display: Replace Serial Monitor output with a 0.96-inch I2C OLED for a standalone, computer-free device
- Mobile notifications: Use Blynk or IFTTT to send push notifications to your phone when alert conditions are met
- Enclosure: 3D print or laser-cut a professional enclosure. IP65-rated enclosures are essential for outdoor installations in Indian weather conditions
Troubleshooting Common Issues
- Sensor not responding: Check VCC voltage (3.3V vs 5V), verify wiring polarity, test with I2C scanner for I2C devices, try a different module
- Erratic readings: Add filtering (moving average), add decoupling capacitors, use shorter wires, separate sensor wires from motor/relay wires
- Arduino resets during operation: Power supply insufficient for all modules — use external 5V supply, add bulk capacitor (470uF) on power rail
- Display shows wrong data: Check I2C address, verify library version matches hardware, clear display before each update
Advanced Features and Extensions
For a competition or exhibition-quality project, add multiple sensor types for comprehensive monitoring, implement a web-based dashboard accessible from any device, add voice alerts using a DFPlayer Mini MP3 module, and create a 3D-printed enclosure with laser-cut acrylic panels. These additions transform a basic sensor project into a polished product demonstration.
Frequently Asked Questions
Is this project suitable for engineering college submission?
Yes, this is a frequently submitted project for B.Tech, diploma, and BCA/MCA courses in India. To make it stand out, add IoT connectivity (WiFi data upload), a mobile app interface, and a well-documented project report with circuit diagrams, flowcharts, and test results.
Can I power this project with batteries?
Yes, use a 9V battery for quick demos or a 3.7V LiPo with a 5V boost converter for extended portable operation. A 2600 mAh 18650 cell typically provides 8-12 hours depending on the modules connected. Add a TP4056 module for USB charging.
Where can I buy components in India?
Zbotic.in offers the widest selection of Arduino boards, sensors, and accessories with reliable shipping across India. All products come with documentation and technical support. For local shopping, major electronics markets in Mumbai, Bangalore, Delhi, and Chennai stock Arduino components.
How do I make this project weatherproof for outdoor use?
Use an IP65-rated junction box as the enclosure. Route wires through cable glands. Apply conformal coating spray on the PCB for moisture protection. For the sensor, use a waterproof variant or mount it inside a vented housing that allows air flow while blocking water and dust.
Conclusion
The Automatic Street Light with LDR Sensor project is a practical, educational build that demonstrates core embedded systems concepts using affordable, accessible components. Whether you are submitting it as a college project, displaying it at a maker event, or deploying it as a real-world solution, the Arduino platform provides the flexibility and community support to bring your vision to life.
Add comment