Bi-Directional Visitor Counter Using Iot

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 109

BI-DIRECTIONAL VISITOR COUNTER USING IOT

CHAPTER-1

BI-DIRECTIONAL VISITOR COUNTER USING IOT

1.1 Introduction
In today’s world, there is a continuous need for automatic appliances. With the
increase in standard of living, there is a sense of urgency for developing circuits that would
ease the complexity of life. Many times, we need to monitor the person or people visiting
some place like Seminar hall, class rooms, conference room, Shopping mall or temple. To
provide solution for this we are going to implement a project called “Bi-Directional Digital
Visitor Counter”. This system is helpful for counting the number of people in an auditorium
or halls for seminar to avoid congestion. Moreover, it can also be used to check the number
of people who have come to an event or a museum to watch a certain exhibit and also be used
to count and display the number of visitors entering inside any conference room or seminar
hall. Basic concept behind this project is to measure and display the number of persons
entering in any room like seminar hall, conference room, classroom etc. LCD displays
number of person inside the room. The device counts the total number of people entering
through the gate and also the total number of people leaving through the same gate. And
finally, it calculates the total number of current people by subtracting the outgoing visitors
from the incoming visitors on the display. This is a bidirectional counter which means
it works in a two way. That means counter will be incremented if person enters the room and
will be decremented if a person leaves the room. LCD displays this value which is placed
outside the room. In addition, we have another function for this project is to monitor the
multiple classrooms through the website. Visitors data uploads automatically to the
thingSpeak cloud using the Wi-Fi Module. We will see the data in LCD display as well as in
cloud platform.
1.2 Main Objective
The main objective of this project is to monitor the total number of students in
multiple classrooms at different time slots at online from any part of the world using
ThingSpeak platform. The visitors data will be uploaded automatically to ThingSpeak cloud
at a specified interval of time using the ESP8266 Wi-Fi module. We are also included the
attendance system feature for the students those who are in the class room. It is mandatory for
the college management to take attendance for each and every period throughout the
academic timetable.

1
BI-DIRECTIONAL VISITOR COUNTER USING IOT

By implementing this proposed attendance system, even though it is manual we can replace
the attendance paper sheet with the website thus, saving the paper.
1.3 Block diagram of Bi-directional visitor counter
The block diagram of bi-directional visitor counter is as shown in the Fig.1.1. Arduino
Uno is the heart of the circuit, it controls all the components connected to it. We have used
two IR sensors for detecting the persons, one is used for detecting the incoming persons and
other is used for detecting the outgoing persons. Finally, we will see the data in LCD display
as well as in cloud platform.

ThingSpeak

cloud

IR sensor

(IN)
ESP8266 Wi-Fi
Module

IR sensor
Arduino UNO
(OUT)
16x2

Power LCD display

supply

Fig.1.1 Block Diagram of bi-directional visitor counter

2
BI-DIRECTIONAL VISITOR COUNTER USING IOT

CHAPTER-2
HARDWARE COMPONENTS

The hardware components of this project are as listed below. The pin descriptions and the
features of each and every component were explained very clearly below.

1. Arduino UNO
2. Power supply
3. ESP8266 Wi-Fi Module
4. IR sensor
5. LCD display
2.1 Arduino UNO

Arduino interface boards provide the engineers, artists, designers, hobbyists and
anyone who tinker with technology with a low-cost, easy-to- use technology to create their
creative, interactive objects, useful projects etc., A whole new breed of projects can now be
built that can be controlled from a computer. It is an open source computer hardware and
software company, project, and user community that designs and manufactures single-board
microcontrollers and microcontroller kits for building digital devices and interactive objects
that can sense and control objects in the physical and digital world. The project's products
are distributed as open-source hardware and software, which are licensed under the GNU
Lesser General Public License(LGPL) or the GNU General Public License(GPL), permitting
the manufacture of Arduino boards and software distribution by anyone. Arduino boards are
available commercially in preassembled form. Arduino board designs use a variety of
microprocessors and controllers. The boards are equipped with sets of digital and analog
input/output (I/O) pins that may be interfaced to various expansion boards or Breadboards
(shields) and other circuits. The boards feature serial communications interfaces, including
Universal Serial Bus (USB) on some models, which are also used for loading programs from
personal computers. The microcontrollers are typically programmed using a dialect of
features from the programming languages C and C++. In addition to using traditional
compiler tool chains, the Arduino project provides an integrated development environment
(IDE) based on the Processing language project.

3
BI-DIRECTIONAL VISITOR COUNTER USING IOT

The Arduino project started in 2003 as a program for students at the Interaction
Design Institute Ivrea in Ivrea, Italy, aiming to provide a low-cost and easy way for novices
and professionals to create devices that interact with their environment using sensors and
actuators.

Arduino Uno is a microcontroller board based on the ATmega328P datasheet as


shown in Fig.2.1. It has 14 digital input/output pins (of which 6 can be used as PWM
outputs), 6 analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB
connection, a power jack, an ICSP header and a reset button. It contains everything needed to
support the microcontroller; simply connect it to a computer with a USB cable or power it
with a AC-to-DC adapter or battery to get started. You can tinker with your Uno with

out worrying too much about doing something wrong, worst case scenario you can replace
the chip for a few dollars and start over again. It’s an open-source physical computing
platform based on a microcontroller board, and a development environment for writing
software for the board.

Fig.2.1 Overview of the Arduino UNO

In simple words, Arduino is a small microcontroller board with a USB plug to connect to
computer and a number of connection sockets that can be wired up to external electronics,
such as motors, relays, light sensors, laser diodes, loudspeakers, microphones, etc., They can
either be powered through the USB connection from the computer or from a battery.

4
BI-DIRECTIONAL VISITOR COUNTER USING IOT

They can be controlled from the computer or programmed by the computer and then
disconnected and allowed to work independently. Anyone can buy this device through online
auction site or search engine. Since the Arduino is an open-source hardware designs and
create their own clones of the Arduino and sell them, so the market for the boards is
competitive. An official Arduino costs about $30and a clone often less than $20. The name
“Arduino” is reserved by the original makers. However, clone Arduino designs often have the
letters “duino” on the end of their name, for example, Freeduino or DFRduino. The software
for programming Arduino is easy to use and also freely available for Windows, Mac, and
LINUX computers at no cost.

2.1.1 Features of Arduino UNO

1. Microcontroller ATmega328P
2. Operating Voltage 5V
3. Input Voltage (recommended) 7-12V
4. Input Voltage (limit) 6-20V
5. Digital I/O Pins 14 (of which 6 provide PWM
output)
6. PWM Digital I/O Pins 6
7. Analog Input Pins 6
8. DC Current per I/O Pin 20mA
9. DC Current for 3.3V Pin 50mA
10. Flash Memory 32 KB (ATmega328P)
11. SRAM 2 KB (ATmega328P)
12. EEPROM 1 KB (ATmega328P)
13. Clock Speed 16 MHz

5
BI-DIRECTIONAL VISITOR COUNTER USING IOT

2.1.2 Pin Description

The 14 digital input/output pins can be used as input or output pins by using
pinMode(), digitalRead() and digitalWrite() functions in arduino programming as shown in
Fig.2.2. Each pin operates at 5V and can provide or receive a maximum of 40mA current and
has an internal pull-up resistor of 20-50 KOhms which are disconnected by default.  Out of
these 14 pins, some pins have specific functions as listed below:

1. Serial Pins 0 (Rx) and 1 (Tx): Rx and Tx pins are used to receive and transmit TTL
serial data. They are connected with the corresponding ATmega328P USB to TTL
serial chip.
2. External Interrupt Pins 2 and 3: These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value.
3. PWM Pins 3, 5, 6, 9 and 11: These pins provide an 8-bit PWM output by using
analogWrite() function.
4. SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for
SPI communication.
5. In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is
HIGH – LED is on and when pin 13 is LOW, its off.
6. Along with 14 Digital pins, there are 6 analog input pins, each of which provide 10
bits of resolution, i.e. 1024 different values. They measure from 0 to 5 volts but this
limit can be increased by using AREF pin with analog Reference() function.  
7. Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire
library.
8. Arduino Uno has a couple of other pins as explained below:
1. AREF: Used to provide reference voltage for analog inputs with
analogReference() function.
2. Reset Pin: Making this pin LOW, resets the microcontroller.

6
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.2.2 Arduino UNO pin description

Arduino can be used to communicate with a computer, another Arduino board or other
microcontrollers. The ATmega328P microcontroller provides UART TTL (5V) serial
communication which can be done using digital pin 0 (Rx) and digital pin 1 (Tx). An
ATmega16U2 on the board channels this serial communication over USB and appears as a
virtual com port to software on the computer. The ATmega16U2 firmware uses the standard
USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is
required. The Arduino software includes a serial monitor which allows simple textual data to
be sent to and from the Arduino board. There are two RX and TX LEDs on the arduino board
which will flash when data is being transmitted via the USB-to-serial chip and USB
connection to the computer (not for serial communication on pins 0 and 1). A Software Serial
library allows for serial communication on any of the Uno's digital pins. The ATmega328P
also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire
library to simplify use of the I2C bus.

2.2 Power Supply


Every electrical and electronic device that we use in our day-to-day life will require a
power supply. A power supply is an electrical device that supplies electric power to an
electrical load. In general, we use an AC supply of 230V 50Hz, but this power has to be
changed into the required form with required values or voltage range for providing power

7
BI-DIRECTIONAL VISITOR COUNTER USING IOT

supply to different types of devices. There are various types of power electronic converters
such as step-down converter, step-up converter, voltage stabilizer, AC to DC converter, DC
to DC converter, DC to AC converter, and so on. But, in this circuit we used a step down
transformer as a power supply as shown in the Fig.2.3, usually the 5V DC regulated power
supply circuits, are used, which can be designed using different techniques for converting the
available 230V AC power to 5V DC power. There are 4 steps to convert 230V AC to 5V DC
1. Step down the Voltage Level
The step-down converters are used for converting the high voltage into low voltage.
The converter with output voltage less than the input voltage is called as a step-down
converter is as shown in the Fig.2.3, 230V AC is converted into 12V AC using a step-down
transformer. 12V output of stepdown transformer is an RMS value and its peak value is given
by the product of square root of two with RMS value, which is approximately 17V.

Fig.2.3 Step down transformer


Step-down transformer consists of two windings, namely primary and secondary windings
where primary can be designed using a less-gauge wire with more number of turns as it is
used for carrying low-current high-voltage power, and the secondary winding using a high-
gauge wire with less number of turns as it is used for carrying high-current low-voltage
power. Transformers works on the principle of Faraday’s laws of electromagnetic induction.
2. Convert AC to DC
230V AC power is converted into 12V AC (12V RMS value wherein the peak value
is around 17V), but the required power is 5V DC; for this purpose, 12V AC power must be
primarily converted into DC power then it can be stepped down to the 5V DC.  AC power can
be converted into DC using one of the power electronic converters called as Rectifier. There

8
BI-DIRECTIONAL VISITOR COUNTER USING IOT

are different types of rectifiers, such as half-wave rectifier, full-wave rectifier and bridge
rectifier. Due to the advantages of the bridge rectifier over the half and full wave rectifier, the
bridge rectifier is frequently used for converting AC to DC.
3. Smoothing the ripples using Filter
12V DC can be regulated into 5V DC using a step-down converter, but before this, it
is required to obtain pure DC power. The output of the diode bridge is a DC consisting of
ripples also called as pulsating DC. This pulsating DC can be filtered using an inductor filter
or a capacitor filter or a resistor-capacitor-coupled filter for removing the ripples. Consider a
capacitor filter which is frequently used in most cases for smoothing. We know that a
capacitor is an energy storing element. In the circuit, capacitor stores energy while the input
increases from zero to a peak value and, while the supply voltage decreases from peak value
to zero, capacitor starts discharging. This charging and discharging of the capacitor will make
the pulsating DC into pure DC.
4. Regulating 12V DC into 5V DC using Voltage Regulator
12V DC voltage can be stepped down to 5V DC voltage using a DC step-down
converter called as voltage regulator IC7805. The first two digits ‘78’ of IC7805 voltage
regulator represent positive series voltage regulators and the last two digits ‘05’ represents
the output voltage of the voltage regulator.

2.3 ESP8266 Wi-Fi Module

ESP8266 is an UART Wi-Fi transparent transmission module with ultralow power


consumption, specially designed for the needs of a new connected world. It offers a complete
and self-contained Wi-Fi networking solution, allowing it to either host the application or to
offload all Wi-Fi networking functions from anotherapplicationprocessor.ESP8266 has
powerful on-board processing and storage capabilities that allow it to be integrated with the
sensors and other application specific devices through its GPIOs with minimal development
up-front and minimal loading during runtime. Its high degree of on-chip integration allows
for minimal external circuitry, and the entire solution, including front-end module, is
designed to occupy minimal PCB area. ESP8266 Serial Wi-Fi Wireless Transceiver Module
is suitable for Uno, Mega 2560 and Nano. The ESP8266 is a very user friendly and low-cost
device to provide internet connectivity to your projects. The module can work both as a
Access point (can create hotspot) and as a station (can connect to Wi-Fi), hence it can
easily fetch data and upload it to the internet making Internet of Things as easy as possible. It

9
BI-DIRECTIONAL VISITOR COUNTER USING IOT

can also fetch data from internet using API’s hence your project could access any information
that is available in the internet, thus making it smarter. Another exciting feature of this
module is that it can be programmed using the Arduino IDE which makes it a lot more user
friendly.

The ESP8266 Wi-Fi Module is a self-contained SOC with integrated TCP/IP protocol
stack that can give any microcontroller access to your Wi-Fi network is as shown in Fig.2.4.
The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking
functions from another application processor. Each ESP8266 module comes pre-programmed
with an AT command set firmware, meaning, you can simply hook this up to your Arduino
device and get about as much WIFI-ability as a Wi-Fi Shield offers (and that's just out of the
box). The ESP8266 module is an extremely cost-effective board with a huge, and ever
growing, community. This module has a powerful enough on-board processing and storage
capability that allows it to be integrated with the sensors and other application specific
devices through its GPIOs with minimal development up-front and minimal loading during
runtime. Its high degree of on-chip integration allows for minimal external circuitry,
including the front-end module, is designed to occupy minimal PCB area. The ESP8266
supports APSD for VoIP applications and Bluetooth co-existence interfaces, it contains a
self-calibrated RF allowing it to work under all operating conditions and requires no external
RF parts. The overview of ESP8266 Wi-Fi Module is as shown in Fig.2.4.

Fig.2.4 Overview of Wi-Fi Module

