We will discuss in today’s topic, how can we build a simple Infrared Sensor Based Automatic Bidirectional Visitor Counter using Arduino. Often we see automatic bidirectional visitor counters at stadiums, malls, offices, etc. How does this single device count people when they enter or exit from the compound?
Today we will discuss its principle, and how it works. The main intention is to design a circuit where the number of persons entering or leaving a compound or room is kept track of and displayed on an LCD screen. It is definitely an interesting mini project for hobbyists and students for fun as well as learning. So let’s do this. Before going to the project, first, check out how to build an Infrared Sensor.
Principle Behind Bidirectional Visitor Counter
The principle behind this bidirectional visitor counter is infrared sensing. Infrared or IR sensor is a device that works with infrared rays and an infrared receiver like a Photo Diode or a Photo Transistor that act as a Transmitter and Receiver respectively.
In this project, we have used an IR LED as the IR Transmitter and a Photo Diode as the IR Receiver. Two sets of IR sensors containing of an IR LED and Photo Diode are placed at two ends of the entrance of a room.
Output from each sensor is detected by the Arduino. In the normal state, IR rays from the IR Transmitter would not fall onto the Photo Diode as it is a reflective type IR Sensor. The output from the IR sensor would be a logic LOW state in this case.
In case of any interruption (Due to any person crossing the entrance), the Photo Diode would start receiving the IR rays and start conducting the current. As a result, the output from the sensor would be a logic HIGH state.
The transition from LOW to HIGH, for each sensor pair, is detected by the Arduino and accordingly the count would be increased or decreased.
Project
Circuit Diagram
Components Required
- Arduino Nano
- 16×2 LCD Display
- Infrared Sensor Module (x2)
- 5V Relay
- BC547 NPN Transistor
- Resistor (1KΩ, 220Ω)
- Hi-Link 5V AC-DC Converter (Optional)
- AC Source
Circuit Explanation
The project of “Bidirectional Visitor Counter” is based on the interfacing of some components such as sensors, microcontroller, counter display and gate.
Sensor Part: In this part, we have used two IR sensors which contain IR LEDs, Photo Diodes, potentiometer, comparator (Op-Amp) and LEDs. The potentiometer is used here for setting up reference voltage at the comparator’s one terminal and IR sensors sense the object or person and provide a certain change in voltage at the comparator’s second terminal. Then comparator compares both these voltages and generates a digital signal at the output terminal. Here we have used two comparators for two sensors. LM358 is used as a comparator. LM358 has inbuilt two low noise Op-Amp.
Control Part: Arduino is used for controlling the whole process of this bidirectional visitor counter. The outputs of comparators are connected to pin 14 and pin 19 of the Arduino. Arduino then read these signals and send commands to the relay module to drive the load for control.
Counter Display Part: The display part contains a 16×2 LCD display. This section will show the counted number of people entering or exiting from the room and light status when no one will be in the room.
Relay Module Part: The relay module consists of a BC547 NPN transistor and a 5-volt relay for controlling the load (light bulb). Transistor is used to drive the relay because Arduino does not supply the required voltage and current to drive the relay. So we have added a transistor in this circuit to get enough voltage and current for the relay. Arduino sends signals to this driver transistor and then the light bulb will turn on and off accordingly.
Applications of Bidirectional Visitor Counter
The Bidirectional Visitor Counter device can be used in the home as an indication of a number of persons entering a party.
It can be used at official meetings.
At secured official places, this device can keep a check on the number of persons entering a secured place.
It can also be used as a home automation system to ensure energy saving by switching on and off the loads only when needed.
Disadvantages of Bidirectional Visitor Counter
This project has the capability of low range and cannot be implemented in large areas.
With the frequent changes of the count, after a certain time, the output may be confusing.
Arduino Code Without I2C Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #include<LiquidCrystal.h> //#include <Wire.h> //for LCD I2C Module //#include <LiquidCrystal_I2C.h> //LiquidCrystal_I2C lcd(0x27, 16, 2); LiquidCrystal lcd(13,12,11,10,9,8); //for LCD without I2C Module #define in 14 #define out 19 #define relay 2 int count=0; void IN() { count++; lcd.clear(); lcd.print("Person In Room"); lcd.setCursor(0,1); lcd.print(count); delay(1000); } void OUT() { count--; lcd.clear(); lcd.print("Person In Room"); lcd.setCursor(0,1); lcd.print(count); delay(1000); } void setup() { // lcd.init(); //for LCD with I2C Module // lcd.backlight(); lcd.begin(16,2); //for LCD without I2C Module 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)==0) IN(); if(digitalRead(out)==0) OUT(); 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); } |
Arduino Code With I2C Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #include<LiquidCrystal.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); #define in 14 #define out 15 #define relay 2 int count=0; void IN() { count++; lcd.clear(); lcd.print("Person In Room"); lcd.setCursor(0,1); lcd.print(count); delay(500); } void OUT() { count--; lcd.clear(); lcd.print("Person In Room"); lcd.setCursor(0,1); lcd.print(count); delay(500); } void setup() { lcd.init(); lcd.backlight(); lcd.print("Visitor Counter"); delay(500); 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)==0) IN(); if(digitalRead(out)==0) OUT(); 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); } |
we do this circuit last 2 year ago