Embedded SystemsBeginnerPRJ-152

Advanced Smart Street Light Controller Using ESP8266

Off by day, dim at night, and full brightness when someone passes.

Built and tested by Drisya K S · Industrial Robotics Institute

ESP8266 NodeMCU

Arduino IDE, Blynk (optional)

LevelBeginner
Build time1–2 hours
BoardESP8266 NodeMCU
Parts9 components

What is the Advanced Smart Street Light Controller?

An energy-saving street light. An LDR detects whether it is day or night, and a PIR sensor detects people or vehicles. During the day the light stays off; at night it glows dim, and it switches to full brightness whenever motion is detected, using PWM through a MOSFET.

How it works

  1. The LDR reading tells day from night (below 500 = night).
  2. During the day the light stays off.
  3. At night with no motion, the light runs dim (PWM 300).
  4. At night when the PIR sees movement, the light goes to full brightness (PWM 1023).

Parts list

ComponentQty
ESP8266 NodeMCU (or Arduino Uno)1
LDR1
Resistor 10kΩ1
PIR Motion Sensor1
MOSFET or Relay Module1
LED / Bulb1
Jumper WiresAs needed
Breadboard1
Power Supply1

Software

  • Arduino IDE
  • Blynk (optional)

Wiring and connections

FromConnect to
LDR one leg3.3V
LDR other legA0
10kΩ resistorA0 to GND
PIR VCC5V (VIN)
PIR GNDGND
PIR OUTD5
MOSFET gateD6 (PWM)
LED / bulb −MOSFET drain
MOSFET sourceGND

How to build the Advanced Smart Street Light Controller

  1. Build the LDR voltage divider on A0.
  2. Connect the PIR output to D5.
  3. Drive the LED strip or bulb through a logic-level MOSFET on D6.
  4. Upload the code and open the Serial Monitor at 9600 baud.
  5. Cover the LDR to simulate night and wave in front of the PIR to test.
  6. Adjust the 500 night threshold for your location.

Advanced Smart Street Light Controller code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.

int ldrPin = A0;
int pirPin = D5;
int ledPin = D6;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int lightValue = analogRead(ldrPin);
  int motion = digitalRead(pirPin);

  Serial.println(lightValue);

  if (lightValue < 500) {            // night
    if (motion == HIGH) {
      analogWrite(ledPin, 1023);     // bright
    } else {
      analogWrite(ledPin, 300);      // dim
    }
  } else {
    analogWrite(ledPin, 0);          // day: off
  }

  delay(200);
}

Real-world uses

  • Street and highway lighting
  • Campus and parking lighting
  • Corridors and staircases
  • Smart city demos

Frequently asked questions

What is a Advanced Smart Street Light Controller?

An energy-saving street light. An LDR detects whether it is day or night, and a PIR sensor detects people or vehicles.

What components are needed for the Advanced Smart Street Light Controller?

You need: ESP8266 NodeMCU (or Arduino Uno) (1), LDR (1), Resistor 10kΩ (1), PIR Motion Sensor (1), MOSFET or Relay Module (1), LED / Bulb (1), Jumper Wires, Breadboard (1), Power Supply (1). Software: Arduino IDE, Blynk (optional).

Is the Advanced Smart Street Light Controller project good for beginners?

Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.

Where can I get the code for the Advanced Smart Street Light Controller?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Advanced Smart Street Light Controller?

Yes. IRI sells a kit with the parts for this project (PRJ-152). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo