Skip to content

Automatic Light ON-OFF based on presence of people

It is quite often that we see in homes, office that people leave the lights, lamps and fans in on condition even if it not necessary, by this by this power consumption will be more unnecessarily, so how can we save the power? Wouldn’t it be good if we could have an automatic light ON-OFF system based on the presence of people in the room?

Here I have come up with a project for Domestic Power Optimization by using Arduino Uno. It is very interesting project for hobbyists and students for fun as well as learning.

Key Components:
To know more about the components used click on the link below.

  1. Arduino UNO
  2. Relay (5v)
  3. Resisters
  4. IR Sensor module
  5. 16×2 LCD display
  6. BC547 Transistor
  7. Bread Board, Connecting Wires, Led.

The project is based on the interfacing of some components such as sensors, motors etc. with Arduino microcontroller. This counter can be used to count people in both directions. This circuit can be used to count the number of persons entering a hall/mall/home/office in the entrance gate and it can count the number of persons leaving the hall by decrementing the count at same gate or exit gate and it depends upon sensor placement in mall/hall.

The sensor always observes an interruption and provide an input to the controller which would run the counter increment or decrement depending on entering or exiting of the person. And counter value is displayed on a 16×2 LCD through the controller.

When any one enters in the room, IR sensor will get interrupted by the object then other sensor will not work because we have added a delay for a while.

Automatic Light ON-OFF Circuit Explanation:

Let us see the various sections and their workings.

Sensor section:

In this section we have used two IR sensor modules which contain IR diodes, potentiometer, Comparator (Op-Amp) and LED’s. A potentiometer is used for setting reference voltage at comparator’s one terminal and IR sensors sense the object or person and provide a change in voltage at comparator’s second terminal. Then comparator compares both voltages and generates a digital signal at output. In this circuit we have used two comparators for two sensors. LM358 is used as comparator. LM358 has inbuilt two low noise Op-amp.

Control Section:

Arduino UNO is used for controlling whole the process of this visitor counter project. The outputs of comparators are connected to digital pin number 14 and 19 of Arduino. Arduino read these signals and send commands to relay driver circuit to drive the relay for light bulb controlling.

Relay Driver section:

Relay driver section consist a BC547 transistor and a 5volt relay for controlling the light bulb. Transistor is used to drive the relay because Arduino does not supply enough voltage and current to drive relay.so we added a relay driver circuit to get enough voltage and current for relay. Arduino sends commands to this relay driver transistor and then light bulb will turn on/off accordingly.

The outputs of IR Sensor Modules are directly connected to Arduino digital pin number 14(A0) and 19(A5). And Relay driver transistor at digital pin 2. LCD is connected in 4 bit mode. RS and EN pin of LCD is directly connected at 13 and 12. Data pin of LCD D4-D7 is also directly connected to Arduino at D11-D8 respectively. Rest of connections are shown in the below circuit diagram.

Code:

#include<LiquidCrystal.h>

LiquidCrystal lcd(13,12,11,10,9,8);

#define in 14
#define out 19
#define relay 2

int count=0;

void IN() // In Function
{
	count++;
	lcd.clear();
	lcd.print("Person In Room:");
	lcd.setCursor(0,1);
	lcd.print(count);
	delay(1000);
}

void OUT() //Out function
{
	count--;
	lcd.clear();
	lcd.print("Person In Room:");
	lcd.setCursor(0,1);
	lcd.print(count);
	delay(1000);
}

void setup()
{
	lcd.begin(16,2);
	lcd.print("Visitor Counter");
	delay(2000);
	pinMode(in, INPUT);
	pinMode(out, INPUT);
	pinMode(relay, OUTPUT);
	lcd.clear();
	lcd.print("Person In Room:");
	lcd.setCursor(0,1);
	lcd.print(count);
}

void loop()
{
	if(digitalRead(in))
		IN(); //calling IN function
	if(digitalRead(out))
		OUT(); //calling Out function
	if(count<=0)
	{
		lcd.clear();
		digitalWrite(relay, LOW);
		lcd.clear();
		lcd.print("Nobody In Room");
		lcd.setCursor(0,1);
		lcd.print("Light Is Off");
		delay(200);
	}
	else
		digitalWrite(relay, HIGH);
}

Leave a Reply

Your email address will not be published. Required fields are marked *