IOT

Bidirectional Visitor Counter with Automatic Light Control using Arduino

We frequently see visitor counters in stadiums, malls, offices, and classrooms, among other places. When no one is inside, how do they count the people and turn on or off the lights? Today we’re going to show you how to make an automatic room light controller with a bidirectional visitor counter using an Arduino Uno. It’s a great project for enthusiasts and students who want to learn while having fun.

Proposed System

We will use Arduino to create a Bidirectional Visitor Counter with an Automatic Light Control System in this project. This project is based on a pair of infrared sensors that detect an impediment and trigger an interrupt. The pair of IR sensors can detect visitors from both directions, i.e. the number of people entering and exiting the building.

This Arduino Bidirectional Visitor Counter Project can be used to count the number of people who enter a hall, a shopping mall, an office, or a function at an entrance gate. It can also be utilized at parking lot gates and other public locations. The system keeps track of how many people enter and exit a gate. Finally, it counts the total number of persons in the room at any one time. The room light is switched off when there are no persons inside the room, i.e. when the total number of individuals is zero. The light goes on when even a single person is found within the room. The light management system is automated and is based on the presence of visitors. +

Visitor Counter Light Control Arduino

We can complete the project using just one Arduino Nano Board. To display the number of visits, we can utilize a 16×2 LCD Display. However, for this project, you may choose to use a 0.96′′ OLED Display. When a human is detected inside a room, a 5V single channel relay is activated. The light attached to the Relay turns on automatically.

Hardware Required

  • Arduino Nano
  • IR Infrared Sensor Module
  • 0.96″ I2C OLED Display
  • 5V 1 Channel Relay Module
  • 5V Power Supply

IR Sensor as Visitor Detector

The main element of this project is the IR Sensor which works as a Human Detector. Whenever the IR sensor detects an interrupt it counts the person and adds it to the previous value. You can check some of our previous projects made using IR Sensor Like Digital Tachometer and also the Fan Speed Measurement.

IR Sensor Module

The ambient light adaptability of the IR Sensor module is excellent. It is equipped with an infrared transmitter and receiver. When an obstruction is encountered, the infrared emitting tube emits a specific frequency, which is reflected back to the signal. The receiver tube then receives the reflected signal. The circuit also includes an Opamp, a Variable Resistor (Trimmer pot), and an output LED in addition to the IR Transmitter and Receiver.

The Sensor consists of the following Parts.

1. IR LED Transmitter

IR LEDs emit light with a wavelength of 700nm – 1mm in the infrared frequency band. The light-emitting angle of IR LEDs is approximately 20-60 degrees, with a range of 5-10cm. IR LEDs are white or transparent in color, allowing them to emit the most amount of light possible.

2. Photodiode Receiver

Photodiode acts as the IR receiver as its conducts when light falls on it. Photodiode looks like a LED, with a black color coating on its outer side. The Black color absorbs the highest amount of light.

3. LM358 Opamp

The IR sensor uses an LM358 Operational Amplifier (Op-Amp) as a voltage comparator. The comparator circuit compares the predefined threshold voltage to the series resistor voltage of the photodiode. The Op-Amp output is high when the photodiode’s series resistor voltage drop is larger than the threshold voltage. Similarly, the Op-Amp output is low when the photodiode’s series resistor voltage drop is smaller than the threshold voltage.

The LED at the output terminal turns on when the Op-Amp output is high. This denotes the presence of an object or an impediment.

4. Variable Resistor

Here, the variable resistor is pre-set. It is used to calibrate the detection distance range for the object.

Arduino Bidirectional Visitor Counter Circuit

The project’s hardware is fairly simple to put together. A pair of IR sensors, an OLED display, and a 5V Relay Module are all that is required. The following is a circuit diagram.

Bidirectional Visitor Counter Circuit

The circuit shown above can be built on a breadboard. Connect the SDA and SCL pins of the OLED Display to A4 and A5 of the Arduino, respectively. 3.3V VCC is required for the OLED Display. Connect the digital output pins of the two IR Sensors to 2 and 3 in the same way. The IR Sensor can be powered by either 3.3V or 5V. The Arduino digital pin must be used to operate the relay module. Connect its Input pin to Arduino’s digital pin 5. A 5V supply is also required for the relay.

