💡 Smart Light using ESP32 + PIR
Project Details
Controller
ESP32
Sensor
PIR Motion Sensor
Output
Relay + Light
Level
Beginner
Overview
This project automatically turns ON a light when motion is detected using a PIR sensor and ESP32. It helps in energy saving and smart automation systems.
Components
- ESP32 Development Board
- PIR Sensor
- Relay Module
- Bulb / Load
- Jumper Wires
Connections
PIR Sensor
Connected to GPIO 14
Relay Module
Connected to GPIO 26
ESP32 Code
ESP32 Arduino Code
#define PIR 14
#define RELAY 26
void setup(){
pinMode(PIR, INPUT);
pinMode(RELAY, OUTPUT);
}
void loop(){
int motion = digitalRead(PIR);
digitalWrite(RELAY, motion);
}
Output
When motion is detected, the light turns ON automatically. When no motion is detected, the light turns OFF.
Flasher