Automatic_Room_Light_Controller_Using_Arduino_and_PIR_sensors
Automatic_Room_Light_Controller_Using_Arduino_and_PIR_sensors
MU MIT
PROJECT MEMBERS:
II
Simulation and Result ..................................................................................................... 21
5.1 Software design ..................................................................................................... 21
5.1.1 Arduino IDE ................................................................................................. 21
5.1.2 Proteus 8......................................................................................................... 21
5.2 Testing................................................................................................................... 22
Chapter Six...................................................................................................................... 27
Conclusion and Recommendation .................................................................................. 27
6.1 Conclusion ............................................................................................................ 27
6.2 Recommendation .................................................................................................. 27
References ....................................................................................................................... 28
Appendix ......................................................................................................................... 29
III
List of figures
Figure1: flow chart of project methodology ………………………………………...4
Figure2: Arduino UNO microcontroller……………………………………………...8
Figure3: PIR sensor ………………………………………………………………....10
Figure4: light dependent resistor……………………………………………………...11
Figure5: Pictorial view of LCD Display……………………………………………...11
Figure 6: schematic view of an LCD screen………………………………………….12
Figure7: relay switch………………………………………………………………….12
Figure 8: lamp…………………………………………………………………………13
Figure 11: Block diagram of the automatic room light controller …………………….14
Microcontroller………………………………………………………………………...22
Figure16: system response schematic of the designed system when LDR lighted……23
Figure 17: system response schematic of the designed system when LDR no lighted and
there is occupancy …………………………………………………………………...24
Figure18: system response schematic of the designed system when LDR no lighted and
leaves one person, but still there is occupancy ……………………………………….25
Figure19: system response schematic of the designed system when LDR no lighted and
there is no occupancy ………………………………………………………………...26
IV
List of symbols and abbreviations
COM common
DC direct current
KB kilobyte
NO normally open
Pf Pico farad
V
Chapter One
Introduction
1.1 Overview
In recent years, we common people are interested to interact with technology and thus
make our day to day tasks easier by creating automation. Even we are really feeling the
seriousness to save energy for ours and future generations. People are getting lazy to even
do simple tasks like switching off the lights while going outdoors, which results in a large
amount of energy wastage. Such kind of carelessness is generally seen in public and
private buildings, industries, schools, colleges and most of us are disinterested to switch
off electronic appliances such as fans and lights when not in use. This has resulted in
increased power consumption in home areas on a large scale. Moreover, unusable power
consumption occurs in the absence of human beings in public and private sectors.
In today’s world, there is a continuous need for automatic appliances. With the increase
in standard of living, there is a sense of urgency for developing circuits that would ease
the complexity of life. The energy crisis is one of the major problems that the world
needs to resolve for sustainable economic development. Electrical energy lighting makes
up the largest part of power consumption in the world particularly through the use of
lamps [1]. These lamps are mainly controlled using ordinary switches that are manually
operated. Sometimes the intensity from outside is sufficient to illuminate the room.
Therefore, there is no need to turn any light ON. Due to a busy schedule and competitive
world, human beings cannot spare time to perform their daily activities manually. One
of the most common things that one forgets to do is switching OFF the lights whenever
they are not required. This leads to wastage of electrical power and an increase in the
payment for such services. Hence, the need of some power management to save energy.
The importance of electrical energy is increasing everyday with the impact of
technological advancements [2].
1
The main problem addressed by this project is the inefficient use of lighting in rooms
that are not occupied. The lack of an automated system to control the lights based
on occupancy results in increased energy consumption and higher operational costs.
To avoid all such situations, we designed this project called “Automatic room
light controller with visitor counter using Arduino and PIR sensors”. user can
reduce electricity usage and save some amount of money thereby. When there is
no human presence or motion the room lights will get switched off on their own. It
is an efficient way to save energy and human efforts.
Lighting systems rely on manual operation, which is prone to human error, such as
forgetting to turn off lights when leaving a room. This issue is exacerbated in large
buildings where multiple rooms are involved, leading to significant energy wastage.
This happens due to negligence or because we forgot to turn lights off or when we
are in a hurry.
2
❖ To make a controller-based model to count the number of persons visiting a
particular room.
Various rooms like seminar hall, conference hall where the capacity of room is limited
and should not be exceeded by displaying the actual number of persons inside the room
A. Classrooms, study rooms in colleges, to take count the accurate number of
students in the classroom and control the room light accordingly.
B. Our homes because many times we come out of our bedroom or any other room
and we forgot to turn off the room light.
C. Cinema halls to count the number of persons entering inside. So that these places
should not get overcrowded to avoid congestion.
a. It is used when only single person enters to the sensitivity region of the sensor
hence if two persons are crossing simultaneously it detects as one person.
b. The only person who can communicate with the control module is the person
who is in the receptionist and security units.
c. Only devices with electrical controlling input ports will be possible targets
for the project.
3
1.6 Organization of Project
In this project a clear outline has been provided with descriptions of each chapter are
given below: This project consists of 6 chapters. Chapter 1 gives an overview of the
entire project including a statement of the problem, project objective, and project scope.
Chapter 2 reviews and related works with compression with the system have been
discussed. Chapter 3 covers the descriptions of system components. chapter 4 discusses
the design and development of the system selected to construct an automatic room light
controller, and interfacing of materials with Arduino and working operation of the
design. Chapter five, the result of each module displayed on LCD will be shown in
picture and the software of embedded system design of the final design’s program flow
is explained in detail and Chapter six, summarizes Conclusion and recommendations.
4
Chapter Two
Literature Review
This chapter reviews some references from previous projects, journals, articles, and book and
data sheets. A brief discussion of each work has been discussed and critiques and limitations
of each work are also explained. It highlights briefly some of the light control designs that have
been made using different control modules that have been made previously.
All of the journal only viewed that automation of the room which has systems switch ON
even in day if there is occupancy in the room, but we modified this using LDR sensor to
turn OFF during day time even if there is occupancy.
This project uses a visitor counter and PIR sensor to detect human presence and operate
room lights. Human presence is detected using a PIR sensor at the entrance. When the
LDR sensor’s output becomes low and a person enters the room there is an increment in
the visitor counter which leads to turn ON action of lights controlled by a microcontroller
program. And when the person leaves room lights go OFF following decrement in counter.
6|Page
Chapter Three
System components description
3.1 Introduction
This chapter covers all parts of ARLC from the system overview to the individual components
required to assemble the visitor counter to provide effective crowd management as in
monitoring and controlling. The design in its sense has four main sections and circuits as
shown in Figure 3.1. These include Detection section (IR sensor circuitry), microcontroller
section, alerting section (LCD and relay) and power supply circuit. The description of these
components is also illustrated as follows
D. Relay
G. Load (Lamp)
H. jumper Wires
7|Page
A, Power Supply:
Here we used +12V dc power supply. The main function of this block is to provide the
required amount of voltage to essential circuits. +12V is given to the relay driver. There are
different ways to power our Arduino board. The most common way is through the USB
connector available on every board. we use USB connector method,
8|Page
Below is a specification of Arduino UNO
Operating Voltage 5V
SRAM 2 KB
EEPROM 1 KB
9|Page
C, Passive Infrared sensor as a sensing unit:
This is one of the main parts of our project. The main intention of this block is to sense the
person. For sensing the person, we use a TSOP 1738 (PIR) sensors. By using this sensor and
its related circuit diagram we can count the number of persons.
10 | P a g e
light shines on the LDR semiconductor, so more electrons are released to conduct electricity
and the resistance falls further. LDRs are very useful components that can be used for a variety
of light sensing applications.
11 | P a g e
The LCD screen will display “Capacity Full” when the microcontroller detects that the
required number of visitors supposed to occupy a particular building is exceeded.
RL
RLY-SPNO
G, Load
12 | P a g e
Figure 8: lamp
H, Resistors
The property of a material which opposes the flow of the electrons is resistance or the element
is called resistor. The unit of resistance is Ohms. There are two types of resistor.
These are variable resistors and fixed resistors.
Figure 9: resistor
Variable Resistors
There are two general ways in which variable resistors are used. One is the variable resistor
whose value is easily changed, like the volume adjustment of Radio. The other is a semi-fixed
resistor that is not meant to be adjusted by anyone but a technician. It is used to adjust the
operating condition of the circuit by the technician. Semi-fixed resistors are used to compensate
for the inaccuracies of the resistors, and to fine-tune a circuit. Some variable resistors must be
turned many times to use the whole range of resistance they offer.
This allows for very precise adjustments of their value.
These are called "Potentiometers" or "Trimmer Potentiometers." The symbol of resistor is
shown in figure below.
I, jumper Wires: It is a wire or a group of wire that contains connector pins at both the ends
which are used to connect different elements or devices with the breadboard. Jumper wires
can be used to connect Arduino devices without soldering.
13 | P a g e
Chapter Four
System design procedure
4.1 The Design
This project aimed at designing an Arduino-based room light control and visitor counter control
system where human movement was to be under continuous surveillance. To achieve this,
sensors that produced digital output were employed. In this project, two types of sensors
namely; LDR sensors and PIR sensors were used. These sensors were connected directly to the
Arduino pins and acted as an input to the system. For notification purposes, LCD was employed
to indicate room occupancy. The display was connected to the output pin of the ARDUINO
microcontroller. A complete block diagram for the system is shown in Figure 4.1. It is made
up of a personal counter circuitry, Arduino microcontroller, LDR light sensor, LCD and a relay
circuitry. The sensor’s outputs are interfaced to the input port of the Arduino which under the
control program stored in its memory displays the room occupancy on the LCD and decides on
when to switch on/off the lights through a relay.
Power supply
Entrance IR Arduino
sensor Micro Relay
Controller
Exit IR sensor
LCD Display
LDR Sensor
15 | P a g e
all the character to be displayed are converted into ASCII form and then sent to the LCD along
with different control words.
The control word differentiated the various operations and is executed. It is also possible to
read the LCD data if required. The control signals to the LCD are also provided by the Micro
controller.
Pin Description
VCC/VDD is connected to the +5V supply. VEE/VSS and RW is connected to the ground, Vee
is used for controlling LCD contrast. RS, register select. There are two very important registers
inside the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction
command code register is selected, allowing the user to send a command such as clear display,
cursor at home, etc., If RS=1 the data register is selected, allowing the user to send data to be
displayed on the LCD.
R/W, read/write R/W input allows the user to write information to the LCD or read information
from it. R/W=1 when reading; R/W=0 when writing. EN, Enable the LCD to latch information
presented to its data pins uses the enable pin. When data is supplied to data pins, a high-to-low
pulse must be applied to this pin in order for the LCD to latch in the data present at the data
pins. The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents
of the LCD’s internal registers. To display letters and numbers, we send ASCII codes for the
letters AZ, a-z, and numbers 0-9 to these pins while making RS=1.There are also instruction
command codes that can be sent to the LCD to clear the display or force the cursor to the home
position or blink the instruction command codes. We also use RS=0 to check the busy flag bit
to see if the LCD is ready to receive information.
LCD2
LM041L
16 | P a g e
4.2.3 Relay to microcontroller interface circuit
A relay is an electromagnetic switch that opens and closes under the control of another
electrical circuit. Since the relay can control an output circuit of higher voltage than the input
circuit it can be considered as a form of an electrical amplifier.
When the microcontroller pin connected to the relay circuit goes high i.e. logic-1, current flows
through the relay coil and the resulting magnetic field attracts an armature that is mechanically
linked to a moving contact. This movement either makes or breaks a connection with a fixed
contact. On the contrary, when the Arduino microcontroller pin goes to logic-0, the current to
the coil is switched OFF and the armature is returned by a force approximately half as strong
as the magnetic force to its relaxed position. Since in this case the coil is energized with DC,
IN4001 diode was connected across the coil to dissipate the energy from the collapsing
magnetic field at deactivation, which would otherwise generate a spike of voltage and may
cause damage to circuit components. The relay switch connections are usually labeled COM,
NC, NO whereby: i, COM - Common, is the moving part of the switch. ii, NC- Normally
Closed, COM is connected to this when the relay coil is off. iii. NO- Normally Open, COM is
connected to this when the relay coil is on
Arduino Microcontroller can only provide 25 mA on its pins hence we need an external DC
power supply to provide the current required for the operation of the relay. When the pin P5 of
the Arduino microcontroller goes high, the relay coil energizes. The switched circuit in this
design was to be ON when the relay coil is energized hence the COM was connected to No
contact otherwise the COM should be connected to NC. Therefore, the relay controls the lamp
connected to it based on the status of the PIR and LDR sensors.
17 | P a g e
output pin goes high when motion is sensed and low if no motion is detected. iii) Ground
connected to the negative power.
The output of the IR sensor module is monitored through the digital port of the microcontroller.
When motion is sensed, this output is high at about 3.33 V as depicted by the 3.33 V regulator
IC on board in the IR detector module used. This voltage was used as a valid logic high for the
microcontroller. However, in order to get a full swing of the logic voltages, the sensor output
was employed to Arduino. The microcontroller here monitors the voltage at the collector of the
transistor. During normal condition, the transistor is cut off and the collector output is at logic
high i.e. +5 V. On sensing motion, the high output from the sensor saturates the transistor and
the voltage at the collector drops down to logic low (0.4 V).
A single pole double throw (SPDT) relay is connected to port D, pin 5 of the microcontroller
through a driver transistor. The relay requires 12 volts at a current of around 100mA, which
cannot provide by the microcontroller. So, the driver transistor is added. The relay is used to
operate the external solenoid forming part of a locking device or for operating any other
electrical devices. Normally their relay remains off. As soon as pin of the microcontroller goes
high, the relay operates which lead to control the bulb if the output of LDR is low.
18 | P a g e
Figure13: system design
Also, the counter will not change if both the sensors have not detected the person which helps
to solve the situation that we were facing earlier of the counter increasing or decreasing even
when the person was just standing in one position without entering or leaving the room. When
a person is entering the room the output of the PIR sensor1 goes high and the output of the PIR
sensor2 goes HIGH after some time delay, Then the number of people (count) will be increased
and displayed on the LCD display. When a person is leaving the room the output of the PIR
sensor2 goes high and the output of the PIR sensor1 goes HIGH after some time delay, Then
the number of people (count) will be decreased and displayed on the LCD display.to turn ON
the lamp using the relay module, there must be a person in the room and the room should be
dark. which means the lamps must not turned ON in a day. When it is night and no person is
in the room the lamps must turned OFF.
19 | P a g e
4.4 Flow diagram of the system
YES If NO
LCD>0
Relay on
20 | P a g e
Chapter Five
These are: -
5.1.2 Proteus 8
Proteus 8 is a single application with many service modules offering different functionality
(schematic capture, PCB layout, etc.). The wrapper that enables all of the various tools to
communicate with each other consists of three main parts.
Application Framework
Proteus 8 consists of a single application (PDS.EXE). This is the framework or container which
hosts all of the functionality of Proteus. ISIS, ARES, 3DV all open as tabbed windows within
this framework and therefore all have access to the common database [6].
21 | P a g e
Common Database: The common database contains information about parts used in the
project. A part can contain both a schematic component and a PCB footprint as well both user
and system properties.
Live Net list: Together with the common database the maintenance of a live net list allows all
open modules to automatically reflect changes. The most obvious example of this is wiring in
ISIS producing rats nest connections in ARES but it goes much further than that. The new Bill
of Materials module contains a live viewer and the 3D Viewer and Design Explorer are also
linked into the live net list.
Figure15: final circuit of automatic room light controller using Arduino microcontroller
5.2 Testing
The software realization of the system is very vital. This is where the fantasy of the whole idea
meets reality. The designer seen their work not just on paper but also evaluated well by using
the appropriate software. After carrying out all the paper design and analysis, the project was
tested to ensure its working ability. Simulation using Proteus virtual system modelling (VSM)
22 | P a g e
whereby the source code file obtained from the development environment was added to
Arduino microcontroller program memory and the simulation initiated. By pressing entrance
switch followed by exit switch the status of the counter incremented and this count was
displayed on the LCD display. On the contrary, pressing exit switch followed by the entrance
switch the status of the counter decreased which displayed on the LCD. Micro controller reads
data from LDR and activates the relay according to the intensity of light. When light intensity
detected is more it de-energized the relay, which turn the light OFF while, light intensity
detected is less the microcontroller activate relay thus, the lamp turned ON. The overall result
can be generalized in the following four cases which are discussed below.
Case 1
When the entrance switch was pressed first followed by the exit switch, and LDR have good
light, the microcontroller understand that someone want to enter the room and the intensity of
light is sufficient in the room. Which results the count which displayed on the LCD was
incremented by one also relay was deactivated thus, the light in the room deactivate as shown
in figure 16 bellow.
Figure16: system response schematic of the designed system when LDR lighted.
Case 2
When the entrance switch was pressed first followed by exit switch, and LDR haven’t light,
the microcontroller understand that someone want to enter the room and the intensity of light
23 | P a g e
inside the room is in efficient. Which results the count to be incremented and the relay was
activated which turn ON the room light as shown in figure 17 bellow.
Figure 17: system response schematic of the designed system when LDR no lighted and
there is occupancy.
Case 3
When the exit switch was pressed first followed by entrance switch, and LDR haven’t light,
the microcontroller understand that someone want to leave the room Which results the count
to be decremented and if the count isn’t dropped to zero, that means there is someone in the
room then relay will be stay activated which takes no action on the room light as shown in
figure 18 bellow.
24 | P a g e
Figure18: system response schematic of the designed system when LDR no lighted and leaves
one person, but still there is occupancy
Case 4
When the exit switch was pressed for the first time followed by entrance switch, and LDR
haven’t light, the microcontroller understand that someone want to leave the room Which
results the count to be decremented and if the count drops to zero, that means there is no one
in the room then relay will be deactivated which turns OFF the room light as shown in figure19
bellow.
25 | P a g e
Figure19: system response schematic of the designed system when LDR no lighted and there is no
occupancy
26 | P a g e
Chapter Six
6.2 Recommendation
The control system available in our country is manually operated switch. These systems are
designed to operate the user at the desired time. But this way is not good and it has disadvantage
that the user may lazy or forget to switch OFF the light at the day time. The other disadvantage
is in some rooms such as Meeting halls and libraries we look many people enter and they leave
it due to the absence of vacant space to sit and disturbing the activity’s performing in that room.
To overcome these, dis advantages we recommend to Mekelle Institute of Technology (MIT)
department of EEE to motivate the next generation students to bring this design in to practical
application which opens and closes a door automatically.
27 | P a g e
References
[1] Sheriff Matta, Syed Masud Mahmud, "An intelligent light control system for power saving," in
IECON 2010 - 36th Annual Conference on IEEE Industrial Electronics Society, Glendale, AZ,
USA, November 2010.
[2] R. Gunturkun, " Feedforward and Elman Feedback Harmonics Compensation," in PhD thesis,
Graduate School of Natural and Applied science, Turkey, 2003.
[3] Vibhuti and S.L Shimi, "Implementation of Smart classroom Using WAGO PLC,," in in
proceedings of the second international conference on inventive system and control(ICISC)
Coimbatore,, 2018.
[4] A, Maslekar, k.Aparna, k.mamatha and T.Shivakumara,, "Smart Lighting system using
Raspberry pi," international journal of innovative research in science and technology,, vol. 04,
no. 1, p. 7, 2015.
[5] Suresh s., H.N.S Anusha ,T.Rajath ,P.soundarya and S.V.pratyusha Vudatha,, "Authomatic
Lighting and control system for classroom," in international conference on ICT in Bussiness
industry and Government(ICTBIG), 2016.
[6] Pradnya Prabhakar Powar, Sheetal Arun Patkure,Madhura Pramod Walvekar,Vaishnavi
Aravind Patil,Tejaswini Ulhas Pati,, "Automatic Room Light controller," international journal
of creative research thoughts(IJCRT), vol. 2, no. 10, pp. 2-5, 2022.
28 | P a g e
Appendix
The software program loaded into the micro controller
//MICROCONTROLER */
// the code displays status of room occupancy in a controlled room. Based on the count and
//status of the infrared sensor output, the lights are switched on and off automatically and the
//status of the room occupancy is shown on the LCD and also open-close the door.
//-------------------------------------------------------------------------------------------------/
#include<LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
#define PIRsensor1 6 //define the arduino pins to connect with PIR sensor1
#define PIRsensor2 7 //define the arduino pins to connect with PIR sensor2
#define relay 5 //define the arduino pins to connect with relay
#define LDRsensor A0 //define the arduino pins to connect with LDR sensor
int sensorState1 = 0; //intialise the PIRsensor state
int sensorState2 = 0; //intialise the PIRsensor state
int count=0;
float LDRvalue=0; //intialise the LDRsensor state
void setup()
{
pinMode (PIRsensor1,INPUT );
pinMode (PIRsensor2, INPUT);
pinMode (LDRsensor,INPUT);
pinMode(relay, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(4,0);
29 | P a g e
lcd.print("COUNTER");
lcd.setCursor(0,1);
lcd.print("No Person In ");
delay(200);
}
void loop()
{
sensorState1 = digitalRead(PIRsensor1);
sensorState2 = digitalRead(PIRsensor2);
LDRvalue = analogRead(LDRsensor);
LDRvalue = (3.3*LDRvalue)/1023;
Serial.print(LDRvalue); //read th value from the sensor ,then
// print the values comming from the sensor on the screan.
lcd.setCursor(0,1);
lcd.print("persons In: ");
lcd.setCursor(12,1);
lcd.print(count);
lcd.setCursor(13,1);
lcd.print(" ");
}
else {
lcd.setCursor(0,1);
lcd.print("persons IN: ");
lcd.setCursor(12,1);
lcd.print(count);
}
digitalWrite(relay, HIGH);
}
else{
digitalWrite(relay, LOW);
}
}
31 | P a g e