Schematic & PCB Designing

If you don’t want to put the circuit together on a breadboard, here is the schematic. The schematic below can be used to create a bespoke PCB. For the schematic, I utilised EasyEDA, an online Schematic & PCB Designing Tool.

You can convert the schematic to PCB after constructing the Schematic for Arduino Bidirectional Visitor Counter. The PCB appears to be similar to the one in the image below.

PCB Ordering & Assembly

The Gerber File for Bidirectional Visitor Counter with Light Control PCB is given below. You can simply download the Gerber File and order the PCB from NextPCB.

Download Gerber File: Visitor Counter PCB

Now you can visit the NextPCB official website by clicking here: https://www.nextpcb.com/. So you will be directed to NextPCB website.

You can now upload the Gerber File and place an order on the website. The PCBs are in excellent condition. That is why the majority of people entrust NextPCB with their PCB and PCBA needs.

I received the PCB after a week. The PCB quality is excellent, with a high finish.

After that, put all of the components on the PCB. The completed hardware, which includes the PCB board and the installed component, must be tested alongside the code. Below is a picture of the hardware.

Arduino Source Code/Program for Bidirectionl Visitor Counter

The Arduino Bidirectional Visitor Counter with Automatic Light Control System source code is provided below. Compilation of the code necessitates the use of SSD1306 and the GFX OLED library. To begin, download and install the libraries listed below into the Arduino IDE.

1. Download SSD1306 Library: https://github.com/adafruit/Adafruit_SSD1306

2. Download Adafruit GFX Library: https://github.com/adafruit/Adafruit-GFX-Library

You can now copy the code and upload it to the Arduino Board.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define inSensor 2
#define outSensor 3

int inStatus;
int outStatus;

int countin = 0;
int countout = 0;

int in;
int out;
int now;

#define relay 5

void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128×64)
delay(2000);
pinMode(inSensor, INPUT);
pinMode(outSensor, INPUT);
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);

display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(20, 20);
display.print(“Visitor”);
display.setCursor(20, 40);
display.print(“Counter”);
display.display();
delay(3000);
}

void loop()
{
inStatus = digitalRead(inSensor);
outStatus = digitalRead(outSensor);
if (inStatus == 0)
{
in = countin++;
}

if (outStatus == 0)
{
out = countout++;
}

now = in – out;

if (now <= 0)
{
digitalWrite(relay, HIGH);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 15);
display.print(“No Visitor”);
display.setCursor(5, 40);
display.print(“Light Off”);
display.display();
delay(500);
}
else
{
digitalWrite(relay, LOW);

display.clearDisplay();
display.setTextColor(WHITE);

display.setTextSize(1);
display.setCursor(15, 0);
display.print(“Current Visitor”);
display.setTextSize(2);
display.setCursor(50, 15);
display.print(now);

display.setTextSize(1);
display.setCursor(0, 40);
display.print(“IN: “);
display.print(in);

display.setTextSize(1);
display.setCursor(70, 40);
display.print(“OUT: “);
display.print(out);

display.display();
delay(500);
}
}

Testing & Results

The device is ready for installation after uploading the visitor counting code to the Arduino Board. A 5V DC Adapter can be used to turn on the device.

A pair of IR Sensor modules are included with the gadget. One IR sensor should be positioned within the room door and the other outside the room door, i.e. inside the room door and outside the room door.

When there are no visitors in the room, the light turns off, and the OLED Display indicates that no visitors are present.

When someone makes an entry, the visitor is recorded, and the number of arriving guests is displayed on the OLED Display. The light will switch on automatically at this point.

The visitor is deducted when someone leaves the room or exits. As a result, OLED displays the total number of current visitors. The OLED Display also shows the number of people who entered the space and how many people left.

Visitor Counter Light Control Arduino

Conclusion

I hope all of you understand how to design an Arduino Visitor Counter with Light Control System works. You can use this project for Hall, Schools, Office, Functions, etc. We MATHA ELECTRONICS will be back soon with more informative blogs.

Leave a Reply

Your email address will not be published.