10
BI-DIRECTIONAL VISITOR COUNTER USING IOT

2.3.1 Pin Description

ESP8266 Wi-Fi module contains 8 different pins as shown in Fig.2.5, which are used for
different purposes.

1. Ground: ground pin is normally used to Connect the ground of the circuit.
2. TX: Transmitter pin is used to Connect to Rx pin of programmer/uC to upload
program and its alternative name is GPIO-1. The alternative purpose of this pin is that
it Can act as a General purpose Input/output pin when not used as TX
3. GPIO-2: It is a General purpose Input/output pin
4. CH_EN: It is a channel enable pin, which is set to high to enable the Wi-Fi module.
5. GPIO-0: It is another General purpose Input/output pin. The another purpose of this
module is it takes module into serial programming when held low during start up.
6. Reset: Reset pin is used to resets the module.
7. RX: It can act as a General purpose Input/output pin when not used as RX, so the
alternate name for this pin is GPIO-3.
8. VCC: used to connect the +3.3V only.

Fig.2.5 Pin description of Wi-Fi module

2.3.2 Features of Wi-Fi Module


1. Low cost, compact and powerful Wi-Fi Module
2. Power Supply: +3.3V only
3. Current Consumption: 100mA
4. I/O Voltage:  3.6V (max)
5. I/O source current: 12mA (max)

11
BI-DIRECTIONAL VISITOR COUNTER USING IOT

6. Built-in low power 32-bit MCU @ 80MHz


7. 512kB Flash Memory
8. Can be used as Station or Access Point or both combined
9. Supports Deep sleep (<10uA)
10. Supports serial communication hence compatible with many development platform
like Arduino
11. Can be programmed using Arduino IDE or AT-commands or Lua Script.

2.4 IR Sensor

IR sensor is an electronic device, that emits the light in order to sense some object of
the surroundings. An IR sensor can measure the heat of an object as well as detects the
motion. Usually, in the infrared spectrum, all the objects radiate some form of thermal
radiation. These types of radiations are invisible to our eyes, but infrared sensor can detect
these radiations. An infrared (IR) sensor is an electronic device that measures and detects
infrared radiation in its surrounding environment.

Infrared radiation was accidentally discovered by an astronomer named William


Herchel in 1800. While measuring the temperature of each color of light (separated by a
prism), he noticed that the temperature just beyond the red light was highest. IR is invisible to
the human eye, as its wavelength is longer than that of visible light (though it is still on the
same electromagnetic spectrum). Anything that emits heat gives off infrared radiation.

There are two types of infrared sensors: active and passive. Active infrared sensors
both emit and detect infrared radiation. Active IR sensors have two parts: a light emitting
diode (LED) and a receiver. When an object comes close to the sensor, the infrared light from
the LED reflects off of the object and is detected by the receiver. Active IR sensors act as
proximity sensor, and they are commonly used in obstacle detection systems. Passive infrared
(PIR) sensors only detect infrared radiation and do not emit it from an LED.PIR sensors are
most commonly used in motion-based detection, such as in-home security systems.

12
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.2.6 IR Sensor

2.4.1 Pin Description

The IR sensor module consists mainly of the IR Transmitter and Receiver, Opamp, Variable
Resistor (Trimmer pot), output LED as shown in Fig.2.6.

1. IR LED Transmitter: IR LED emits light, in the range of Infrared frequency. IR


light is invisible to us as its wavelength (700nm – 1mm) is much higher than the
visible light range. IR LEDs have light emitting angle of approx. 20-60 degree and
range of approx. few centimeters to several feets, it depends upon the type of IR
transmitter and the manufacturer. Some transmitters have the range in kilometers. IR
LED white or transparent in color, so it can give out amount of maximum light.
2. Photodiode Receiver: Photodiode acts as the IR receiver as its conducts when light
falls on it. Photodiode is a semiconductor which has a P-N junction, operated in
Reverse Bias, means it start conducting the current in reverse direction when Light
falls on it, and the amount of current flow is proportional to the amount of Light. This
property makes it useful for IR detection. Photodiode looks like a LED, with a black
colour coating on its outer side, Black colour absorbs the highest amount of light.
3. LM358 Opamp :LM358 is an Operational Amplifier (Op-Amp) is used as voltage
comparator in the IR sensor. the comparator will compare the threshold voltage set
using the preset and the photodiode’s series resistor voltage. When Opamp's output
is high the LED at the Opamp output terminal turns ON. 
1. Photodiode’s series resistor voltage drop > Threshold voltage = Opamp output
is High

13
BI-DIRECTIONAL VISITOR COUNTER USING IOT

2. Photodiode’s series resistor voltage drop < Threshold voltage = Opamp output
is Low
4. Variable Resistor: The variable resistor used here is a preset. It is used to calibrate
the distance range at which object should be detected.
2.4.2 Working of an IR Sensor
An IR sensor consists of two parts, the emitter or transmitter circuit and the receiver
circuit as shown in below Fig.2.7. This is collectively known as a photo-coupler or an
optocoupler. The emitter is an IR LED and the detector is an IR photodiode. The IR
photodiode is sensitive to the IR light emitted by an IR LED. The photo-diode’s resistance
and output voltage change in proportion to the IR light received. This is the underlying
working principle of the IR sensor. The type of incidence can be direct incidence or indirect
incidence. In direct incidence, the IR LED is placed in front of a photodiode with no obstacle
in between. In indirect incidence, both the diodes are placed side by side with an opaque
object in front of the sensor. The light from the IR LED hits the opaque surface and reflects
back to the photodiode. When the IR transmitter emits radiation, it reaches the object and
some of the radiation reflects back to the IR receiver. Based on the intensity of the reception
by the IR receiver, the output of the sensor defines.

Fig.2.7 Working of an IR Sensor


2.4.3 Features of IR Sensor
1. 5VDC Operating voltage
2. I/O pins are 5V and 3.3V compliant
3. Range: Up to 10cm
4. Adjustable Sensing range

14
BI-DIRECTIONAL VISITOR COUNTER USING IOT

5. Built-in Ambient Light Sensor


6. 20mA supply current.

2.5 16X2 LCD Display

LEDs or 7segment do not have the flexibility to display informative


messages.Thisdisplayhas2linesandcandisplay16charactersoneachline. Nonetheless, when it is
interfaced with the microcontroller, we can scroll the messages with software to display
information which is more than 16 characters inlength.These 16 x 2 LCD display modules are
constant of 16 Columns and 2 Rows. The 1st row of this module has a total of 16 columns 0
to 15 and the position of the first row is 0. Also, the 2nd row has a total of 16 columns 0 to 15
and the position of the second row is position is 1. So the total numbers of the column are 16
x 2 = 32. Its means 16 x 2 LCD module can display 32 characters at the same time is as
shown in the Fig.2.8.

Fig.2.8 16x2 LCD Display


2.5.1 Execution of LCD
LCD accepts two types of signals, one is data, and another is control. These signals
are recognized by the LCD module from status of the RS pin. Now data can be read also from
the LCD display, by pulling the R/W pin high. As soon as the E pin is Pulsed, LCD display
reads data at the falling edge of the pulse and executes it, same for the case of transmission.
LCD displays takes a time of 39-43µS to place a character or execute a command. Except for
clearing display and to seek cursor to home position it takes1.53msto1.64ms. Any attempt to
send any data before this interval may lead to failure to read data or execution of the current
data in some devices. Some devices compensate the speed by storing the incoming data to
some temporary registers.

15
BI-DIRECTIONAL VISITOR COUNTER USING IOT

2.5.2 Pin Description


The 16×2 LCD pin-out is shown below in Fig.2.9. Total 16 pins are there in the LCD
display and it follows a a small outline package. The main benefits of using this module are
inexpensive; simply programmable, animations, and there are no limitations for displaying
custom characters, special and even animations, etc.

Fig.2.9 16X2 LCD Pin diagram

1. Pin1 (Ground/Source Pin): This is a GND pin of display, used to connect the GND
terminal of the microcontroller unit or power source.
2. Pin2 (VCC/Source Pin): This is the voltage supply pin of the display, used to connect the
supply pin of the power source.
3. Pin3 (V0/VEE/Control Pin): This pin regulates the difference of the display, used to
connect a changeable POT that can supply 0 to 5V.
4. Pin4 (Register Select/Control Pin): This pin toggles among command or data register,
used to connect a microcontroller unit pin and obtains either 0 or 1(0 = data mode, and 1
= command mode).

16
BI-DIRECTIONAL VISITOR COUNTER USING IOT

5. Pin5 (Read/Write/Control Pin): This pin toggles the display among the read or writes
operation, and it is connected to a microcontroller unit pin to get either 0 or 1 (0 = Write
Operation, and 1 = Read Operation).
6. Pin 6 (Enable/Control Pin): This pin should be held high to execute Read/Write process,
and it is connected to the microcontroller unit & constantly held high.
7. Pins 7-14 (Data Pins): These pins are used to send data to the display. These pins are
connected in two-wire modes like 4-wire mode and 8-wire mode. In 4-wire mode, only
four pins are connected to the microcontroller unit like 0 to 3, whereas in 8-wire mode,
8-pins are connected to microcontroller unit like 0 to 7.
8. Pin15 (+ve pin of the LED): This pin is connected to +5V.
9. Pin 16 (-ve pin of the LED): This pin is connected to GND.

2.5.3 Features of LCD Display


The features of this LCD mainly include the following.

1. The operating voltage of this LCD is 5V.


2. It includes two rows where each row can produce 16-characters.
3. The utilization of current is 1mA with no backlight.
4. Every character can be built with a 5×8 pixel box.
5. The alphanumeric LCDs alphabets & numbers.
6. Is display can work on two modes like 4-bit & 8-bit.
7. These are obtainable in Blue & Green Backlight.
8. It displays a few custom generated characters.

17
BI-DIRECTIONAL VISITOR COUNTER USING IOT

CHAPTER-3

SOFTWARE DEVELOPMENT

In this project we are using an Arduino ide software to program the Arduino UNO,
Things Speak server to see the data updated on the server. HTML5 and Bootstrap are used for
a project website.

3.1 Arduino IDE Software

The software used by the Arduino is Arduino IDE. The Arduino IDE is a cross-
platform application written in Java, and is derived from the IDE for the Processing
programming language and the Wiring project. It is designed to introduce programming to
artists and other newcomers unfamiliar with software development. It includes a code editor
with features such as syntax, highlighting, brace matching, and automatic indentation, and is
also capable of compiling and uploading programs to the board with a single click. There is
typically no need to edit make files or run programs on command-line interface. The first time
you run the Arduino software, it will automatically create a directory for your sketchbook.

Fig.3.1 Window of the Arduino IDE software


you can view or change the location of the sketchbook location from with the
Preferences dialog. The source code for the IDE is released under the GNU General Public

18
BI-DIRECTIONAL VISITOR COUNTER USING IOT

License, version 2. The Arduino IDE supports the languages C and C++ using special rules of
code structuring. .The Arduino IDE comes with a C/C++ library called "Wiring" (from the
project of the same name), which makes many common input/output operations much easier.
Arduino programs are written in C/C++, although users only need define two functions to
make a runnable program.
1. setup() – a function run once at the start of a program that can initialize
settings.
2. loop() – a function called repeatedly until the board powers off.
The Arduino IDE supplies a software library from the Wiring project, which provides many
common input and output procedures. The Fig.3.1 shows the Arduino IDE. User-written code
only requires two basic functions, for starting the sketch and the main program loop, that are
compiled and linked with a program stub main() into an executable cyclic executive program
with the GNU tool chain, also included with the IDE distribution. The Arduino IDE employs
the program avrdude to convert the executable code into a text file in hexadecimal encoding
that is loaded into the Arduino board by a loader program in the board's firmware, as shown
in Programs written using Arduino Software (IDE) are called sketches.
These sketches are written in the text editor and are saved with the file extension .ino. The
editor has features for cutting/pasting and for searching/replacing text. The message area
gives feedback while saving and exporting and also displays errors. The console displays text
output by the Arduino Software (IDE), including complete error messages and other
information. The bottom right hand corner of the window displays the configured board and
serial port. The toolbar buttons are as shown in Fig.3.2.

Fig.3.2 Toolbar Buttons


1. Verify: Checks your code for errors compiling it.
2. Upload: Compiles your code and uploads it to the configured board. See
uploading below for details.
3. New: Creates a new sketch.

19
BI-DIRECTIONAL VISITOR COUNTER USING IOT

4. Open: Presents a menu of all the sketches in your sketchbook. Clicking one will
open it within the current window overwriting its content.
5. Save: Saves your sketch.
Additional commands are found within the five menus: File, Edit, Sketch, Tools, Help as
shown in Fig.3.3. The menus are context sensitive, which means only those items relevant to
the work currently being carried out are available.

Fig.3.3 Menu bar


3.1.1 File
In the option file we are going to have the following features as explained below,
1. New: Creates a new instance of the editor, with the bare minimum structure of a
sketch already in place.
2. Open: Allows to load a sketch file browsing through the computer drives and
folders.
3. Open Recent: Provides a short list of the most recent sketches, ready to be
opened.
4. Sketchbook: Shows the current sketches within the sketchbook folder structure;
clicking on any name opens the corresponding sketch in a new editor instance.
5. Examples: Any example provided by the Arduino Software (IDE) or library
shows up in this menu item. All the examples are structured in a tree that allows
easy access by topic or library.
6. Close: Closes the instance of the Arduino Software from which it is clicked.
7. Save: Saves the sketch with the current name. If the file hasn't been named before,
a name will be provided in a "Save as" window.
8. Save as: Allows to save the current sketch with a different name.
9. Page Setup: It shows the Page Setup window for printing.
10. Print: Sends the current sketch to the printer according to the settings defined in
Page Setup.
11. Preferences: Opens the Preferences window where some settings of the IDE may
be customized, as the language of the IDE interface.

20
BI-DIRECTIONAL VISITOR COUNTER USING IOT

