Switches off your desk lamp and fan when you walk away.
Built and tested by Shahan Fathima K · Industrial Robotics Institute

An energy saver for study or office desks. A PIR motion sensor checks whether someone is sitting at the desk. While someone is there, a relay keeps the lamp, fan or charger powered; if no movement is seen for a set time, the ESP8266 switches the relay off to stop wasting electricity.
| Component | Qty |
|---|---|
| ESP8266 NodeMCU | 1 |
| PIR Motion Sensor | 1 |
| Relay Module | 1 |
| LED (optional indicator) | 1 |
| Resistor 220Ω (for LED) | 1 |
| Jumper Wires | As needed |
| Power Supply | 1 |
| From | Connect to |
|---|---|
| PIR VCC | 5V (VIN) |
| PIR GND | GND |
| PIR OUT | D1 |
| Relay IN | D2 |
| Relay VCC / GND | 5V (VIN) / GND |
| LED + (via resistor) | D3 |
| LED − | GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.
#define pirPin D1
#define relayPin D2
#define ledPin D3
unsigned long lastMotionTime = 0;
unsigned long delayTime = 10000; // 10 s for demo
void setup()
{
pinMode(pirPin, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(relayPin, LOW); // devices OFF at start
}
void loop()
{
int motion = digitalRead(pirPin);
if (motion == HIGH)
{
lastMotionTime = millis();
digitalWrite(relayPin, HIGH); // devices ON
digitalWrite(ledPin, HIGH);
}
if (millis() - lastMotionTime > delayTime)
{
digitalWrite(relayPin, LOW); // devices OFF
digitalWrite(ledPin, LOW);
}
delay(200);
}An energy saver for study or office desks. A PIR motion sensor checks whether someone is sitting at the desk.
You need: ESP8266 NodeMCU (1), PIR Motion Sensor (1), Relay Module (1), LED (optional indicator) (1), Resistor 220Ω (for LED) (1), Jumper Wires, Power Supply (1). Software: Arduino IDE.
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.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-061). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.