Akash Sharma
Published © GPL3+

Smart Motion Sensor Light with ESP32

An ESP32-based motion sensor light that automatically turns on in the dark, saving energy and improving home automation.

BeginnerWork in progress2 hours16
Smart Motion Sensor Light with ESP32

Things used in this project

Story

Read more

Schematics

ESP32 PIR Motion Sensor Circuit Diagram

This diagram shows the connection between ESP32, PIR motion sensor, and LED.
The PIR sensor detects motion and sends a signal to ESP32, which controls the LED output.

Code

ESP32 Motion Sensor Light Code

Arduino
This code controls the motion sensor light system using ESP32 and PIR sensor.
When motion is detected, the LED turns ON and stays active for a few seconds before turning OFF automatically.
#define PIR_PIN 13
#define LED_PIN 12

int motionState = LOW;

void setup() {
  pinMode(PIR_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  motionState = digitalRead(PIR_PIN);

  if (motionState == HIGH) {
    Serial.println("Motion Detected!");
    digitalWrite(LED_PIN, HIGH);
    delay(5000);  // Light stays ON for 5 seconds
  } else {
    digitalWrite(LED_PIN, LOW);
  }
}

Credits

Akash Sharma
3 projects • 0 followers
Hardware Engineer, Self-Taught Innovator, Technical Writer. I design, build and break hardware systems to understand them deeply.

Comments