12. Quit: Closes all IDE windows. The same sketches open when Quit was chosen
will be automatically reopened the next time you start the IDE.
3.1.2 Edit
In the option Edit we are going to have the following features as explained below,
1. Undo/Redo: Goes back of one or more steps you did while editing; when you go
back, you may go forward with Redo.
2. Cut: Removes the selected text from the editor and places it into the clipboard.
3. Copy: Duplicates the selected text in the editor and places it into the clipboard.
4. Copy for Forum: Copies the code of your sketch to the clipboard in a form
suitable for posting to the forum, complete with syntax colouring.
5. Copy as HTML: Copies the code of your sketch to the clipboard as HTML,
suitable for embedding in web pages.
6. Paste: Puts the contents of the clipboard at the cursor position, in the editor.
7. Select All: Selects and highlights the whole content of the editor.
8. Comment/Uncomment: Puts or removes the // comment marker at the
beginning of each selected line.
9. Increase/Decrease Indent: Adds or subtracts a space at the beginning of each
selected line, moving the text one space on the right or eliminating a space at the
beginning.
10. Find: Opens the Find and Replace window where you can specify text to search
inside the current sketch according to several options.
11. Find Next: Highlights the next occurrence - if any - of the string specified as the
search item in the Find window, relative to the cursor position.
12. Find Previous: Highlights the previous occurrence - if any - of the string
specified as the search item in the Find window relative to the cursor position.
3.1.3 Sketch
In the option sketch we are going to have the following features as explained below,
1. Verify/Compile: Checks your sketch for errors compiling it; it will report
memory usage for code and variables in the console area.
2. Upload: Compiles and loads the binary file onto the configured board through
the configured Port.
3. Upload Using Programmer: This will overwrite the boot loader on the board;
you will need to use Tools > Burn Boot loader to restore it and be able to Upload
to USB serial port again. However, it allows you to use the full capacity of the

21
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Flash memory for your sketch. Please note that this command will NOT burn the
fuses. To do so a Tools -> Burn Boot loader command must be executed.
4. Export Compiled Binary: Saves a .hex file that may be kept as archive or sent
to the board using other tools.
5. Show Sketch Folder: Opens the current sketch folder.
6. Include Library: Adds a library to your sketch by inserting #include statements
at the start of your code. For more details, see libraries below. Additionally, from
this menu item you can access the Library Manager and import new libraries
from .zip files.
7. Add File: Adds a source file to the sketch (it will be copied from its current
location). The new file appears in a new tab in the sketch window. Files can be
removed from the sketch using the tab menu accessible clicking on the small
triangle icon below the serial monitor one on the right-side of the toolbar.
Adds a source file to the sketch (it will be copied from its current location). The new file
appears in a new tab in the sketch window. Files can be removed from the sketch using the
tab menu accessible clicking on the small triangle icon below the serial monitor one on the
right-side of the toolbar. These sketches are written in the text editor and are saved with the
file extension .ino. The editor has features for cutting/pasting and for searching/replacing
text. The message area gives feedback while saving and exporting and also displays errors.
The console displays text output by the Arduino Software (IDE), including complete error
messages and other information.
The bottom right hand corner of the window displays the configured board and serial port.
The toolbar buttons Adds a source file to the sketch (it will be copied from its current
location). The new file appears in a new tab in the sketch window. Files can be removed from
the sketch using the tab menu accessible clicking on the small triangle icon below the serial
monitor one on the right-side of the toolbar. These sketches are written in the text editor and
are saved with the file extension .ino. The editor has features for cutting/pasting and for
searching/replacing text. The message area gives feedback while saving and exporting and
also displays errors. The console displays text output by the Arduino Software (IDE),
including complete error messages and other information.

22
BI-DIRECTIONAL VISITOR COUNTER USING IOT

3.1.4 Tools
In the option Tools we are going to have the following features as explained below,
1. Auto Format: This formats your code nicely: i.e. indents it so that opening and
closing curly braces line up, and that the statements inside curly braces are
indented more.
2. Archive Sketch: Archives a copy of the current sketch in .zip format. The
archive is placed in the same directory as the sketch.
3. Fix Encoding & Reload: Fixes possible discrepancies between the editor char
map encoding and other operating systems char maps.
4. Serial Monitor: Opens the serial monitor window and initiates the exchange of
data with any connected board on the currently selected Port. This usually resets
the board, if the board supports Reset over serial port opening.
5. Board: Select the board that you're using. See below for descriptions of the
various boards.
6. Port: This menu contains all the serial devices (real or virtual) on your machine.
It should automatically refresh every time you open the top-level tools menu.
7. Programmer: For selecting a hardware programmer when programming a board
or chip and not using the onboard USB-serial connection. Normally you won't
need this, but if you're burning a boot loader to a new microcontroller, you will
use this.
8. Burn Boot loader: The items in this menu allow you to burn a boot loader onto
the microcontroller on an Arduino board. This is not required for normal use of
an Arduino or Genuino board but is useful if you purchase a new ATmega
microcontroller (which normally come without a boot loader). Ensure that you've
selected the correct board from the Boards menu before burning the boot loader
on the target board. This command also set the right fuses. The items in this
menu allow you to burn a boot loader onto the microcontroller on an Arduino
board. This is not required for normal use of an Arduino or Genuino board but is
useful if you purchase a new ATmega microcontroller (which normally come
without a bootloader). Ensure that you've selected the correct board from the
Boards menu before burning the boot loader on the target board. This command
also set the right fuses.

23
BI-DIRECTIONAL VISITOR COUNTER USING IOT

3.1.5 Help
Here you find easy access to a number of documents that come with the Arduino
Software (IDE). You have access to Getting Started, Reference, this guide to the IDE and
other documents locally, without an internet connection. The documents are a local copy of
the online ones and may link back to our online website.
3.2 Uploading
Before uploading your sketch, you need to select the correct items from the Tools >
Board and Tools > Port menus. The boards are described below. On the Mac, 51 the serial
port is probably something like /dev/tty.usbmodem241 (for an Uno or Mega2560 or
Leonardo) or /dev/tty.usbserial-1B1 (for a Duemilanove or earlier USB board), or /dev/tty. as
shown in Fig.3.4.

Fig.3.4 Uploading the file.


USA19QW1b1P1.1 (for a serial board connected with a Key span USB-to-Serial
adapter). On Windows, it's probably COM1 or COM2 (for a serial board) or COM4, COM5,
COM7, or higher (for a USB board) - to find out, you look for USB serial device in the ports
section of the Windows Device Manager. On Linux, it should be /dev/ttyACMx,
/dev/ttyUSBx or similar. Once you have selected the correct serial port and board, press the
upload button in the toolbar or select the upload item from the sketch menu. Current arduino
boards will reset automatically and begin the upload. With older boards (pre-Diecimila) that
lack auto-reset.
Once you've selected the correct serial port and board, press the upload button in the
toolbar or select the Upload item from the Sketch menu. Current Arduino boards will reset
automatically and begin the upload. With older boards (pre-Diecimila) that lack auto-reset,
you'll need to press the reset button on the board just before starting the upload. On most
boards, you'll see the RX and TX LEDs blink as the sketch is uploaded. The Arduino
Software (IDE) will display a message when the upload is complete, or show an error. When

24
BI-DIRECTIONAL VISITOR COUNTER USING IOT

you upload a sketch, you're using the Arduino boot loader, a small program that has been
loaded on to the microcontroller on your board. It allows you to upload code without using
any additional hardware. The boot loader is active for a few seconds when the board resets.
then it starts whichever sketch was most recently uploaded to the microcontroller. The boot
loader will blink the on-board (pin 13) LED when it starts. Once you have selected the
correct serial pot and board, press the upload button in the toolbar or select the upload item
from the sketch menu. current arduino boards will reset automatically and begin the upload.
with older boards that lack auto reset, you will see the leds blink as the sketch is uploaded.
The arduino software will display a message when the upload is complete or show an error.
when you upload a sketch, you are using the arduino boot loader, a small program that has
been loaded on to the microcontroller on your board. It allows you to upload code without
using any additional hardware. The boot loader is active for a few seconds when the board
resets, then it starts whichever sketch was most recently uploaded to the microcontroller. The
boot loader will blink the on board led when it starts. Once you have selected the correct
serial pot and board, press the upload. when you upload a sketch, you are using the arduino
boot loader, a small program that has been loaded on to the microcontroller on your board. It
allows you to upload code without using any additional hardware. The boot loader is active
for a few seconds when the board resets.
The arduino software will display a message when the upload is complete, or show an
error. When you upload a sketch, you are using the arduino boot loader, a small program that
has been loaded on to the microcontroller on your board. It allows you to upload code
without using any additional hardware. The boot loader is active for a few seconds when the
board resets, then it starts whichever sketch was most recently uploaded to the
microcontroller. The boot loader will blink the on board led when you upload a sketch, you
are using the arduino boot loader, a small program that has been loaded on to the
microcontroller on your board. It allows you to upload code without using any additional
hardware. The boot loader is active for a few seconds when the board resets; then it starts
whichever sketch was most recently uploaded to the microcontroller. The boot loader will
blink the on-board (pin 13) LED when it starts (i.e. when the board resets).
3.3 Libraries
Libraries provide extra functionality for use in sketches, e.g. working with hardware
or manipulating data. To use a library in a sketch, select it from the Sketch > Import Library
menu. This will insert one or more #include statements at the top of the sketch and compile

25
BI-DIRECTIONAL VISITOR COUNTER USING IOT

the library with your sketch. Because libraries are uploaded to the board with your sketch,
they increase the amount of space it takes up. If a sketch no longer needs a library, simply
delete its #include statements from the top of your code. There is a list of libraries in the
reference. Some libraries are included with the Arduino software. Others can be downloaded
from a variety of sources or through the Library Manager. Starting with version 1.0.5 of the
IDE, you do can import a library from a zip file and use it in an open sketch. See these
instructions for installing a third-party library.
3.4 Standard Libraries
In the standard libraries, we are going to have the following features as explained below,
1. EEPROM - reading and writing to "permanent" storage
2. Ethernet - for connecting to the internet using the Arduino Ethernet Shield,
Arduino Ethernet Shield 2 and Arduino Leonardo ETH
3. Firmata - for communicating with applications on the computer using a standard
serial protocol.
4. GSM - for connecting to a GSM/GRPS network with the GSM shield.
5. Liquid Crystal - for controlling liquid crystal displays (LCDs)
6. SD - for reading and writing SD cards
7. Servo - for controlling servo motors
8. SPI - for communicating with devices using the Serial Peripheral Interface (SPI)
Bus
9. Software Serial - for serial communication on any digital pins. Version 1.0 and
later of Arduino incorporate Mikal Hart's New Soft Serial library as Software
Serial.
10. Stepper - for controlling stepper motors
11. TFT - for drawing text, images, and shapes on the Arduino TFT screen
12. Wi-Fi - for connecting to the internet using the Arduino Wi-Fi shield
13. Wire - Two Wire Interface (TWI/I2C) for sending and receiving data over a net of
devices or sensors.
14. The Matrix and Sprite libraries are no longer part of the core distribution.
3.5 Third-Party Hardware
Support for third-party hardware can be added to the hardware directory of your
sketchbook directory. Platforms installed there may include board definitions (which appear
in the board menu), core libraries, boot loaders, and programmer definitions.

26
BI-DIRECTIONAL VISITOR COUNTER USING IOT

To install, create the hardware directory, then unzip the third-party platform into its own
sub-directory. (Don't use "Arduino" as the sub-directory name or you'll override the built-in
Arduino platform.) To uninstall, simply delete its directory. For details on creating packages
for third-party hardware, see the Arduino IDE 1.5 3rd party Hardware specification.
3.6 Serial Monitor
This displays serial sent from the Arduino or Genuino board over USB or serial
connector, To send data to the board, enter text and click on the "send" button or press enter.
Choose the baud rate from the drop-down menu that matches the rate passed to Serial. begin
in your sketch. Note that on Windows, Mac or Linux the board will reset (it will rerun your
sketch) when you connect with the serial monitor. Please note that the Serial Monitor does
not process control characters; if your sketch needs a complete management of the serial
communication with control characters, you can use an external terminal program and
connect it to the COM port assigned to your Arduino board. You can also talk to the board
from Processing, Flash, MaxMSP, etc (we can see the interfacing page for details). The boot
loader is active for a few seconds when the board resets; then it starts whichever sketch was
most recently uploaded to the microcontroller. The boot loader will blink the on-board (pin
13) LED when it starts (i.e. when the board resets).
Choose the baud rate from the drop-down menu that matches the rate passed to Serial.
begin in your sketch. Note that on Windows, Mac or Linux the board will reset (it will rerun
your sketch) when you connect with the serial monitor. Please note that the Serial Monitor
does not process control characters; if your sketch needs a complete management of the serial
communication with control characters.

Fig.3.5 Serial monitor window

27
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Choose the baud rate from the drop-down menu that matches the rate passed to Serial. begin
in your sketch. Note that on Windows, Mac or Linux the board will reset (it will rerun your
sketch) when you connect with the serial monitor. Please note that the Serial Monitor does
not process control characters; if your sketch needs a complete management of the serial
communication as shown in Fig.3.5.
3.7 ThingSpeak
According to its developers, ThingSpeak is an open-source Internet of Things (IoT)
application and API to store and retrieve data from things using the HTTP and MQTT
protocol over the Internet or via a Local Area Network. ThingSpeak enables the creation of
sensor logging applications, location tracking applications, and a social network of things
with status updates. ThingSpeak was originally launched by ioBridge in 2010 as a service in
support of IoT applications. ThingSpeak has integrated support from the numerical
computing. software MATLAB from Math Works, allowing ThingSpeak users to analyze and
visualize uploaded data using Matlab without requiring the purchase of a Matlab license from
Math works.
ThingSpeak has a close relationship with Math works, Inc. In fact, all of the
ThingSpeak documentation is incorporated into the Math works Matlab
documentation site and even enabling registered Math works user accounts as valid login
credentials on the ThingSpeak website. The terms of service and privacy policy of
ThingSpeak.com are between the agreeing user and Math works, Inc. ThingSpeak has been
the subject of articles in specialized Maker websites like Instructables, Code project.
ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize and
analyze live data streams in the cloud. ThingSpeak provides instant visualizations of data
posted by your devices to ThingSpeak. With the ability to execute MATLAB code in
ThingSpeak you can perform online analysis and processing of the data as it comes in.
ThingSpeak is often used for prototyping and proof of concept IOT systems that require
analytics.
3.7.1 ThingSpeak  Key Features
ThingSpeak allows you to aggregate, visualize and analyze live data streams in the cloud.
Some of the key capabilities of ThingSpeak include the ability to
1. Easily configure devices to send data to ThingSpeak using popular IoT protocols.
2. Visualize your sensor data in real-time.
3. Aggregate data on-demand from third-party sources.

28
BI-DIRECTIONAL VISITOR COUNTER USING IOT

4. Use the power of MATLAB to make sense of your IoT data.


