Implementation of Arduino-based Counter System

—Automated counter system is an efficient solution for counting the number of people entering or leaving a room. This paper attempts to provide a unique solution which can automatically count the number of people. It intelligently discovers and counts the number of people with the help of internal code from the Arduino UNO. This has been achieved by using an Infrared sensor, piezoelectric sensors and the development board Arduino UNO. Two Infrared sensors are placed at entry and exit of a room. A series of piezoelectric sensors are placed under a mat between the two infrared sensors. The sensors acquire the data and sends to the arduino which maintains the count. The system requires low voltage and minimum maintenance to continue the operation.

I. INTRODUCTION We are in a world of digital transformation. In every aspect technology is one common thing people depend upon. If we look back in the 1970s, people used to count visitors manually by counting them or they used a manual tally counter. But today we can see that many methods have been introduced to count people without the need of any human presence. The sensors and cameras will simplify our job of counting the people. We just need to program them to perform the required task. The primary method of counting visitors include hiring people to stand and manually count the number of guests or workers who enter or exit from the venue or location. Even the tally counters are not user friendly and don't have many advantages. Therefore, these methods prove to be unreliable and come at a great cost. In recent times, counting visitors has become an essential task for people working in sectors which include customers where the number is used as a satisfaction tool by the administrators. Hence, people began researching methods to count people efficiently without hindrance. Since then many methods have been introduced which are now used in various sectors around the world. However, there are certain disadvantages with every method and it is up to the administrators to decide the best method to count visitors. One method might be efficacious but extremely expensive. Another one can be quite feasible and cheap but not efficient. The objective of this paper is to provide a suitable solution for counting people in an office or a place where the intensity of people is moderate to high. The solution used basic sensors such as IR and piezoelectric and are programmed using a development board called Arduino. This paper is intended to provide an efficient yet inexpensive solution for people who are in need of it.

II. LITERATURE REVIEW
There is more than one method to count the visitors. It ultimately depends on the intensity of people. The following papers were studied and analyzed to understand the current scope of people detection: Bruno F. Carvalho and others [1] have suggested a method that utilizes sensors for detecting people. The ultrasonic sensor plays a dominant role in identifying objects and accurately calculates the distance between the sensor and the objects. "The ultrasonic sensor constantly measures the distance of objects ahead, sending a signal through Trigger pin e receiving through Echo". Two ultrasonic sensors are placed side by side and an algorithm is devised to count the number of visitors entering the premises. They have also implemented another method which uses motion sensors to detect any motion of an object or a person and compared the two methods. Both the methods are successfully tested in an environment. But this method cannot detect more than one person at a time. If two persons pass through the system side by side, the system will detect only one person.
Jeong Woo Choi and others [2] have proposed a method that uses IR-UWB radar sensors for counting people. "IR-UWB radar uses an impulse signal that occupies wide bandwidth. It is a technology that transmits an impulse signal and recognizes various situations by processing multiple signals that are received after being reflected from multiple human and objects". The algorithm devised for this method is implemented using ARM Cortex-M4 and Raspberry Pi 2 modules. Two IR-UWB sensors with antennas are fixed to count the number of people. Though the system can detect multiple people at a time, it is not cost efficient. The sensors are high expensive in the market.
Another approach using IR sensors was proposed by Jothibasu M, Aakash B and others [3]. IR sensors play a vital role in identifying objects. In this method, two IR sensors are placed adjacent to each other which detect the visitors. "The logic behind the working of the counting process is simple, when the person crosses the sensor near the door and then to the sensor away, it recognizes as an increment in count". Apart from being a bi-directional counter, this method can be used to control home appliances and helps in consuming less electricity. This method cannot detect more than one person at a time. If two persons pass through the system side by side, the system will detect only one person.
Jingwen Li [4] have designed an approach that uses Bag-Of-Features (BOF) model to count the number of pedestrians. "The system can also select pedestrians and non-pedestrians samples automatically and update the classifier in real-time to make it more suitable for certain specific scene. The dataset used is CASIA pedestrian counting dataset and trained using SVM classifier. The system requires real time monitoring of the pedestrians via camera modules which are very expensive. Kartik Madhira and Aditya Shukla [5] have proposed a method that uses image processing techniques to count human specific areas such as ATMs, retail shops, malls etc. "The people counter solution was made using computer vision library OpenCV for Python computer language". The method achieved around 80-93% accuracy. The cameras were positioned in many angles to test the accuracy of the method. The system requires real time monitoring of the persons via camera modules which are very expensive.
Shubham Mathur and others [6] have come up with a method that uses image processing with sensor feedback for counting people entering or leaving a lab. Histogram of oriented gradients (HOG) technique was used for this method. The images are captured using Raspberry Pi fitted with a RaspiCam. A pair of PIR sensors is installed to instruct the system to capture the images. The data can be sent via Bluetooth to local servers for security purposes. An efficiency of 83% is achieved using this method. The equipment used in this system is very expensive. The sensors add extra cost to the system apart from camera module and Raspberry Pi.
Another method proposed by Dr.P.Satyanarayana and others [7] involves the use of OPEN CV3 using python 3.5.2. "The implementation goes on like the process of background subtraction on the incoming frames followed by the blob analysis using which the person can be detected and by using virtual lines, the count of the people entering and leaving a particular area can be evaluated". The system requires real time monitoring of the persons via camera modules which are very expensive.
David Beymer [8] proposed a method that involves 3D stereo vision. "The stereo system performs real-time 3D reconstruction by employing table lookup to map from image coordinates and disparities to 3D. Based on the 3D coordinates, the scene is (1) segmented by filtering out pixels outside the volume of interest, and (2) reprojected to a topdown, orthographic view. Finally, people are detected and tracked in the orthographc reprojection using a Gaussian mixture model and Kalman filtering". The system requires real time monitoring of the persons via camera modules which are very expensive.
III. CONSTRUCTION A. Infrared sensor: An infrared (IR) sensor emits and detects infrared radiation. It is used to detect obstacles. An IR sensor consists of IR transmitter, receiver, operational amplifier (Opamp), variable resistor and an light emitting diode (LED) in brief. IR transmitter is an IR LED which emits light in the range of infrared frequency. IR light is invisible to us because the wavelength of IR radiation (700 nm -1mm) is much higher than visible light. IR light have emitting angle of approximately 20-60 degrees with a range of approximately few centimeters to several feet. The photodiode receiver acts as the IR receiver which detects the reflected IR light. Photodiode is an LED with black color coated on its outer side. The Opamp is used as a voltage comparator in the IR sensor. The variable resistor is used to calibrate the distance range at which the object should be detected.

