Smart Room Energy Saver

by anthony_11 in Circuits > Arduino

47 Views, 0 Favorites, 0 Comments

Smart Room Energy Saver

1000000178.jpg

Hi everyone, my goal is to create a device that automatically turns a light on when someone enters a room and turns it off after the room has been empty for a period of time. The system also displays its status and estimated energy savings. Thank you for showing interest.


Note: I had to use computer power for the last half of this build since my 9V battery ran out because it had been used for other projects and was old.

But a full 9V battery will work for this project.

Supplies

Electronics:

1x Arduino Uno (or compatible)

1x PIR Motion sensor (HC-SR501)

1x Breadboard

Jumper Wires

1x LCD 1602 display

LED

220 ohms resistor

Laptop compatible with Arduino IDE (or equivalent)

USB cable

9V battery

Snap-on connector


Enclosure:

Foam board

Hot glue

Hobby knife

Ruler

Pencil

Gather and Inspect Electronics

1000000110.jpg
1000000112.jpg
1000000116.jpg
1000000115.jpg
1000000114.jpg
1000000117.jpg
1000000177.jpg

Check Everything

Make sure:

  1. The Arduino powers on.
  2. The LCD isn't damaged.
  3. The PIR sensor has all three pins.
  4. You have enough jumper wires.

Once everything is working. You can now begin.

Place Components

1000000138.jpg

I like to lay out my components on a table


A good layout is:

LCD

PIR

Arduino

Breadboard


This layout leaves enough room between parts so wires aren't stretched.

Power to Breadboard

Screenshot 2026-07-06 10.31.54 PM.png
1000000140.jpg
1000000139.jpg

CONNECTIONS:

Arduino 5V to Breadboard positive rail (+)

Arduino GND to Breadboard negative rail (-)


Now every component will get power from the breadboard rails instead of directly from the Arduino.


LCD 1602 Mounting + Wiring

1000000145.jpg
1000000146.jpg
1000000147.jpg
1000000148.jpg


Connect LCD pins:

  1. Pin 1 (VSS) to GND rail
  2. Pin 2 (VDD) to 5V rail
  3. Pin 16 (K) to GND rail
  4. Pin 3 (VO) to GND rail
  5. Pin 15 (A) to 5V


LCD control connections:

Pin 4 (RS) to Arduino D12

Pin 5 (RW) to GND

Pin 6 (E) to Arduino D11


LCD data connections:

Pin 11 (D4) to Arduino D5

Pin 12 (D5) to Arduino D4

Pin 13 (D6) to Arduino D7

Pin 14 (D7) to Arduino D6

Connect the PIR Motion Sensor

1000000151.jpg
1000000153.jpg
1000000152.jpg

Find the 3 pins on the PIR sensor and follow the connections guide.


Connections:

VCC to 5V rail

GND to GND rail

OUT to Arduino D2


The sensor sends a signal to the Arduino when motion is detected.

Connect the LED Light

1000000155 (1).jpg
1000000154 (1).jpg

The LED is going to be used as a prototype for an actual room light.

Connections:

  1. Arduino D8 to 220 ohms resistor to LED positive leg.
  2. LED negative leg to GND rail.


The Arduino controls the LED

  1. High signal = light ON
  2. LOW signal = light OFF


So far, the LED should light up and the LCD too.

Install Arduino Software


(I used the Arduino cloud but the IDE should work better)


Open the Arduino IDE and Connect the Arduino Uno.

Install the LiquidCrystal library.


Now, upload this code:

#include <LiquidCrystal.h>


LiquidCrystal lcd(12, 11, 5, 4, 7, 6);


const int pirPin = 2;

const int ledPin = 8;


unsigned long lastMotionTime = 0;

unsigned long savedTime = 0;

unsigned long emptyStartTime = 0;


const unsigned long timeout = 30000;


bool lightOn = false;

bool countingSaved = false;


void setup() {

pinMode(pirPin, INPUT);

pinMode(ledPin, OUTPUT);


lcd.begin(16, 2);


lcd.print("SMART ENERGY");

delay(2000);

lcd.clear();

}


void loop() {


int motion = digitalRead(pirPin);


// Motion detected

if (motion == HIGH) {


lastMotionTime = millis();


if (!lightOn) {

lightOn = true;

digitalWrite(ledPin, HIGH);

}


countingSaved = false;


lcd.setCursor(0,0);

lcd.print("ROOM: OCCUPIED");

lcd.setCursor(0,1);

lcd.print("Light: ON ");

}



// No motion for timeout period

if (lightOn && millis() - lastMotionTime > timeout) {


lightOn = false;

digitalWrite(ledPin, LOW);


countingSaved = true;

emptyStartTime = millis();


lcd.clear();

lcd.setCursor(0,0);

lcd.print("ROOM: EMPTY");

}



// Count only after shutoff

if (countingSaved) {


savedTime = (millis() - emptyStartTime) / 1000;


lcd.setCursor(0,1);

lcd.print("Saved: ");

lcd.print(savedTime);

lcd.print("s ");

}

}

Build the Enclosure (Optional)

1000000170.jpg
1000000174.jpg
1000000172.jpg
1000000173.jpg

Create a small enclosure using foam board or cardboard.

My enclosure will use hot glue and foam board but foam-tac and cardboard also works.

Make sure the PIR can still see outside the enclosure and the USB cable can reach the Arduino.


Test the System

1000000164.jpg
1000000162.jpg
1000000163.jpg
  1. Plug the 9V battery into the Arduino.
  2. Wait for the PIR sensor to initialize.
  3. Move in front of the sensor.
  4. Confirm LED turns on and shows "ROOM: OCCUPIED"
  5. Stop moving.
  6. Wait 30 seconds.
  7. Confirm LED turns off, LCD shows "ROOM: EMPTY", and Saved timer increases.

'

Thanks to everyone for looking at my project as this is my first one published on Instructables!!