This is a project i've made 5 years ago. The idea came to me through my dad and my friend's mother. Me and my dad once found ourselves on a busy street during a bright summer day, the only thing off about that day was the street lights were left on. This inspired my dad to come up with this idea. Fast forward another year and my friend's mom was telling us how no one would need the street lights in the middle of the night as it isn't common for people to drive then. And, this inspired me to build this.
Smart Urban Illumination: PIR Street Light Automation
Leaving municipal lighting on at full capacity when streets are empty is a significant waste of energy. This Motion Triggered Street Light project mimics advanced smart-city infrastructure. The system uses a PIR (Passive Infrared) sensor to detect motion. When a warm object like a human or vehicle moves across its field of view, the sensor triggers the Arduino to activate the light.
It is a really simple circuit containing 2 sensors namely the PIR and the LDR. I've managed to find a program involving a PIR sensor and an LDR on the web except, it wasn't used for doing what I mentioned here. So, all I needed to do was tweak some code to create this. This is what the code basically does, we have two sensors working as inputs here. In order for this to work, i'd programmed the arduino to turn the light on only when both the sensors tell it to meaning the LDR doesn't detect light and the PIR sensor detects motion.
So now, the street lights aren't going to be left lit up during the day (Since only the PIR sensor may want to turn the light on) and even in the night time, the street lights are only going to light up if something like a person or animal walks by (Since both the sensors need to be in agreement for the light to turn on). This will not only save us a lot of energy but also help wild life.
Utilizing The Pyroelectric Sensor (HC-SR501)
The PIR sensor requires absolutely zero code libraries; it operates entirely on raw physical hardware output!
- The white faceted Fresnel lens separates the street into microscopic thermal slices.
- A warm human body walking across these slices causes voltage shifts inside the semiconductor core.
- The Module outputs a pure
3.3V Logic HIGHonto its Data pin natively. The Arduino reads this perfectly asHIGH!
int pirSensor = 2; // Physical PIR Trigger input
int streetLight = 9; // PWM enabled LED pin!
void setup() {
pinMode(pirSensor, INPUT);
pinMode(streetLight, OUTPUT);
// Wait 30 seconds upon boot for the PIR to map the environment thermally!
delay(30000);
}
void loop() {
int motionDetected = digitalRead(pirSensor);
if (motionDetected == HIGH) {
// Target acquired! Blast illumination to maximum!
analogWrite(streetLight, 255);
} else {
// Empty street. Drop to eco-friendly 10% brightness!
analogWrite(streetLight, 25);
}
}
Power Scaling with PWM and MOSFETs
If you want to actually power a 12V heavy LED Floodlight, the Arduino cannot do this directly. A mechanical relay is also a bad choice because it can only do ON or OFF; it cannot "DIM"!
- The system must explicitly utilize an IRLZ44N Logic-Level N-Channel MOSFET!
- The Arduino sends a
analogWrite()PWM frequency to the MOSFET Gate. - The MOSFET acts as a blazing fast solid-state dimmer switch, dynamically allowing a massive 12V Battery to flow precisely into the floodlights, executing the 10% Dimmer economy mode flawlessly without wasting power as heat!
Smart City Infrastructure Loadout
- Arduino Uno/Nano (Running the logic matrices constantly).
- HC-SR501 PIR Sensor (Must face entirely away from direct intense sunlight to prevent thermal blindness anomalies!).
- Logic Level N-Channel MOSFET (IRLZ44N) with a 10K pull-down resistor attached from Gate to Ground to prevent the lights from flickering if the Arduino crashes!
- 12V High-Amperage LED Floodlight Array (Simulating the physical street illumination).
- LDR (Photoresistor) [Optional Upgrade] (Wire an LDR so the system fundamentally refuses to trigger the lights during full daylight hours, ensuring absolute energy efficiency!).