Fig. 1 Infrared Sensor
The sensor consists of three pins namely vcc, ground and vin. The vcc pin is connected to a 5 volts DC supply to power up the sensor. The ground pin is connected to ground. The vin pin is connected to one of the digital input/output (I/O) pins of arduino. Once powered up, the sensor transmits IR light. Whenever there is an obstacle in front of the sensor, the light will get reflected which is detected by the IR receiver.

B. Piezoelectric sensor:
The piezoelectric sensor has the ability to convert mechanical stress to electrical energy (AC output). The principle involved is piezoelectric effect. It is a reversible effect means if electric energy is provided, mechanical stress is induced. Common materials used in piezoelectric sensors are quartz, Rochelle salt. Synthetic materials including zinc oxide and gallium arsenide are also used. The sensor has two terminals namely positive and negative. The positive terminal is connected to one of the analog pins of arduino and the negative terminal is connected to ground. By pressing the sensor, the mechanical energy produced is converted to electrical energy.

C. Arduino UNO
Arduino is an open-source microcontroller board based on ATmega328p microcontroller [11]. It is one of the popular development boards used for experimental purposes and it serves as an intermediate to Internet of Things (IoT) [12]. It also includes 14 digital I/O pins for both reading and writing data, and 6 analog pins for reading input: GND (3 pins): Abbreviation for 'Ground'. The board consists of 3 pins and is used as the negative terminal of any sensor or circuit connected to the Arduino. 5V & 3.3V: These pins supply 5volts and 3.3 volts of power to the circuit respectively. Most sensors are designed to be compatible with these 2 voltages. Power: All Arduino boards require a power source to run on. There are two ways to power the board. The first is by using a USB cable connected to a computer. Alternatively, the board can be powered by connecting it directly to a wall power supply using the barrel jack given. But the voltage of the power source should be in the range of 6-12V. Analog: Analog pins are designated under 'Analog In' label and consist of pins A0 to A5. These pins can read signals from analog devices such as piezoelectric sensors and convert it to binary data for the processor to read. IV. METHODOLOGY The system consists of a piezoelectric mat. The piezoelectric sensors are distributed evenly on the mat and the connections are made to the analog pin of Arduino UNO board. Two IR sensors are installed at either end of the mat at a sufficient height from the ground. The first IR sensor which is programmed to detect the entry of a person is placed on the exit side of the mat. The second IR sensor which is programmed to detect the exit of a person is placed on the entry side of the mat. When a person enters and passes through the mat, the weight of the person, which is in the form of external stress to the piezoelectric sensor, is converted into an electrical signal. The electric signal is greater than a certain threshold, and the digital output is high. The threshold value is set so that whenever a person passes through the mat it records the signal and the value is high for a certain period of time. The person then passes by the IR sensor which detects the entry. The algorithm is designed in such a way that if both piezoelectric and the entry IR sensor are high at the same time, it detects the person and the count is increased by one. Fig. 4 Hardware of the project which includes IR sensors and piezoelectric mat When a person exits and passes through the mat, the weight of the person is converted to an electrical signal, which surpasses the threshold and is set high. The person then passes by the IR sensor which detects the exit. Now since both the sensors (piezoelectric and exit IR sensor) are set high, the system detects the person is leaving and the count is decreased by one. The person passes through both the IR sensors but since there is a delay in activating the piezoelectric sensor, only one of the sensors get time to detect by the time a person passes through the system and count is detected.
The system is designed so that even if two persons enter or exit simultaneously the threshold is set to detect the two persons and the count is increased by two.

VI. RESULTS
The counter system is designed to detect the number of visitors entering or leaving the premises. The experiment is performed in a room. A total of five scenarios were considered. Results were obtained which are mentioned in the following table. VII. CONCLUSION AND FUTURE SCOPE The counter system has the ability to detect two simultaneous visitors, entering or leaving at the same time. The system is developed using Arduino UNO development board and it's IDE. The project uses two IR sensors and several piezoelectric sensors for more accuracy and precision. Arduino helps achieve the coordination among the sensors. The system is designed to use at places like laboratories or classrooms where the intensity of crowd is intermediate. The system can be enhanced by installing industrial IR sensors which have better sensitivity at detecting persons at sufficient distance. The size of the mat can also be increased based on the area available. The data can be sent to cloud and store it for future use. The data can also be monitored live for security purposes and can be used for further IoT applications.