5. Run your IoT analytics automatically based on schedules or events.
6. Prototype and build IoT systems without setting up servers or developing web
software.
7. Automatically act on your data and communicate using third-party services like
Twilio or Twitter.
3.7.2Working of ThingSpeak
ThingSpeak is an IoT analytics platform service that allows you to aggregate,
visualize and analyze live data streams in the cloud. ThingSpeak provides instant
visualizations of data posted by your devices to ThingSpeak. With the ability to execute
MATLAB code in ThingSpeak you can perform online analysis and processing of the data as
it comes in. ThingSpeak is often used for prototyping and proof of concept IoT systems that
require analytics. Internet of Things (IoT) describes an emerging trend where a large number
of embedded devices (things) are connected to the Internet. These connected devices
communicate with people and other things and often provide sensor data to cloud storage and
cloud computing resources where the data is processed and analyzed to gain important
insights. Cheap cloud computing power and increased device connectivity is enabling this
trend.
IoT solutions are built for many vertical applications such as environmental monitoring and
control, health monitoring, vehicle fleet monitoring, industrial monitoring and control, and
home automation. In order to connect an object to the IoT, several things are needed in the
hardware and software realm. First of all, if one wishes to go beyond simply connecting data
from a computer, objects to gather (sensors) or receive (actuators) data are necessary. For
example, a digital thermometer can be used to measure temperature. In this case, the data
needs to be uploaded to a network of connected servers which run applications. Such a
network is commonly referred to as ‘the cloud’. The cloud utilizes the process of
visualization, meaning that several physical servers can be connected and used in tandem, but
appear to the user as one machine (despite that at the physical level, the machines function
independently) as shown in Fig.3.6.

29
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.3.6 Working of ThingSpeak


This method of computing thus allows changes to be made to the ‘virtual’ server (such as
software updates or changes in storage space) much easier than before. In this case, an object
will connect to the cloud through a (possibly wireless) Internet connection to upload or
receive data. Objects to be connected are typically augmented with either sensors or
actuators. A sensor is something that tells us about our environment. Think of a temperature
sensor, or even the GPS receiver on your mobile phone. Actuators are something that you
want to control. Things like thermostats, lights, pumps, and outlets. The IoT brings
everything together and allows us to interact with our things and, even more interestingly,
allows things to interact with other things. For the purpose of connecting an object to the IoT,
we focus on the ThingSpeak API. The interface provides simple communication capabilities
to objects within the IoT environment, as well as interesting additional applications (such as
Thing Tweet, which will be further discussed in a later section). Moreover, ThingSpeak
allows you to build applications around data collected by sensors. It offers near real-time data
collection, data processing, and also simple visualizations for its users.
Data is stored in so-called channels, which provides the user with a list of features.
Each channel allows you to store up to 8 fields of data, using up to 255 alphanumeric
characters each. There are also 4 dedicated fields for positional data, consisting of:
Description, Latitude, Longitude, and Elevation. All incoming data is time and date stamped
and receives a sequential ID. Once a channel has been created, data can be published by
accessing the ThingSpeak API with a ‘write key’, a randomly created unique alphanumeric
string used for authentication. Consequently, a ‘read key’ is used to access channel data in

30
BI-DIRECTIONAL VISITOR COUNTER USING IOT

case it is set to keep its data private (the default setting). Channels can also be made public in
which case no read key is required. According to the ThingSpeak website, the API works as
noted. Essentially, ‘things’ are objects that are given sensors to collect data. Data is sent and
received via simple “Hypertext Transfer Protocol” (HTTP) POSTs, much like going to a web
page and filling out a form. This communication happens through plaintext, JSON or XML.
The data is then uploaded to the cloud and from there can be used for a variety of
purposes. In turn, data (such as commands or choosing certain options) can be gathered and
communicated to the cloud, which in turn sends these messages to the object. A deeper level
of what occurs, especially on the server side, can be seen in. When a device sends data
through a HTTP request (communication), it is processed by the IoT service (in this case
ThingSpeak), which communicates with a virtual server. Both the server and the IoT service
communicate directly with the application. Finally, at all levels of communication from the
device to the application there is both requirements regarding security and management of the
data transfer. Unfortunately, ThingSpeak does not document how the specific parts of the
diagram are handled on a technical level. Given enough time and expertise, it should however
be possible to answer this by looking into the (open source) code base.
3.8 HTML5
HTML stands for Hyper Text Markup Language. It is used to design web pages
using markup language. HTML is the combination of Hypertext and Markup language.
Hypertext defines the link between the web pages. Markup language is used to define the
text document within tag which defines the structure of web pages. HTML5 is the fifth and
current version of HTML. It has improved the markup available for documents and has
introduced application programming interfaces (API) and Document Object
Model(DOM).HTML5 is a markup language used for structuring and presenting content on
the World Wide Web. It is the fifth and last major HTML version that is a World Wide Web
Consortium (W3C) recommendation. The current specification is known as the HTML
Living Standard. It is maintained by a consortium of the major browser vendors
(Apple, Google, Mozilla, and Microsoft), the Web Hypertext Application Technology
Working Group (WHATWG).

HTML5 was first released in a public-facing form on 22 January 2008, with a major


update and "W3C Recommendation" status in October 2014. Its goals were to improve the
language with support for the latest multimedia and other new features; to keep the language
both easily readable by humans and consistently understood by computers and devices such

31
BI-DIRECTIONAL VISITOR COUNTER USING IOT

as web browsers, parsers, etc., without XHTML's  rigidity; and to remain backward-


compatible with older software. HTML5 is intended to subsume not only HTML 4 but also
XHTML 1 and DOM Level 2 HTML.HTML5 includes detailed processing models to
encourage more interoperable implementations; it extends, improves, and rationalizes the
markup available for documents and introduces markup and application programming
interfaces (APIs) for complex web applications. For the same reasons, HTML5 is also a
candidate for cross-platform mobile applications because it includes features designed with
low-powered devices in mind.

3.8.1 Features of HTML5

HTML5 is the new standard for HTML. HTML5 is not something completely new.
Most of the HTML5 specifications came from HTML or HTML1.0. A web browser can read
HTML files and compose them into visible or audible web pages. The important features of
HTML5 are listed below.

1. It has introduced new multimedia features which supports audio and video
controls by using <audio> and <video> tags.
2. There are new graphics elements including vector graphics and tags.
3. Enrich semantic content by including <header><footer>, <article>, <section>
and <figure> are added.
4. Drag and Drop- The user can grab an object and drag it further dropping it on a
new location.
5. Geo-location services- It helps to locate the geographical location of a client.
6. Web storage facility which provides web application methods to store data on
web browser.
7. Uses SQL database to store data offline.
8. Allows to draw various shapes like triangle, rectangle, circle, etc.
9. Capable of handling incorrect syntax.
10. Easy DOCTYPE declaration i.e. <!doctype html>
11. Easy character encoding i.e. <meta charset=”UTF-8″>

3.8.2 New Added Elements in HTML5


HTML stands for Hypertext Markup Language, and it is the standard markup
language for creating web pages and web applications. HTML5 is the 5th version of
HTML. With invent of features in HTML5, it’s not only possible to create better websites,

32
BI-DIRECTIONAL VISITOR COUNTER USING IOT

but we can also create dynamic websites. Now let’s have a look at all the new features that
were added in HTML5 that make it better than HTML.
1. Audio and Video
Audio and Video tags are the two major addition to HTML5. It allows developers to
embed a video or audio on their website. HTML5 video can use CSS and CSS3 to style the
video tag. You can change the border, opacity, reflections, gradients, transitions,
transformations, and even animations. HTML5 makes adding video super-fast and without
having to build a video player. This saves time for the developer and offers the client a
superior and more affordable solution.
2. Vector Graphics
This is a new addition to the revised version which has hugely impacted the use of
Adobe Flash in websites. It can be used to draw graphics with various shapes and colors via
scripting usually JS. Vector graphics are scalable, easy to create and edit. It also supports
interactivity and animation. Having a smaller file size makes transferring and loading
graphics much faster on the web. That’s the reason why many people prefer to use vector
graphics.
3. Header and Footer
With these new tags, there is no longer a need to identify the two elements with a
<div> tag. Footer is placed at the end of the web page while Header is placed at the start of
the web page. By using <header> and <footer> HTML5 elements, the browser will know
what to load first and what to load later.
4. Figure and Figcaption
HTML5 allows to use a <figure> element to mark up a photo in a document, and a
<figcaption> element to define a caption for the photo. The <fig caption> tag defines a
caption for a <figure> element. This tag provides a container for content that is equivalent
to a figure. It can be used to group a caption with one or more images, a block of code, or
other content.
5. Nav tag
The <nav> tag defines a set of navigation links. It is used for the part of an internet
site that links to different pages at the website. The hyperlinks can be organized through a
number of approaches. Common examples of the nav elements are menus, tables, contents,
and indexes. This element makes it much easier to create a navigation menu, creates a neat
horizontal menu of text links, and helps screen reading software to correctly identify
primary navigation areas in the document.

33
BI-DIRECTIONAL VISITOR COUNTER USING IOT

6. Progress tag
The progress tag is used to check the progress of a task during the execution.
Progress tag can be used with the conjunction of JavaScript.
7. Storage
In the case of HTML, we can use the browser as the temporary storage whereas, in
the case of HTML5, application cache, web SQL database, and web storage is used.
8. Ease of use
While HTML5 does have risks like constant updates, it is generally easy to keep up
with the changes & updates because of simpler syntax as compared to other versions of
HTML.
9. Canvas
canvas is a tag of HTML which is newly introduced in HTML5. It is used to draw the
images on the fly. It can be used for visual images, rendering graphs, game graphics.
10. Accessibility
With the invent of HTML5 it has played a great role in providing the best of the
accessibility features to a website. This has made the use of website simplified. the people of
almost an kind of disability such as visually impaired, color blind, low vision, blind etc can
have access to the websites that have been designed with the accessibility features of
HTML5.
3.9 Bootstrap
Bootstrap is a free and open source front end development framework for the creation
of websites and web apps. The Bootstrap framework is built on HTML, CSS, and JavaScript
(JS) to facilitate the development of responsive, mobile-first sites and apps. Responsive
design makes it possible for a web page or app to detect the visitor’s screen size and
orientation and automatically adapt the display accordingly; the mobile first approach
assumes that smart phones, tablets and task-specific Mobile apps are employees' primary
tools for getting work done and addresses the requirements of those technologies in design.
Bootstrap includes user interface components, layouts and JS tools along with the
framework for implementation. The software is available precompiled or as source code.
Mark Otto and Jacob Thornton developed Bootstrap at Twitter as a means of improving the
consistency of tools used on the site and reducing maintenance. The software was formerly
known as Twitter Blueprint and is sometimes referred to as Twitter Bootstrap. In computers,
the word bootstrap means to boot: to load a program into a computer using a much smaller
initial program to load in the desired program (which is usually an operating system).

34
BI-DIRECTIONAL VISITOR COUNTER USING IOT

In the physical world, a bootstrap is a small strap or loop at the back of a leather boot that
enables you to pull the entire boot on and in general usage, bootstrapping is the leveraging of
a small initial effort into something larger and more significant. There is also a
common expression, "pulling yourself up by your own bootstraps," meaning to leverage
yourself to success from a small beginning.
3.9.1 Features of Bootstrap
Bootstrap is freely available for every. The main features of bootstrap is, it is very simple and
easy to use, hug JavaScript plugins are available, easily design mobile friendly website.
1. Easy to Use
2. Mobile-Friendly
3. Customizable Bootstrap
4. Simple Integration
5. Responsive Features
6. Browser Compatibility
7. Great Grid System
8. Bundled JavaScript plugins
9. Good Documentation

35
BI-DIRECTIONAL VISITOR COUNTER USING IOT

CHAPTER-4
INTERNET OF THINGS
4.1 Introduction

The ‘Thing’ in Internet of Things (IoT) can be any device with any kind of built-in-
sensors with the ability to collect and transfer data over a network without manual
intervention. The embedded technology in the object helps them to interact with internal
states and the external environment, which in turn helps in decisions making process as
shown in Fig.4.1.

Fig.4.1. IoT Introduction

In a nutshell, IoT is a concept that connects all the devices to the internet and let them
communicate with each other over the internet. IoT is a giant network of connected devices
all of which gather and share data about how they are used and the environments in which
they are operated. By doing so, each of your devices will be learning from the experience of
other devices, as humans do. IoT is trying to expand the interdependence in human
i.e., interact, contribute and collaborate to things. I know this sounds a bit complicated, let’s
understand this with an example.
A developer submits the application with a document containing the standards, logic,
errors & exceptions handled by him to the tester. Again, if there are any issues Tester
communicates it back to the Developer. It takes multiple iterations & in this manner a smart
application is created. Similarly, a room temperature sensor gathers the data and send it

36
BI-DIRECTIONAL VISITOR COUNTER USING IOT

across the network, which is then used by multiple device sensors to adjust their temperatures
accordingly.  For example, refrigerator’s sensor can gather the data regarding the outside
temperature and accordingly adjust the refrigerator’s temperature. Similarly, your air
conditioners can also adjust its temperature accordingly. This is how devices can interact,
contribute & collaborate.

4.2 What is Internet of Things (IoT)?


The Internet of Things may be a hot topic in the industry but it’s not a new concept. In
the early 2000’s, Kevin Ashton was laying the groundwork for what would become the
Internet of Things (IoT) at MIT’s Auto ID lab. Ashton was one of the pioneers who
conceived this notion as he searched for ways that Proctor & Gamble could improve its
business by linking RFID information to the Internet. The concept was simple but powerful.
If all objects in daily life were equipped with identifiers and wireless connectivity, these
objects could be communicate with each other and be managed by computers.

In a 1999 article for the RFID Journal Ashton wrote: If we had computers that knew
everything there was to know about things using data they gathered without any help from us
-- we would be able to track and count everything, and greatly reduce waste, loss and cost.
We would know when things needed replacing, repairing or recalling, and whether they were
fresh or past their best. We need to empower computers with their own means of gathering
information, so they can see, hear and smell the world for themselves, in all its random glory.
RFID and sensor technology enable computers to observe, identify and understand the world
without the limitations of human-entered data. At the time, this vision required major
technology improvements. After all, how would we connect everything on the planet. What
type of wireless communications could be built into devices. What changes would need to be
made to the existing Internet infrastructure to support billions of new devices communicating.
What would power these devices. What must be developed to make the solutions cost
effective. There were more questions than answers to the IoT concepts in 1999.

Today, many of these obstacles have been solved. The size and cost of wireless radios
has dropped tremendously. IPv6 allows us to assign a communications address to billions of
devices. Electronics companies are building Wi-Fi and cellular wireless connectivity into a
wide range of devices. ABI Research estimates over five billion wireless chips will ship in
2013.2 Mobile data coverage has improved significantly with many networks offering broad

37
BI-DIRECTIONAL VISITOR COUNTER USING IOT

