Evaluation of An Arduino-Based IoT Person Counter
Evaluation of An Arduino-Based IoT Person Counter
Bruno F. Carvalho, Caio C. M. Silva, Alessandra M. Silva, Fábio Buiati and Rafael Timóteo
Laboratório LATITUDE – Faculdade de Tecnologia, Universidade de Brasília, Campus Darcy Ribeiro, Brasília, Brazil
Abstract: The IoT devices can provide a wide range of information, which can be used to infer the behavior patterns
with a large semantic bias. In this sense, an IoT network has the ability to use trafficked information to perform
its own management. One type of information that can be used by an IoT network is the amount of people in
a certain place. This information, combined with others, can help IoT-based systems discover characteristics
about the environment in which it is deployed. Thus, the integration of the data captured provides the
achievement of manifold applications, such as air conditioning regulation, security access and people
management in a working environment. In this research, it is proposed the implementation of an IoT person
counter. Two different technologies were used, aiming to verify the best option to design a counter device
with low-cost microcontrollers and sensors. Experimental results shows that in controlled environments the
IoT person counter has a satisfactory accuracy. Some limitations were also identified in order to clarify the
scenarios where those devices can be used.
129
Carvalho, B., Silva, C., Silva, A., Buiati, F. and Timóteo, R.
Evaluation of an Arduino-based IoT Person Counter.
DOI: 10.5220/0005954601290136
In Proceedings of the International Conference on Internet of Things and Big Data (IoTBD 2016), pages 129-136
ISBN: 978-989-758-183-0
Copyright
c 2016 by SCITEPRESS – Science and Technology Publications, Lda. All rights reserved
IoTBD 2016 - International Conference on Internet of Things and Big Data
130
Evaluation of an Arduino-based IoT Person Counter
the other hand, sound absorbing material, such as device. The prototype of this device was built with an
cloth and foam, are not easily identified. Arduino Uno (A.Uno, 2016) and two motion sensors
model DYP-ME003 (Motion, 2011).
131
IoTBD 2016 - International Conference on Internet of Things and Big Data
two of these sensors allows four different states: two end while
sensors on 0, one sensor on 1 and another on 0 or two end procedure
sensors on 1. When the two sensors are HIGH, can be
detected that a person passed in front of the sensors. The motion sensors used on this implementation have
some technical restrictions that should be taken into
3.1.2 Algorithm account as they directly impact in the device
implementation: The sensor stands in HIGH for 2.5
The motion approach algorithm is presented in seconds: When the DYP-ME003 sensor detects
Algorithm 1. The implementation defines a procedure motion, it stands in high for approximately 2.5
named read_opposite_sensor(byte, bool, int), and seconds. In this time interval, the sensor is
other named main. The read_apposite_sensor incapacitated to perform data capture. This limitation
receives as parameter: a byte, which indicates the undermines the counting process, if people pass in a
sensor_id, a boolean value that gives the direction in time interval shorter than 2.5 seconds. Besides that,
which the person is passing and an int value that only one person can pass in front of the device, if a
represents the time interval when the sensor has to be group of people pass, the device will recognize as just
read. one person.
This procedure performs the reading of the
opposite sensor during the time interval max_time, if
it recognizes any motion, then it detected passage of
3.2 Ultrasonic Approach
an individual. Depending on the direction, the
The ultrasonic IoT person counter was built with one
procedure can add or subtract the value in the persons
microcontroller and two ultrasonic sensors. This
counter.
device performs its functionality similarly to the
The main procedure is executed while the device
motion device. The difference consists on the
is on and checks if any motion was detected in any of
information provided by the sensor. The ultrasonic
the sensors. In the case of motion detection,
device informs the distance of an object that is ahead
read_opposite_sensor function is called to see if
of it.
anyone passed in front of the other sensor. It is
Therefore, the device checks at what distance an
important to notice that this implementation does not
object is from the sensor and waits until the other
use external libraries, just Arduino pre-defined
sensor recognizes the object in the same distance
functions.
interval. In this case, it is recognized that someone has
Algorithm 1: Motion person counter passed in front of the device. The prototype of this
procedure read_opposite_sensor(byte device was built with an Arduino Uno (A.Uno, 2016)
sensor, bool direction, int max_time) : and two ultrasonic sensors model HC-SR04
void (Ultrasonic, 2011).
int time = 0;
while(millis() - time < 3.2.1 Circuit Schema
max_time)
if(is_high(sensor) && The ultrasonic circuit schema is shown in figure 2. An
direction) Arduino UNO is responsible for collecting the
number_of_people++;
information captured by the ultrasonic sensors. This
else if(is_high(sensor) &&
!direction) circuit has two HC-SR04 sensors (ultrasonic sensor)
number_of_people--; connected with one Arduino Uno. The VCC is
end while supplied by the 5V Arduino pin and the GND of each
time - millis(); sensor is attached in the GND Arduino pin. Each
end procedure sensor has one Trigger and Echo pin. The first sensor
has Arduino digital pin 7 and 6 connected,
procedure main() : void respectively, to Trigger and Echo. Besides that, the
int number_of_people = 0; second one is attached with digital pin 9 on Trigger
while(device_on)
and digital pin 8 on Echo.
if(sensor_is_high(first))
The ultrasonic sensor constantly measures the
read_oposite_sensor(second, 1); distance of objects ahead, sending a signal through
else Trigger pin e receiving through Echo. When it is first
if(sensor_is_high(second)) turned on, the device measures the distance of all
read_oposite_sensor stationary objects in the environment. In this paper,
(first,0);
132
Evaluation of an Arduino-based IoT Person Counter
this distance will be called environment distance. For example, if the delay time is set to 200
Besides that, when a person passes in front of the milliseconds, the device will verify how many
device, the distance measured will be named person persons are entering the room for 200ms, then it will
distance. verify how many persons are exiting the room for
The combining of these two sensors heads to four 200ms. The min_dist and max_dist represents the
different states: two sensors reading the environment distance range, this interval indicates the size (width)
distance, one reading environment and the other a of the corridor where people can pass.
person distance, and the two sensors detecting a Therefore, the algorithm is executed while the
person distance. When two devices read a person device is on, and checks if anybody has passed in any
distance, that means someone passed in front of it. direction. If so, this amount is incremented or
decremented from the people global counter. In each
iteration the direction is changed so the device can
read in both directions. To finish the procedure the
device sends to the server the captured information,
through the rest interface, in order to preserve a
historical ballast.
procedure read_ultrasonic_distance(bool
direction) : float distance
microsec = ultrasonic.timing();
distance =
ultrasonic.convert(direction,
Ultrasonic::CM);
return distance;
end procedure
procedure count_persons(float
Figure 2: Ultrasonic person counter circuit schema. min_distance, float max_distance, bool
direction): int amount_people
3.2.2 Algorithm
float distance_dir = 0;
float distance_oposite_dir = 0;
To perform people counting process the algorithm number_of_people = 0;
presented in Algorithm 2 was deployed in the circuit. do
It use two procedures and one library to compute the distance_dir =
information. The library is called “ultrasonic.h” (), read_ultrasonic_distance(direction);
and it is used to perform two types of processing: distance_oposite_dir =
read_ultrasonic_distance(!direct
• timing(): Gives the time passed between the ion);
emission and reception of an ultrasonic wave. if(same_distance_range(dis
• convert(bool, int): receives the sensor id (in this tance_dir,
case a boolean value), and the precision wanted distance_oposite_dir))
(in this case centimeters). number_of_people++;
The library was adapted to work with boolean while(distance > min_distance &&
values as a sensor id. Besides that, two procedures distance < max_distance)
were implemented; read_ultrasonic_distance(bool) return number_of_people;
end procedure
and count_persons(float,float,bool). The first one
uses the library functions to return the distance that an
object is from the sensor. The count_persons procedure main() : void
procedure counts the number of persons who passed
in front of one sensor. float delay = 200;
The main procedure uses the following pre- int max_dist = 100; //centimeters
int min_dist = 40; //centimeters
configured information: delay, min_dist and int direction = 1;
max_dist. Delay indicates the time when the amount_of_people = 0;
microcontroller has to switch the direction of reading.
133
IoTBD 2016 - International Conference on Internet of Things and Big Data
4 EXPERIMENTAL RESULTS
4.1 Experimental Environment
In order to compare the proposed solutions in a real
scenario, all IoT person counters were installed in the
same laboratory room. The devices were deployed
next to the door, objectifying only to capture data
related to the entry and exit of people. This room is
used by fifteen distinct persons at different times of Figure 5: Scenario 3 - Two persons entering or leaving the
day. room at the same time.
The proposed implementations were analyzed in
relation of the accuracy of the information provided
by the IoT devices. Experiments were conducted in
the following approach:
• Controlled tests: Devices were tested in specific
scenarios with minimum external interference.
These scenarios can be seen in Figures 3,4,
5,6,7,8 and 9.
The scenarios proposed for the execution of controlled
tests were designed in order to analyse the
effectiveness of implementations in different Figure 6: Scenario 4 - Two persons entering or leaving the
situations. Thus, the scenarios differ in number of room in a short time interval.
people, time interval between the passage of persons
134
Evaluation of an Arduino-based IoT Person Counter
135
IoTBD 2016 - International Conference on Internet of Things and Big Data
REFERENCES
A.Uno, Arduino Uno datasheet. On-line reference acessed
in 19/02/2016. https://www.arduino.cc/en/Main/
ArduinoBoardUno
A.WiFi, Arduino WiFi shield datasheet. On-line reference
acessed in 17/02/2016. https://www.arduino.cc/en/
Main/ArduinoWiFiShield
Gridling G., Weiss B. (2006). Introduction to
Microcontrollers. Vienna University of Technology.
Henricksen, K., Indulska, J. (2004). “Modelling and using
imperfect context information,” in Pervasive Computing
and Communications Workshops. Proceedings of the
Second IEEE Annual Conference on. IEEE, 2004, pp.
33–37.
Manna, S., Bhunia, S.S., Mukherjee, N. (2014). Vehicular
Pollution Monitoring Using IoT. IEEE International
Conference on Recent Advances and Innovations in
Enineering.
Motion sensor: spcification of DYP-ME003. On-line
reference acessed in
19/02/2016. http://elecfreaks.com/ store/download/
datasheet/sensor/DYP-ME003/ Specification.pdf
M. Sensor, The Beginner’s Guide to Motion Sensors. On-
line reference acessed in 23/02/2016. http://www.
safewise.com/resources/motion-sensor-guide
Raspaile, P., Keswani, V. (2013). An Approach Towards
Low Cost Wireless Sensor Network for the
Applications of IoT. International Journal of
Engineering Science and Advanced Technology.
Sickle, T. V. (2001). Programming Microcontrollers in C.
LLH Technology Publishing, Eagle Rock.
Silva, C. C .M., Ferreira, H. G. C., Sousa Júnior, R. T.,
Buiati, F. and Villalba, L.J.G, 2016. Design and
Evaluation of a Services Interface for the Internet of
Things. Wireless Personal Communications. p. 1-38.
Springer.
Toma, C., Popa, M. (2014). Internet of Thing Architecture
for Context Aware Sensors Data Processing in Waste
Management Solution. Journal od Mobile, Embedded
and Distributed Systems, vol. VI.
Ultrasonic sensor: specification of HC-SR04. On-line
reference acessed in 19/02/2016.
http://www.elecfreaks. com/store/download/product/
136