💡 Smart Light using ESP32 + PIR
Controller
ESP32
Sensor
PIR Motion Sensor
Output
Relay + Light
Level
Beginner
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.
- ESP32 Development Board
- PIR Sensor
- Relay Module
- Bulb / Load
- Jumper Wires
PIR Sensor
Connected to GPIO 14
Relay Module
Connected to GPIO 26
#define PIR 14
#define RELAY 26
void setup(){
pinMode(PIR, INPUT);
pinMode(RELAY, OUTPUT);
}
void loop(){
int motion = digitalRead(PIR);
digitalWrite(RELAY, motion);
}
When motion is detected, the light turns ON automatically. When no motion is detected, the light turns OFF.
Flasher