band speeds. While not perfect, battery technology has improved and solar recharging has
been built into numerous devices. There will be billions of objects connecting to the network
with the next several years. For example, Cisco’s Internet of Things Group (IOTG) predicts
there will be over 50 billion connected devices by describes a system where items in the
physical world, and sensors within or attached to these items, are connected to the Internet
via wireless and wired Internet connections. These sensors can use various types of local area
connections such as RFID, NFC, Wi-Fi, Bluetooth, and Zigbee. Sensors can also have wide
area connectivity such as GSM, GPRS, 3G, and LTE. The Internet of Things will:

1. Connect both inanimate and living things


Early trials and deployments of Internet of Things networks began with connecting
industrial equipment. Today, the vision of IoT has expanded to connect everything from
industrial equipment to everyday objects. The types of items range from gas turbines to
automobiles to utility meters. It can also include living organisms such as plants, farm
animals and people. For example, the Cow Tracking Project in Essex uses data collected from
radio positioning tags to monitor cows for illness and track behavior in the herd. Wearable
computing and digital health devices, such as Nike+ Fuel band and Fit bit, are examples of
how people are connecting in the Internet of Things landscape. Cisco has expanded the
definition of IoT to the Internet of Everything (IoE), which includes people, places, objects
and things. Basically anything you can attach a sensor and connectivity to can participate in
the new connected ecosystems.

2. Use sensors for data collection


The physical objects that are being connected will possess one or more sensors. Each
sensor will monitor a specific condition such as location, vibration, motion and temperature.
In IoT, these sensors will connect to each other and to systems that can understand or present
information from the sensor’s data feeds. These sensors will provide new information to a
company’s systems and to people.

3. Change what types of item communicate over an IP Network


In the past, people communicated with people and with machines. Imagine if all of
your equipment had the ability to communicate. What would it tell you? IoT-enabled objects
will share information about their condition and the surrounding environment with people,
software systems and other machines. This information can be shared in real time or collected

38
BI-DIRECTIONAL VISITOR COUNTER USING IOT

and sharedat defined intervals. Going forward, everything will have a digital identity and
connectivity, which means you can identify, track and communicate with objects.

IoT data differs from traditional computing. The data can be small in size and
frequent in transmission. The number of devices, or nodes, that are connecting to the network
are also greater in IoT than in traditional PC computing. Machine-to-Machine
communications and intelligence drawn from the devices and the network will allow
businesses to automate certain basic tasks without depending on central or cloud based
applications and services. These attributes present opportunities to collect a wide range of
data but also provide challenges in terms of designing the appropriate data networking and
security.

4.3 The three factors of IOT

The factors of IoT (Internet of Things) are as follows,

1. Communication
IoT communicates information to people and systems, such as state and health of
equipment (e.g. it's on or off, charged, full or empty) and data from sensors that can monitor a
person’s vital signs. In most cases, we didn’t have access to this information before or it was
collected manually and infrequently. For example, an IOT-enabled HVAC system can report
if its air filter is clean and functioning properly. Almost every company has a class of assets it
could track. GPS-enabled assets can communicate their current location and movement.
Location is important for items that move, such as trucks, but it’s also applicable for locating
items and people within an organization. In the healthcare industry, IoT can help a hospital
track the location of everything from wheelchairs to cardiac defibrillators to surgeons. In
thetransportation industry, a business can deliver real-time tracking and condition of parcels
and pallets. For example, Maersk can use sensors to track the location of a refrigerated
shipping container and its current temperature.

2. Control and Automation


In a connected world, a business will have visibility into a device’s condition. In
many cases, a business or consumer will also be able to remotely control a device. For
example, a business can remotely turn on or shut down a specific piece of equipment or
adjust the temperature in a climate-controlled environment. Meanwhile, a consumer can use
IoT to unlock their car or start the washing machine. Once a performance baseline has been

39
BI-DIRECTIONAL VISITOR COUNTER USING IOT

established, a process can send alerts for anomalies and possibly deliver an automated
response. For example, if the brake pads on a truck are about to fail, it can prompt the
company to take the vehicle out of service and automatically schedule maintenance.

3. Cost Savings
Many companies will adopt IoT to save money. Measurement provides actual
performance data and equipment health, instead of just estimates. Businesses, particularly
industrial companies, lose money when equipment fails. With new sensor information, IoT
can help a company save money by minimizing equipment failure and allowing the business
to perform planned maintenance. Sensors can also measuring items, such as driving behavior
and speed, to reduce fuel expense and wear and tear on consumables. New smart meters in
homes and businesses can also provide data that helps people understand energy consumption
and opportunities for cost savings.

4.4 Benefits of IoT

Since IoT allows devices to be controlled remotely across the internet, thus it created
opportunities to directly connect & integrate the physical world to the computer-based
systems using sensors and internet. The interconnection of these multiple embedded devices
will be resulting in automation in nearly all fields and also enabling advanced applications.
This is resulting in improved accuracy, efficiency and economic benefit with reduced human
intervention. It encompasses technologies such as smart grids, smart homes, intelligent
transportation and smart cities.

The major benefits of IoT are:

1. Improved Customer Engagement


IoT improves customer experience by automating the action. For e.g. any issue in the
car will be automatically detected by the sensors. The driver, as well as the manufacturer, will
be notified about it. Till the time driver reaches the service station, the manufacturer will
make sure that the faulty part is available at the service station.

2. Technical Optimization
IoT has helped a lot in improving technologies and making them better. The
manufacturer can collect data from different car sensors and analyze them to improve their
design and make them much more efficient.

40
BI-DIRECTIONAL VISITOR COUNTER USING IOT

3. Reduced Waste 
Our current insights are superficial, but IoT provides real-time information leading to
effective decision making & management of resources. For example, if a manufacturer finds
fault in multiple engines, he can track the manufacturing plant of those engines and can
rectify the issue with manufacturing belt. Nowadays, we are surrounded by lots of IoT
enabled devices which are continuously emitting data and communicating through multiple
devices. Moving ahead, let’s discuss the required hardware for building an IoT application.
We will also look at the IoT devices which we are using in our day to day life.

4.5 IoT Hardware

Now you would be wondering what is the required hardware for preparing an IoT
solution. The answer to this question is, you’ll first require sensors that will sense the
environment, then you require a remote dashboard to monitor your output and display it in a
clearer & conceivable form. At last, you will require a device with the capability of serving &
routing. The key task of the system would be detecting specific conditions and taking actions
accordingly. One thing to keep in mind is securing the communication between the devices
and the dashboard.
Some of the common sensors that you are surrounded by are accelerometers,
temperature sensors, magnetometers, proximity sensors, gyroscopes, image sensors, acoustic
sensors, light sensors, pressure sensors, gas RFID sensors, humidity sensors & micro flow
sensors. Nowadays we also have many wearable devices like smart watches, shoes & 3D
glasses. This is the best example of a smart solution. 3D glasses adjust television’s brightness
and contrast according to your eye and your smart watches keeps track of your daily activities
and fitness. 
Mobile apps have immensely contributed to revolutionizing the technology world.
Cell phones are already encased with applications and sensors that reveals lots of information
about its user. It has Geo-location information, it can sense and trace light condition, the
orientation of your device and a lot more information. It also comes with multiple
connectivity options like Wi-Fi, Bluetooth and cellular that helps them to communicate with
other devices. Thus, due to these default qualities of cell phones, it is the core of the IoT
ecosystem. Today, Smartphone can interact with smart watch and fitness band to further ease
and enhance the user experience. IoT uses multiple technologies and protocols to

41
BI-DIRECTIONAL VISITOR COUNTER USING IOT

communicate with devices based on the requirements. The major technologies & protocols
are Bluetooth, wireless, NFC, RFID, radio protocols and WiFi-Direct.
IoT applications are flourishing across all industries & market. The IoT has a
multitude of expansion over various industries. IoT applications are flourishing across all
industries & market. The IoT has a multitude of expansion over various industries. It spans
over all groups of users, from those who are trying to reduce & conserve energy in their home
to large organizations who want to improve their business operations. IoT has not only
proved itself useful in optimizing critical applications in many organizations, but also have
boosted the concept of advanced automation which we have imagined a decade before. Let’s
understand the capabilities of IoT across different industries and look how they are
revolutionizing them.

4.6 IoT Across Various Domains


The applications of IoT across various domains are as follows,
1. Energy Applications 
The energy rates have raised to a great instinct. Individuals and organizations, both
are searching ways to reduce and control the consumption. IoT provides a way to not only
monitor the energy usage at the appliance-level but also at the house-level, grid level or could
be at the distribution level. Smart Meters & Smart Grid are used to monitor energy
consumption. It also detects threats to the system performance and stability, which protect
appliances from downtime and damages.
2. Healthcare Application
Smart watches and fitness devices have changed the frequency of health monitoring.
People can monitor their own health at regular intervals. Not only this, now if a patient is
coming to the hospital by ambulance, by the time he or she reaches the hospital his health
report is diagnosed by doctors and the hospital quickly starts the treatment. The data gathered
from multiple healthcare applications are now collected and used to analyze different disease
and find its cure.
3. Education
IoT provides education aids which helps in fulfilling the gaps in the education
industry. It not only improves the quality of education but also optimizes the cost and
improves the management by taking into consideration students response and performance.

42
BI-DIRECTIONAL VISITOR COUNTER USING IOT

4. Government
Governments are trying to build smart cities using IoT solutions. IoT enhances armed
force systems and services. It provides better security across the borders through inexpensive
& high-performance devices. IoT helps government agencies to monitor data in real-time and
improve their services like healthcare, transportation, education etc.
5. Air and Water Pollution 
Through various sensors, we can detect the pollution in the air and water by frequent
sampling. This helps in preventing substantial contamination and related disasters. IoT allows
operations to minimize the human intervention in farming analysis and monitoring. Systems
automatically detect changes in crops, soil, environment, and more.
6. Transportation
IoT has changed the transportation sector. Now, we have self-driving cars with
sensors, traffic lights that can sense the traffic and switch automatically, parking assistance,
giving us the location of free parking space etc. Also, various sensors in your vehicle indicate
you about the current status of your vehicle, so that you don’t face any issues while
travelling.  

43
BI-DIRECTIONAL VISITOR COUNTER USING IOT

CHAPTER-5
PROJECT WEBSITE

We developed a website for the purpose of displaying the count of students present
inside a classroom. The following is the homepage of our project website shown in Fig.5.1.

Fig.5.1 Homepage

The homepage represents our college name and the department supporting this project. The
three lines at the top right represents a navigation bar. It helps us navigate through the
webpages consists in this website. Once we click/tap on navigation bar icon, it will show like
this in Fig.5.2

Fig.5.2 Navigation bar links

44
BI-DIRECTIONAL VISITOR COUNTER USING IOT

There are total 6 webpages present in this website, each website’s icon in the navigation bar
represents its own respective webpage. In this project, we are monitoring the students count
inside two classrooms namely, IV ECE-C and IV ECE-D.

5.1 Visitor count


The main objective of this webpage is to monitor the total count of the students in multiple
classrooms at different times at online from any part of the world using ThingSpeak platform.
The students data will be uploaded automatically to ThingSpeak cloud at a specified interval
of time using the ESP8266 Wi-Fi module.

5.1.1 IV ECE-C Visitor count


In this webpage, we can see clearly the student’s count of IV ECE-C as shown in Fig.5.3
and graph in Fig.5.4.

Fig.5.3 IV ECE-C Visitor count webpage

45
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.5.4 IV ECE-C Visitor count graph

5.1.2 IV ECE-D Visitor count

In this webpage, we can see clearly the student’s count and its graph of IV ECE-D in Fig.5.5
and Fig.5.6.

Fig.5.5 IV ECE-D Visitor count webpage

46
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.5.6 IV ECE-D Visitor count graph

47
BI-DIRECTIONAL VISITOR COUNTER USING IOT

5.2 Attendance
We are also including the attendance system for these two classrooms. It is mandatory for the
college management to take attendance for each and every period throughout the academic
timetable. By implementing this proposed attendance system, even though it is manual we
can replace the attendance paper sheet with the website thus, saving the paper.

5.2.1 Attendance system implementation

We can take an attendance by using either a smart phone or laptop. The procedure of each
type is explained below.

5.2.1.1 Using Smart phone

Step 1 - open the website in the google chrome mobile browser using the following
link https://batch5-project-website.netlify.app/
Step 2 – open the attendance page of your preferred classroom through the
navigation bar as show in Fig.5.7

Fig.5.7 Attendance page

48
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Step 3 – choose a subject and click on show/hide the listbutton, students list
will appear as shown in below Fig.5.8.

Fig.5.8 Choosing a subject


Step 4 – Tap/click on roll numbers to mark students as absent as shown below
in Fig.5.9, and finally absentees list will be displayed as shown in Fig.5.10.

Fig 5.9 Displaying students list

49
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.5.10 Displaying absentees

Step 5 – click on the download option as shown in Fig.5.11

Download

Fig.5.11 Displaying the download option

50
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Step 6 – once the webpage is downloaded as shown in below Fig.5.12. we can


open it whenever we want to see the attendance of the students.

Fig.5.12 Displaying the downloaded file

If we want to share the attendance file to someone, they need to install this app as shown in
Fig.5.13 from the play store in order to able to view the attendance.

Fig.5.13 MHTML Viewer in playstore

51
BI-DIRECTIONAL VISITOR COUNTER USING IOT

5.2.1.2 Using a laptop/desktop


Step 1 – open the website in the google chrome mobile browser using the
following link https://batch5-project-website.netlify.app/
Step 2 – open the attendance page of your preferred classroom through
the navigation bar
Step 3 – choose a subject and click on show/hide the list button, students
list will appear.
Step 4 – Tap/click on roll numbers to mark students as absent, after that
open the settings
Step 5 – After finishing taking attendance, click on show/hide the list
button and then press CTRL + p to save the file as shown in Fig.5.14. The
resultant attendance page will be saved in the pdf format.

Fig.5.14 Displaying how to save the file


Step 6 – choose the file location to be saved and name the file as you
want, shown in below Fig.5.15

Fig.5.15 Choose the file location and name

52
BI-DIRECTIONAL VISITOR COUNTER USING IOT

This is how the downloaded attendance file will appear after opening it as shown Fig.5.16.

Fig.5.16 Displaying the downloaded file

5.3 Netlify

Netlify is a web developer platform that multiplies productivity. By unifying the


elements of the modern decoupled web, from local development to advanced edge logic,
Netlify enables a 10x faster path to much more performant, secure, and scalable websites and
apps. It is a global platform with powerful features for managing code and assets. The home
page of Netlify is as shown in below Fig.5.17

53
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.5.17 Netlify homepage

5.4 Deploying project website using netlify

Netlify is a cloud computing company that offers hosting and server


less backend services for web applications and static websites. Netlify is an all-in-one
platform for automating modern web projects. Netlify supports atomic deployment of your
sites and apps, allowing you to push sets of changes to frontend code and backend functions
together, as a unit, without even requiring a maintenance window. On Netlify, every global
deploy is an atomic unit representing a state in time of your application. Worldwide caches
are updated instantly, supporting richer applications than possible on a CDN. Deploy
thousands of times daily without any risk of partial deploys or stale assets. Global edge nodes
all have built-in intelligence to natively serve A/B tests, phased rollouts, or geographic
variations. Advance DNS management and network rules support user authentication, per-
page routing, and even proxying to multiple legacy applications—all on the same domain. So,
we deployed our project website in netlify platform by creating a account for free is as shown
in below Fig.5.18

54
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.5.18 Displaying deployed project website

5.5 Advantages and Disadvantages Bi-directional visitor counter

Advantages of Bi-directional visitor counter

1. Can work 24 x 7 without any problem.


2. Low cost & very easy to implement.
3. In schools/colleges it will help to check if somebody is there in the zone or not. If the
data on display unit is zero the security guards can shut the door easily.
4. Whole system will work automatically so it reduces the human work.

Disadvantages of Bi-directional visitor counter

1. IR Sensor cannot detect accurately if lots of people are entering at one time.
2. It is a low range circuit cannot be implemented at large areas.

55
BI-DIRECTIONAL VISITOR COUNTER USING IOT

5.6 Applications of Bi-directional visitor counter


1. It can be used at schools and colleges.
2. It can be used at official meetings.
3. Cinema theatres
4. Shopping malls
5. Museums
6. This circuit can be used domestically to get an indication of number of persons
entering a party.
7. It can be used at homes and other places to keep a check on the number of persons
entering a secured place.

56
BI-DIRECTIONAL VISITOR COUNTER USING IOT

CHAPTER-6
RESULT
Bi-directional visitor counter has been designed and implemented. Now, we can keep
track of number of people present inside a room by using this system. Arduino is the main
controller and the two IR Sensors are used for detecting the incoming and outgoing persons.
The system is ready to display the count after giving proper power supply to the components
is as shown in the Fig.6.1.

Fig.6.1 Hardware kit

The system results is not only displayed in the LCD display but also in the cloud
platform. The visitors data will be uploaded automatically to ThingSpeak cloud at a specified
interval of time using the ESP8266 Wi-Fi module and displayed in a linear graph form is as
shown in the Fig.6.2 and Fig.6.3 of students. The X-axis represents the Date and Y-axis
represents the particular class room means we can know the count of the students clearly. By
clicking on the particular point of graph, we will get the clear count with date and time of the
students at different time intervals.

57
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Fig.6.2 Visitor count graph


In the Fig.6.2, graph is showing that at 10:29 am, Thursday, June 24th there are currently 5
members present inside the classroom

Fig.6.3 Visitor count graph at different time interval

The Fig.6.3 Visitor count graph at different time interval shows the count of number
of students in the classroom at 10:45 am. We can observe from the graphs that previously
stayed 5 students left the classroom in between the class hours. As we take attendance for
period to period, we can now know the roll numbers of the students who left the classroom.

CONCLUSION
In today’s world, there is continuous need automatic appliance will be increase in
standard of living, there is a sense of urgency for developing circuit that would ease the

58
BI-DIRECTIONAL VISITOR COUNTER USING IOT

complexity of life. Also, if someone wants to know the number of persons present in a room
so as not to have congestion, the circuit proves to be helpful. This project is designed and
presented in order to count visitors of an auditorium, seminar hall, class room, malls, sports
venue etc. The system counts both entering and exiting visitor of the class room or other
places, where it is placed. Depending upon the interrupt from the sensors, the system
identifies the entry and exit of the visitors. Finally, visitor count results will be displayed in
LCD (16x2) display and also in ThingSpeak server by using Wi-Fi module and we created a
website to monitor the count and attendance of particular classroom. This Project is useful in
developing countries and this project has a bright future.

FUTURE SCOPE

59
BI-DIRECTIONAL VISITOR COUNTER USING IOT

There is a great scope for the modifications of the Bi-directional visitor counter. The
system can be improved by adding new functionalities. By modifying this circuit and using
two relays we can achieve a task of opening and closing the door and also using this circuit
and proper power supply we can used for automatic room control for various applications
such as fans, tube lights, etc. and also we can check the ambient light intensity and then
decide if the light needs to be turned ON or not. In bidirectional visitor counter the voice
alarm may be added to indelicate room is full and person can’t enter in the room. We can
increase the maximum number of people that can be counted by implementing the external
EEPROM IC and metal detector can be added for security reasons.

60
BI-DIRECTIONAL VISITOR COUNTER USING IOT

BIBLIOGRAPHY

1. https://batch5-project-website.netlify.app/ - project website


2. https://thingspeak.com/ - ThingSpeak homepage
3. https://www.netlify.com/ - netlify homepage
4. https://store.arduino.cc/digital/create - arduino cloud
5. https://github.com
6. https://books.google.com
7. https://wikipedia.org
8. https://www.academia.edu/6806338/Simulation_of_Energy_Efficient_Bi-
directional_Visitor_Counting_Machine_on_FPGA
9. https://www.scribd.com/document/446602181/research-paper-on-bidirectional-
visitor-counter
10. https://www.dnatechindia.com/Bidirectional-Visitor-Counter.html
11. https://www.researchtrend.net/ijet//44-S-837
12. http://www.ijsrp.org/research-paper-0716.php?rp=P555611
13. https://www.irjet.net/archives/V8/i4/PIT/ICIETET-100
14. https://www.researchgate.net/publication/
317312336_Smart_Class_Monitoring_System
15. http://www.ijsred.com/volume4/issue2/IJSRED-V4I2P28-counter

61
BI-DIRECTIONAL VISITOR COUNTER USING IOT

APPENDIX
Website code
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link_href='http://fonts.googleapis.com/css?family=Lora:400,700|Open+Sans:400,300,700'
rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/reset.css"><!-- CSS reset -->
<link rel="stylesheet" href="css/style.css"><!-- Resource style -->
<title>Batch 5</title>
</head>
<body>
<a href="#cd-nav" class="cd-nav-trigger">
Menu<span><!-- used to create the menu icon --></span>
</a>
<main>
<section class="cd-section index cd-selected">
<header style="background-color: orangered;">
<div class="cd-title">
<h2>Aditya College of Engineering and Technology</h2>
<h2>Electronics and Communication Engineering Department - 2</h2>
</div>
</header>
</section>
</main>
<nav class="cd-nav-container" id="cd-nav">
<header>

62
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<a href="#0" class="cd-close-nav">Close</a>


</header>
<ul class="cd-nav">
<li data-menu="services">
<a href="services.html">
<em>
IV ECE-C <br>
VISITOR COUNT
</em>
</a>
</li>
<li data-menu="contact">
<a href="secC.html">
<em>IV ECE-C Attendance</em>
</a>
</li>
<li class="cd-selected" data-menu="index">
<a href="index.html">
<em>Home</em>
</a>
</li>
<li data-menu="careers">
<a href="careers.html">
<em>
IV ECE-D <br>
VISITOR COUNT
</em>
</a>
</li>

63
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<li data-menu="about">
<a href="secD.html">
<em>IV ECE-D Attendance</em>
</a>
</li>
<li data-menu="projects">
<a href="">
<em>About project</em>
</a>
</li>
</ul>
</nav>
</body>
</html>

ECE C.html
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="http://fonts.googleapis.com/css?family=Lora:400,700|Open+Sans:400,300,700"
rel="stylesheet"
type="text/css"/>
<title>IV ECE-C</title>
</head>
<body>
<a href="#cd-nav" class="cd-nav-trigger">
Menu<span><!-- used to create the menu icon --></span>

64
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</a>
<main>
<section>
<header style="background-color: orangered">
<div class="cd-title">
<h2>IV ECE-C</h2>
<h4>Total number of students: 66</h4>
</div>
</header>
<div class="cd-content">
<center>
<iframe
width="450"
height="260"
style="border: 1px solid #cccccc"
src="https://thingspeak.com/channels/1022033/charts/5?bgcolor=%23ffffff&color=
%23d62020&dynamic=true&results=60&type=line&update=15"
></iframe>
</center>
</div>
</section>
</main>
<script src="js/jquery-2.1.1.js"></script>
<script src="js/main.js"></script>
<!-- Resource jQuery -->
</body>
</html>

65
BI-DIRECTIONAL VISITOR COUNTER USING IOT

ECE D.html
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="http://fonts.googleapis.com/css?family=Lora:400,700|Open+Sans:400,300,700"
rel="stylesheet"
type="text/css"/>
<link rel="stylesheet" href="css/reset.css" />
<!-- CSS reset -->
<link rel="stylesheet" href="css/style.css" />
<!-- Resource style -->
<title>IV ECE-D</title>
</head>
<body>
<a href="#cd-nav" class="cd-nav-trigger">
Menu<span><!-- used to create the menu icon --></span>
</a>
<main>
<section class="cd-section careers cd-selected">
<header style="background-color: orangered">
<div class="cd-title">
<h2>IV ECE-D</h2>
<h4>Total number of students: 73</h4>
</div>
</header>
<div class="cd-content">

66
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<center>
<iframe
width="450"
height="260"
style="border: 1px solid #cccccc"
src="https://thingspeak.com/channels/1022033/charts/6?bgcolor=%23ffffff&color=
%23d62020&dynamic=true&results=60&type=line&update=15"
></iframe>
</center>
</div>
</section>
</main>
<script src="js/jquery-2.1.1.js"></script>
<script src="js/main.js"></script>
<!-- Resource jQuery -->
</body>
</html>

Sec C.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Attendance</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://mxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

67
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<style>
tr {
background-color: rgb(21, 235, 21);
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<center><h2>IV ECE-C Attendance</h2></center>
<h3>Choose subject:</h3>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="CMC">
CMC
</button>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="EMI">
EMI
</button>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="SC">
SC
</button>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="WSN">
WSN
</button>
<p>click/tap on roll number to mark as absent</p>
<div class="table-responsive mt-5">
<table id="tab" class="collapse table">
<thead>
<tr style="background-color: cyan">

68
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<th scope="col">S.no</th>
<th scope="col">Roll number</th>
<th scope="col">Name</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td id="1">17P31A04C1</td>
<td>ADABALA SATYA SUDHEERA</td>
</tr>
<tr>
<th scope="row">2</th>
<td id="2">17P31A04C2</td>
<td>AKELLA MANASA</td>
</tr>
<tr>
<th scope="row">3</th>
<td id="3">17P31A04C3</td>
<td>ALLAPARTHI SHARON PUSHPA VALLI</td>
</tr>
<tr>
<th scope="row">4</th>
<td id="4">17P31A04C4</td>
<td>ANGARA VINAYSURYA</td>
</tr>
<tr>
<th scope="row">5</th>
<td id="5">17P31A04C5</td>

69
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td>BANDARU MOHAN KISHORE</td>


</tr>
<tr>
<th scope="row">6</th>
<td id="6">17P31A04C6</td>
<td>BANDI DURGA NOOKAMBICA</td>
</tr>
<tr>
<th scope="row">7</th>
<td id="7">17P31A04C7</td>
<td>BANDI VARA NAGA SAI CHAKRA SRIDEVI</td>
</tr>
<tr>
<th scope="row">8</th>
<td id="8">17P31A04C8</td>
<td>BEZAWADA YOGESH KUMAR</td>
</tr>
<tr>
<th scope="row">9</th>
<td id="9">17P31A04C9</td>
<td>BODDU VENKATA DHARANI</td>
</tr>
<tr>
<th scope="row">10</th>
<td id="10">17P31A04D0</td>
<td>CHITIKENA SAIDARSAN</td>
</tr>
<tr>
<th scope="row">11</th>

70
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td id="11">17P31A04D1</td>
<td>DANGETI CHARISHMA BHAVANI</td>
</tr>
<tr>
<th scope="row">12</th>
<td id="12">17P31A04D2</td>
<td>DESALANKA SITARAMASWAMY</td>
</tr>
<tr>
<th scope="row">13</th>
<td id="13">17P31A04D4</td>
<td>GAJJAVARAPU PRANITHA</td>
</tr>
<tr>
<th scope="row">14</th>
<td id="14">17P31A04D5</td>
<td>GOLLAVILLI AVINASH NAIDU</td>
</tr>
<tr>
<th scope="row">15</th>
<td id="15">17P31A04D6</td>
<td>GUNDU SASI PREETHAM</td>
</tr>
<tr>
<th scope="row">16</th>
<td id="16">17P31A04D7</td>
<td>INUGANTI UHA SESHA ANDALU</td>
</tr>
<tr>

71
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<th scope="row">17</th>
<td id="17">17P31A04D8</td>
<td>KADIYALA NAGADEVI</td>
</tr>
<tr>
<th scope="row">18</th>
<td id="18">17P31A04D9</td>
<td>KAKI NAGA VENKATA APPALA LAKSHMI PRATYUSHA</td>
</tr>
<tr>
<th scope="row">19</th>
<td id="19">17P31A04E0</td>
<td>KANDULA LOKESH REDDY</td>
</tr>
<tr>
<th scope="row">20</th>
<td id="20">17P31A04E1</td>
<td>KANTIPUDI YAMUNA SRI</td>
</tr>
<tr>
<th scope="row">21</th>
<td id="21">17P31A04E2</td>
<td>KARRI KRISHNA PAVANI</td>
</tr>
<tr>
<th scope="row">22</th>
<td id="22">17P31A04E3</td>
<td>KATHA KEERTHI</td>
</tr>

72
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<tr>
<th scope="row">23</th>
<td id="23">17P31A04E4</td>
<td>KEERTHI PRATHYUSHA</td>
</tr>
<tr>
<th scope="row">24</th>
<td id="24">17P31A04E5</td>
<td>KOMMOJU LAVANYA</td>
</tr>
<tr>
<th scope="row">25</th>
<td id="25">17P31A04E6</td>
<td>KONA ASHOK KUMAR</td>
</tr>
<tr>
<th scope="row">26</th>
<td id="26">17P31A04E7</td>
<td>KORASIKA OM SAI</td>
</tr>
<tr>
<th scope="row">27</th>
<td id="27">17P31A04E8</td>
<td>KOVVURI SAHITHI</td>
</tr>
<tr>
<th scope="row">28</th>
<td id="28">17P31A04E9</td>
<td>LAKKOJU SRI CHAITANYA</td>

73
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</tr>
<tr>
<th scope="row">29</th>
<td id="29">17P31A04F0</td>
<td>LAKSHMI SUNANDA CHANNA</td>
</tr>
<tr>
<th scope="row">30</th>
<td id="30">17P31A04F1</td>
<td>MADDIPATI GREESHMA DEVI</td>
</tr>
<tr>
<th scope="row">31</th>
<td id="31">17P31A04F2</td>
<td>MALLIDI LAKSHMANREDDY</td>
</tr>
<tr>
<th scope="row">32</th>
<td id="32">17P31A04F3</td>
<td>MAMIDIPAKA V V N L DURGAMANI</td>
</tr>
<tr>
<th scope="row">33</th>
<td id="33">17P31A04F4</td>
<td>MEKA VARSHA SAI MANI DEEPIKA</td>
</tr>
<tr>
<th scope="row">34</th>
<td id="34">17P31A04F5</td>

74
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td>MUTYALA SIVA SANTHOSHI</td>


</tr>
<tr>
<th scope="row">35</th>
<td id="35">17P31A04F6</td>
<td>NEELAPALA JAGADEESH</td>
</tr>
<tr>
<th scope="row">36</th>
<td id="36">17P31A04F7</td>
<td>PASUPULETI RAMYA SATYA</td>
</tr>
<tr>
<th scope="row">37</th>
<td id="37">17P31A04F8</td>
<td>PEMMANABOIDI VENKATA SAI KIRAN</td>
</tr>
<tr>
<th scope="row">38</th>
<td id="38">17P31A04F9</td>
<td>PENDYALA JYOTHI SWAROOP KUMAR</td>
</tr>
<tr>
<th scope="row">39</th>
<td id="39">17P31A04G0</td>
<td>RAYALA SAI CHANDANA</td>
</tr>
<tr>
<th scope="row">40</th>

75
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td id="40">17P31A04G1</td>
<td>SAILA PRAGNYA</td>
</tr>
<tr>
<th scope="row">41</th>
<td id="41">17P31A04G2</td>
<td>SAMAYAMANTHULA CHAITANYA VENKATA SAI</td>
</tr>
<tr>
<th scope="row">42</th>
<td id="42">17P31A04G3</td>
<td>SATYAMSETTI NAGA SUNNY</td>
</tr>
<tr>
<th scope="row">43</th>
<td id="43">17P31A04G4</td>
<td>SATYAVARAPU VIVEK</td>
</tr>
<tr>
<th scope="row">44</th>
<td id="44">17P31A04G5</td>
<td>SEELA SAI ANIL KUMAR</td>
</tr>
<tr>
<th scope="row">45</th>
<td id="45">17P31A04G6</td>
<td>SHAIK HAJARA MUNVARA SIDDIQA</td>
</tr>
<tr>

76
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<th scope="row">46</th>
<td id="46">17P31A04G7</td>
<td>SHAIK ROSHINI</td>
</tr>
<tr>
<th scope="row">47</th>
<td id="47">17P31A04G8</td>
<td>PILLA PADMA RAMA VENKATA SANTHOSHI LAKSHMI</td>
</tr>
<tr>
<th scope="row">48</th>
<td id="48">17P31A04G9</td>
<td>SURIBHOTLA GUNESWARA TEJA</td>
</tr>
<tr>
<th scope="row">49</th>
<td id="49">17P31A04H0</td>
<td>THATAVARTHY SURYA MYTHREYI</td>
</tr>
<tr>
<th scope="row">50</th>
<td id="50">17P31A04H1</td>
<td>TUMMALAPALLI LAKSHMI PRASANNA</td>
</tr>
<tr>
<th scope="row">51</th>
<td id="51">17P31A04H2</td>
<td>UPPU SIVA SAI TEJA</td>
</tr>

77
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<tr>
<th scope="row">52</th>
<td id="52">17P31A04H3</td>
<td>VALLEPALLI MURALI</td>
</tr>
<tr>
<th scope="row">53</th>
<td id="53">17P31A04H4</td>
<td>VASAMSETTI SHARON ROJA</td>
</tr>
<tr>
<th scope="row">54</th>
<td id="54">17P31A04H5</td>
<td>VEERA GANESH NARLA</td>
</tr>
<tr>
<th scope="row">55</th>
<td id="55">17P31A04H6</td>
<td>VIJURAATHU JAGADESHWARA RAO</td>
</tr>
<tr>
<th scope="row">56</th>
<td id="56">17P31A04H7</td>
<td>YANAMADALA SAI SRI SATHVIKA</td>
</tr>
<tr>
<th scope="row">57</th>
<td id="57">17P31A04H8</td>
<td>YANDAMURI ACHYUT</td>

78
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</tr>
<tr>
<th scope="row">58</th>
<td id="58">17P31A04H9</td>
<td>YESWANTH REDDY KETHAM</td>
</tr>
<tr>
<th scope="row">59</th>
<td id="59">18P35A0419</td>
<td>KAMIREDDY MANOHAR</td>
</tr>
<tr>
<th scope="row">60</th>
<td id="60">18P35A0420</td>
<td>KARRI SURYA HARIKA</td>
</tr>
<tr>
<th scope="row">61</th>
<td id="61">18P35A0421</td>
<td>DUDI SUMANTHI</td>
</tr>
<tr>
<th scope="row">62</th>
<td id="62">18P35A0422</td>
<td>MALLIPUDI MURALI KRISHNA</td>
</tr>
<tr>
<th scope="row">63</th>
<td id="63">18P35A0423</td>

79
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td>GUNDUMALLA SRIDEVI</td>
</tr>
<tr>
<th scope="row">64</th>
<td id="64">18P35A0424</td>
<td>BALAM PRAVEEN SAI</td>
</tr>
<tr>
<th scope="row">65</th>
<td id="65">18P35A0425</td>
<td>SUNDARAPALLI SRI LAKSHMI DEEPIKA</td>
</tr>
<tr>
<th scope="row">66</th>
<td id="66">18P35A0426</td>
<td>AKSHINTALA SURESHKUMAR</td>
</tr>
</tbody>
</table>
</div>
<button class="btn btn-info" data-toggle="collapse" data-target="#tab">
Show/Hide the list
</button>
<h2 id="clock" style="color: black"></h2>
<h2 id="sub"></h2>
<p>Absentees are:</p>
<div id="para"></div>
<span>Total number of absentees are:</span>
<span id="para2"></span>

80
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</div>
<script>
function subject(event) {
let sub = document.getElementById("sub");
sub.innerText = event.target.id;
}
let head = document.getElementsByTagName("tr");
let p = document.getElementById("para");
let p2 = document.getElementById("para2");
let clock = document.getElementById("clock");
let count = 0;
headings = Array.from(head);
// for time
setInterval(() => {
let time = new Date();
let hr = time.getHours();
let mn = time.getMinutes();
let sc = time.getSeconds();
let day = "AM";
if (hr > 12) {
hr = hr - 12;
day = "PM";
}
if (hr < 10) {
hr = "0" + hr;
}
if (mn < 10) {
mn = "0" + mn;
}

81
BI-DIRECTIONAL VISITOR COUNTER USING IOT

if (sc < 10) {


sc = "0" + sc;
}
clock.innerText = `${hr}:${mn}:${sc} ${day}`;
});
// var id;
headings.forEach((heading) => {
let present = 1;
heading.addEventListener(
"click",
(handleClick = (e) => {
// let num;
if (present === 1) {
e.target.parentNode.style.backgroundColor = "coral";
// p.innerText += e.target.innerText +'\n'
let num = document.createElement("h4");
num.innerText = e.target.innerText;
num.id = "y" + e.target.id;
// id = num.id
p.append(num);
console.log(num.id);
count += 1;
present = 0;
} else {
e.target.parentNode.style.backgroundColor = "rgb(21, 235, 21)";
present = 1;
count -= 1;
console.log("4" + e.target.id);
document.getElementById("y" + e.target.id).remove();

82
BI-DIRECTIONAL VISITOR COUNTER USING IOT

}
p2.innerText = count;
})
);
});
</script>
</body>
</html>

Sec D.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Attendance</title>
<linkrel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://mxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<style>
tr {
background-color: rgb(21, 235, 21);
color: white;
cursor: pointer;
}
</style>
</head>
<body>

83
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<div class="container">
<center><h2>IV ECE-D Attendance</h2></center>
<h3>Choose subject:</h3>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="CMC">
CMC
</button>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="EMI">
EMI
</button>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="SC">
SC
</button>
<buttontype="button"class="btn btn-light"onclick="subject(event)"id="WSN">
WSN
</button>
<p>click/tap on roll number to mark as absent</p>
<div class="table-responsive mt-5">
<table id="tab" class="collapse table">
<thead>
<tr style="background-color: cyan">
<th scope="col">S.no</th>
<th scope="col">Roll number</th>
<th scope="col">Name</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td id="1">16P31A04H6</td>

84
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td>VANAPALLI SAI VEERA VENKATA LAKSHMI HARIKA</td>


</tr>
<tr>
<th scope="row">2</th>
<td id="2">17A61A0401</td>
<td>ALLADA SRINIVASU</td>
</tr>
<tr>
<th scope="row">3</th>
<td id="3">17A61A0413</td>
<td>GEDDAMURI YASASSRI</td>
</tr>
<tr>
<th scope="row">4</th>
<td id="4">17A61A0427</td>
<td>MAMILLAPALLI VENKATA NAGA SRIVASUDHA</td>
</tr>
<tr>
<th scope="row">5</th>
<td id="5">17A61A0428</td>
<td>MANTHA KAMESWARI SAITEJASWI</td>
</tr>
<tr>
<th scope="row">6</th>
<td id="6">17A61A0431</td>
<td>NOMULA SANTHOSH PRIYANKA</td>
</tr>
<tr>
<th scope="row">7</th>

85
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td id="7">17A61A0442</td>
<td>REDLA PAVAN KALYAN</td>
</tr>
<tr>
<th scope="row">8</th>
<td id="8">17A61A0443</td>
<td>SANDIPARTHI BALA CHANDRAMOULI</td>
</tr>
<tr>
<th scope="row">9</th>
<td id="9">17A61A0445</td>
<td>SENAPATHI SURENDRA</td>
</tr>
<tr>
<th scope="row">10</th>
<td id="10">17P31A04I1</td>
<td>ADAM PRANATHINI</td>
</tr>
<tr>
<th scope="row">11</th>
<td id="11">17P31A04I2</td>
<td>ADAPA PRIYANKA</td>
</tr>
<tr>
<th scope="row">12</th>
<td id="12">17P31A04I3</td>
<td>ADAPA SAI NARASIMHA MURTHY</td>
</tr>
<tr>

86
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<th scope="row">13</th>
<td id="13">17P31A04I4</td>
<td>ADAPAKA ANUSHA DEVI</td>
</tr>
<tr>
<th scope="row">14</th>
<td id="14">17P31A04I5</td>
<td>ANALA VASUKI SAI MANGA TAYARU</td>
</tr>
<tr>
<th scope="row">15</th>
<td id="15">17P31A04I6</td>
<td>BASSA JYOTHI PRIYA</td>
</tr>
<tr>
<th scope="row">16</th>
<td id="16">17P31A04I7</td>
<td>BATHULA VISHNUPRIYA</td>
</tr>
<tr>
<th scope="row">17</th>
<td id="17">17P31A04I8</td>
<td>BILLAKURTHI NAGA SUDHAKAR REDDY</td>
</tr>
<tr>
<th scope="row">18</th>
<td id="18">17P31A04I9</td>
<td>BOLLAM SUBHASH</td>
</tr>

87
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<tr>
<th scope="row">19</th>
<td id="19">17P31A04J1</td>
<td>CHALLA GOWRI TULASI</td>
</tr>
<tr>
<th scope="row">20</th>
<td id="20">17P31A04J2</td>
<td>CHINTA KODANDARAMAAYYAPPA</td>
</tr>
<tr>
<th scope="row">21</th>
<td id="21">17P31A04J3</td>
<td>DALIPARTHI DEEPAK</td>
</tr>
<tr>
<th scope="row">22</th>
<td id="22">17P31A04J4</td>
<td>DESINA RADHA SATYA KRISHNA</td>
</tr>
<tr>
<th scope="row">23</th>
<td id="23">17P31A04J5</td>
<td>DEVARASETTI SIVA SAI</td>
</tr>
<tr>
<th scope="row">24</th>
<td id="24">17P31A04J6</td>
<td>DOMA DEVI PRASANNA</td>

88
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</tr>
<tr>
<th scope="row">25</th>
<td id="25">17P31A04J7</td>
<td>GADI LIKHITA</td>
</tr>
<tr>
<th scope="row">26</th>
<td id="26">17P31A04J8</td>
<td>GATTIMI AMBIKA SURYA LAKSHMI</td>
</tr>
<tr>
<th scope="row">27</th>
<td id="27">17P31A04J9</td>
<td>GEDA SWETHA SRI</td>
</tr>
<tr>
<th scope="row">28</th>
<td id="28">17P31A04K0</td>
<td>GUNDABATHULA GEETANJALI</td>
</tr>
<tr>
<th scope="row">29</th>
<td id="29">17P31A04K1</td>
<td>GURRAM VANDANA</td>
</tr>
<tr>
<th scope="row">30</th>
<td id="30">17P31A04K2</td>

89
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td>KAKARAPALLI HEMANTH</td>
</tr>
<tr>
<th scope="row">31</th>
<td id="31">17P31A04K3</td>
<td>KAKI USHA SRI</td>
</tr>
<tr>
<th scope="row">32</th>
<td id="32">17P31A04K4</td>
<td>KANCHARLA SURYA SREE</td>
</tr>
<tr>
<th scope="row">33</th>
<td id="33">17P31A04K5</td>
<td>KAREM AMRUTHA</td>
</tr>
<tr>
<th scope="row">34</th>
<td id="34">17P31A04K6</td>
<td>KARRI HEMA SAI</td>
</tr>
<tr>
<th scope="row">35</th>
<td id="35">17P31A04K7</td>
<td>KARRI SANTA KUMARI</td>
</tr>
<tr>
<th scope="row">36</th>

90
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td id="36">17P31A04K8</td>
<td>KOMALA VEERA VENKATA RAHUL</td>
</tr>
<tr>
<th scope="row">37</th>
<td id="37">17P31A04K9</td>
<td>KOMMIREDDY UDAY KIRAN</td>
</tr>
<tr>
<th scope="row">38</th>
<td id="38">17P31A04L0</td>
<td>KORLA RAMYA</td>
</tr>
<tr>
<th scope="row">39</th>
<td id="39">17P31A04L2</td>
<td>MADEM VEERA VENKATA SRI SAI SANDEEP</td>
</tr>
<tr>
<th scope="row">40</th>
<td id="40">17P31A04L3</td>
<td>MORAPAKULA UMESH CHANDRA</td>
</tr>
<tr>
<th scope="row">41</th>
<td id="41">17P31A04L4</td>
<td>MOYILLA VILEKHA</td>
</tr>
<tr>

91
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<th scope="row">42</th>
<td id="42">17P31A04L5</td>
<td>MULAKALA VENKATA SAI PRASANNA</td>
</tr>
<tr>
<th scope="row">43</th>
<td id="43">17P31A04L6</td>
<td>MUMMIDI BHARGAV</td>
</tr>
<tr>
<th scope="row">44</th>
<td id="44">17P31A04L7</td>
<td>NALLALA KUMAR VENKATA RAMA KRISHNA</td>
</tr>
<tr>
<th scope="row">45</th>
<td id="45">17P31A04L8</td>
<td>NICHENAKOLLA DURGA PRASAD</td>
</tr>
<tr>
<th scope="row">46</th>
<td id="46">17P31A04L9</td>
<td>NIMMAKAYALA SATISH</td>
</tr>
<tr>
<th scope="row">47</th>
<td id="47">17P31A04M0</td>
<td>PAPOLU JASWANTH</td>
</tr>

92
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<tr>
<th scope="row">48</th>
<td id="48">17P31A04M1</td>
<td>PASUPULETI SAI DEEPTHI</td>
</tr>
<tr>
<th scope="row">49</th>
<td id="49">17P31A04M2</td>
<td>PERURI PRATHYUSHA</td>
</tr>
<tr>
<th scope="row">50</th>
<td id="50">17P31A04M3</td>
<td>PITANI SUREKHA</td>
</tr>
<tr>
<th scope="row">51</th>
<td id="51">17P31A04M5</td>
<td>POTHAMSETTI SRI SATYA RAMYA</td>
</tr>
<tr>
<th scope="row">52</th>
<td id="52">17P31A04M6</td>
<td>RAVI LOKESH</td>
</tr>
<tr>
<th scope="row">53</th>
<td id="53">17P31A04M7</td>
<td>REKADI LAKSHMI SRINIVAS NAICKER</td>

93
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</tr>
<tr>
<th scope="row">54</th>
<td id="54">17P31A04M8</td>
<td>SAMBANGI JAGADEESWARI</td>
</tr>
<tr>
<th scope="row">55</th>
<td id="55">17P31A04M9</td>
<td>SHAIK HABEEB ASHRAF SHARIFF</td>
</tr>
<tr>
<th scope="row">56</th>
<td id="56">17P31A04N0</td>
<td>SISTA VENKATA NAGA VEERABHADRA SAI SUDEEP</td>
</tr>
<tr>
<th scope="row">57</th>
<td id="57">17P31A04N2</td>
<td>TUTHIKA PURNA NIKHIL KUMAR</td>
</tr>
<tr>
<th scope="row">58</th>
<td id="58">17P31A04N3</td>
<td>VELAMARTHI VENUGOPAL KRISHNA</td>
</tr>
<tr>
<th scope="row">59</th>
<td id="59">17P31A04N4</td>

94
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td>VINTHA LAYA</td>
</tr>
<tr>
<th scope="row">60</th>
<td id="60">17P31A04N5</td>
<td>VURA SAI PRIYANKA</td>
</tr>
<tr>
<th scope="row">61</th>
<td id="61">17P31A04N6</td>
<td>VURUKURTHI SRI RAMA VINAY</td>
</tr>
<tr>
<th scope="row">62</th>
<td id="62">17P31A04N7</td>
<td>VUTA RAGHU VEERA PHANI SHANKAR</td>
</tr>
<tr>
<th scope="row">63</th>
<td id="63">17P31A04N8</td>
<td>VUTUKURU VENKATA SATYA SAI DURGA SRIVANI</td>
</tr>
<tr>
<th scope="row">64</th>
<td id="64">17P31A04N9</td>
<td>YERRAMSETTI SAIRAM</td>
</tr>
<tr>
<th scope="row">65</th>

95
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<td id="65">17P31A04O0</td>
<td>RIMMALAPUDI VENKATA VAMSI KRISHNA</td>
</tr>
<tr>
<th scope="row">66</th>
<td id="66">18P35A0427</td>
<td>BEPINA KARUNA KUMARI</td>
</tr>
<tr>
<th scope="row">67</th>
<td id="67">18P35A0428</td>
<td>NETINTI LAKSHMANA</td>
</tr>
<tr>
<th scope="row">68</th>
<td id="68">18P35A0429</td>
<td>ADABALA DORABABU</td>
</tr>
<tr>
<th scope="row">69</th>
<td id="69">18P35A0430</td>
<td>YANALA VEERA VENKATA LAKSHMI</td>
</tr>
<tr>
<th scope="row">70</th>
<td id="70">18P35A0431</td>
<td>SAI KIRANMAYI PASUPULETI</td>
</tr>
<tr>

96
BI-DIRECTIONAL VISITOR COUNTER USING IOT

<th scope="row">71</th>
<td id="71">18P35A0432</td>
<td>DODDA PURNACHANDRA MANIKANTA</td>
</tr>
<tr>
<th scope="row">72</th>
<td id="72">18P35A0433</td>
<td>KARRI SATYANARAYANA</td>
</tr>
<tr>
<th scope="row">73</th>
<td id="73">18P35A0434</td>
<td>PERUMALLA SURESH</td>
</tr>
</tbody>
</table>
</div>
<button class="btn btn-info" data-toggle="collapse" data-target="#tab">
Show/Hide the list
</button>
<h2 id="clock" style="color: black"></h2>
<h2 id="sub"></h2>
<p>Absentees are:</p>
<div id="para"></div>
<span>Total number of absentees are:</span>
<span id="para2"></span>
</div>
<script>
function subject(event) {

97
BI-DIRECTIONAL VISITOR COUNTER USING IOT

let sub = document.getElementById("sub");


sub.innerText = event.target.id;
}
let head = document.getElementsByTagName("tr");
let p = document.getElementById("para");
let p2 = document.getElementById("para2");
let clock = document.getElementById("clock");
let count = 0;
headings = Array.from(head);
// for time
setInterval(() => {
let time = new Date();
let hr = time.getHours();
let mn = time.getMinutes();
let sc = time.getSeconds();
let day = "AM";
if (hr > 12) {
hr = hr - 12;
day = "PM";
}
if (hr < 10) {
hr = "0" + hr;
}
if (mn < 10) {
mn = "0" + mn;
}
if (sc < 10) {
sc = "0" + sc;
}

98
BI-DIRECTIONAL VISITOR COUNTER USING IOT

clock.innerText = `${hr}:${mn}:${sc} ${day}`;


});
// var id;
headings.forEach((heading) => {
let present = 1;
heading.addEventListener(
"click",
(handleClick = (e) => {
// let num;
if (present === 1) {
e.target.parentNode.style.backgroundColor = "coral";
// p.innerText += e.target.innerText +'\n'
let num = document.createElement("h4");
num.innerText = e.target.innerText;
num.id = "y" + e.target.id;
// id = num.id
p.append(num);
console.log(num.id);
count += 1;
present = 0;
} else {
e.target.parentNode.style.backgroundColor = "rgb(21, 235, 21)";
present = 1;
count -= 1;
console.log("4" + e.target.id);
document.getElementById("y" + e.target.id).remove();
}
p2.innerText = count;
})

99
BI-DIRECTIONAL VISITOR COUNTER USING IOT

);
});
</script>
</body>
</html>

About.html
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="http://fonts.googleapis.com/css?family=Lora:400,700|Open+Sans:400,300,700"
rel="stylesheet"type="text/css"/>
<title>About</title>
</head>
<body>
<a href="#cd-nav" class="cd-nav-trigger">
Menu<span><!-- used to create the menu icon --></span>
</a>
<main>
<section>
<header style="background-color: orangered">
<div class="cd-title">
<h2>BI-DIRECTIONAL VISITOR COUNTER USING IOT</h2>
<h2>Final year project</h2>
<h2>by</h2>
<h2>IV ECE-C Batch 5</h2>
<h2>2017-2021</h2>

100
BI-DIRECTIONAL VISITOR COUNTER USING IOT

</div>
</header>
<header style="background-color: orangered">
<div class="cd-title">
<h2>Team members are:</h2>
<h3>B.D.N. Ambica (17P31A04C6)</h3><br />
<h3>K. Nagadevi (17P31A04D8)</h3><br />
<h3>B. Yogesh Kumar (17P31A04C8)</h3><br />
<h3>K. Omsai (17P31A04E7)</h3><br />
<h2>Under the guidance of</h2>
<h3>Mr I. Ramesh Raja, M.E</h3><br />
<h3>Assistant Professor</h3><br />
<h3>Department of ECE-2</h3><br />
</div>
</header>
</section>
</main>
</body>
</html>

101
BI-DIRECTIONAL VISITOR COUNTER USING IOT

Embedded C code
#include <LiquidCrystal.h>
#include <stdio.h>
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
unsigned char gchr='x',gchr1='x';
char rcv,count;
int ir1 = 8;
int ir2 = 9;
int mqv=0, cntl=0,x=0,y=0;;
float phv=0,turbv=0;
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false;// whether the string is complete
void okcheck()
{
unsigned char rcr;
do{
rcr = Serial.read();
}while(rcr != 'K');
}
void things_send()
{
unsigned char recr;
Serial.write("AT+CIPMUX=1\r\n");delay(2000);
Serial.write("AT+CIPSTART=4,\"TCP\",\"184.106.153.149\",80\r\n");
delay(4000); //OK LINKED
Serial.write("AT+CIPSEND=4,77\r\n"); delay(3000);
Serial.write("GET https://api.thingspeak.com/update?api_key=GE42JJ1O6L3A7G9K&");
}
void things_rcv()

102
BI-DIRECTIONAL VISITOR COUNTER USING IOT

{
unsigned char recr;
Serial.write("AT+CIPSTART=4,\"TCP\",\"184.106.153.149\",80\r\n"); delay(4000);
Serial.write("AT+CIPSEND=4,73\r\n"); delay(3000);
Serial.write("GET https://api.thingspeak.com/channels/449069/fields/3.json?results=1");
}
void things_done()
{
Serial.write("\r\n\r\n"); delay(4000);
}
void setup()
{
Serial.begin(9600);//serialEvent();
pinMode(ir1, INPUT);
pinMode(ir2, INPUT);
lcd.begin(16, 2);
lcd.print("Class Room Attendance");
delay(1500);
wifiinit();
lcd.clear();
lcd.setCursor(0, 0); //column,row
lcd.print("Count:");
}
int cntlm=0;
void loop()
{
if(digitalRead(ir1) == LOW)
{delay(500);
while(digitalRead(ir1) == LOW);

103
BI-DIRECTIONAL VISITOR COUNTER USING IOT

cntlm++;
lcd.setCursor(7,0);convertl(cntlm);
if(cntlm % 5 == 0)
{
lcd.setCursor(13,1);lcd.print("1 ");
things_send();
Serial.write("field5=");
converts(cntlm);
things_done();
lcd.setCursor(13,1);lcd.print(" ");
for(cntl=0;cntl<30;cntl++)
{lcd.setCursor(13,1);convertl1(cntl);delay(900);}
lcd.setCursor(13,1);lcd.print(" ");
}
}
if(digitalRead(ir2) == LOW)
{delay(500);
while(digitalRead(ir2) == LOW);
cntlm--;
if(cntlm <= 0)
{
cntlm=0;
}
lcd.setCursor(7,0);convertl(cntlm);
if(cntlm % 5 == 0)
{
lcd.setCursor(13,1);lcd.print("1 ");
things_send();
Serial.write("field5=");

104
BI-DIRECTIONAL VISITOR COUNTER USING IOT

converts(cntlm);
things_done();
lcd.setCursor(13,1);lcd.print(" ");
for(cntl=0;cntl<30;cntl++)
{lcd.setCursor(13,1);convertl1(cntl);delay(900);}
lcd.setCursor(13,1);lcd.print(" ");
}
}
}
/*Read input serial */
int readSerial(char result[])
{
int i = 0;
while (1)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '\n')
{
result[i] = '\0';
Serial.flush();
return 0;
}
if (inChar != '\r')
{
result[i] = inChar;
i++;
}

105
BI-DIRECTIONAL VISITOR COUNTER USING IOT

}
}
}
void wifiinit()
{
Serial.write("AT\r\n"); delay(2000);
Serial.write("ATE0\r\n"); okcheck();delay(2000);
Serial.write("AT+CWMODE=3\r\n"); delay(2000);
lcd.clear();
lcd.print("Connected");
delay(1000);
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
/*
void serialEvent()
{
while (Serial.available())
{
// get the new byte:
char inChar = (char)Serial.read();
if(inChar == '*')
{
gchr = Serial.read();
}

106
BI-DIRECTIONAL VISITOR COUNTER USING IOT

}
}*/
void converts(unsigned int value)
{
unsigned int a,b,c,d,e,f,g,h;
a=value/10000;
b=value%10000;
c=b/1000;
d=b%1000;
e=d/100;
f=d%100;
g=f/10;
h=f%10;
a=a|0x30;
c=c|0x30;
e=e|0x30;
g=g|0x30;
h=h|0x30;
Serial.write(a);
Serial.write(c);
Serial.write(e);
Serial.write(g);
Serial.write(h);
}
void convertl(unsigned int value)
{
unsigned int a,b,c,d,e,f,g,h;
a=value/10000;
b=value%10000;

107
BI-DIRECTIONAL VISITOR COUNTER USING IOT

c=b/1000;
d=b%1000;
e=d/100;
f=d%100;
g=f/10;
h=f%10;
a=a|0x30;
c=c|0x30;
e=e|0x30;
g=g|0x30;
h=h|0x30;
lcd.write(c);
lcd.write(e);
lcd.write(g);
lcd.write(h);
}
void convertl1(unsigned int value)
{
unsigned int a,b,c,d,e,f,g,h;
a=value/10000;
b=value%10000;
c=b/1000;
d=b%1000;
e=d/100;
f=d%100;
g=f/10;
h=f%10;
a=a|0x30;
c=c|0x30;

108
BI-DIRECTIONAL VISITOR COUNTER USING IOT

e=e|0x30;
g=g|0x30;
h=h|0x30;
lcd.write(g);
lcd.write(h);
}

109

You might also like