Smart Parking System From DNR College of Engineering and Technology

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

A Project

On
SMART PARKING SYSTEM
Submitted in partial fulfillment of the requirements for the award of degree of
DIPLOMA
in
ELECTRICAL AND ELECTRONICS ENGINEERING
Submitted by
V. DILIP KUMAR 18354-EE-021 K. SRIKARI RAMYA PRAVALIKA
18354-EE-007 P. ADITYA VIVEK 18354-EE-017 R. LAKSHMI
VENKATRAJU 18354-EE-018 G. LAKSHMI VARA PRASAD
18354-EE-006 Under the esteemed guidance of
Mr.S.RAJESHM.tech
Asst.Professor
Supported by

ANDHRA PRADESH STATE SKILL DEVELOPMENT CORPORATION

DNR COLLEGE OF ENGINEERING AND TECHNOLOGY

(Affiliated to Jawaharlal Nehru Technological University Kakinada)


(Accredited by NAAC with B++ Grade)
Balsumudi, Bhimavaram- 534202, Andhra Pradesh, India.
DEPARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
CERTIFICATE
This is to certify that the project work SMART PARKING SYSTEM is
being submitted for the partial fulfillment of the requirements for university , Kakinada, is
a bonafide work done by the V. DILIP KUMAR (18354-EE-021), K. SRIKARI RAMYA
PRAVALIKA (18354-EE-007), P. ADITYA VIVEK (18354-EE-017), R. LAKSHMI
VENKATRAJU (18354-EE-018), G. LAKSHMI VARA PRASAD (18354-EE-006) ,
under the guidance and it has been found suitable for acceptance according to the
requirements of the university. The results embodied in this thesis have not been
submitted to any other universities/ institutes for the award of any degree.

Head of the Department Mr. S. RajeshM.tech


Asst. Professor

EXTERNAL EXAMINER
INDEX
Abstract 1 UNIT-1 2 - 21 1.1 Introduction
1.2 Need of Smart parking system
1.3 Block Diagram
1.4 Components and materials used in Smart parking system
1.4.1 NodeMCU
1.4.2 IR Sensor
1.4.3 Servo Motor
1.4.4 Male to female jumper wires
1.4.5 Male to male jumper wires
1.4.6 PCB
1.4.7 Female berg strips
1.4.8 Male berg strips
1.4.9 NodeMCU cable
1.5 Softwares used in Smart Parking System
1.5.1 Arduino IDE
1.5.1.1 Steps to install Arduino IDE
1.5.2 Adafruit IO
UNIT-2 22 2. Existing system

UNIT-3 23 - 29 3. Proposing system


3.1 Advantages of Smart parking System
3.2 Application

UNIT-4 30 - 39 4. Program and code


4.1 programming NodeMCU for IOT parking system
4.2 code

UNIT-5 40 - 41 5. Result
5.1 Expecting Outcomes

UNIT-6 42 6. References
ABSTRACT

Lately, the conception of smart cities have acquired huge popularity. Thanks to
the evaluation of the internet of things, the hypothesis of smart cities now seems to be
reachable. Unchanging endeavours are being made in the field of IOT in order to
maximize the efficiency and accuracy of urban infrastructure.Problems such as, traffic
overcrowding, limited car parking facilities and road safety are being addressed by IOT.
The proposed Smart parking system consists of an on-site deployment of an IOT
module that is used to monitor the state of availability of parking space. A mobile
application is also provided that allows an end user to check the availability of parking
slots accordingly. In a few years, the craze towards smart parking increases. This
system has already been employed and implemented in different foriegn developing
countries which made their lives more organized. We can say that vehicle parking is one
of the most time taking processes in our country. So, it would be better to implement this
idea which can save more time and reduce sound pollution. Many corporate companies
have already proposed the concept of smart parking system as included in smart cities
developing project. Our government has recently introduced the planning of modifying
the small towns and urban areas into Smart cities. Most of the work has already started
in order to introduce smart cities to this modern era. The proposal of a smart parking
system has also included in that plan of course it is one of the important systems. As the
traffic system plays a vital role in our daily activities, the development of it is also very
essential. This can also be used to increase the income of the government by providing
some additional features to our proposal. The additional features mentioned here is
parking slot booking facility and implementing charges with respect to the time of
parking. Nowadays most people have some knowledge about the internet and almost
every person has their own smartphone. So, there are many chances that our proposal
will succeed. The most important consideration is online booking and checking anything
online has become the habit for most of the people. So, our proposal that is Smart
Parking System doesn’t cause any problem to the end users. This paper gives brief
knowledge about the advantages, development process and the intention to propose the
project. So, it would clear the doubts regarding the Smart parking system.

1
UNIT-1
INTRODUCTION

1.1 Introduction

“The internet of things(IOT) is a system of interrelated computing devices,


mechanical and digital machines, objects, animals or people that are provided with
unique identifiers and the ability to transfer data over a network without requiring a
human-to-human or human-to-computer interaction. The smart parking system is purely
based on IOT and has included part of embedded systems. It provides information
about parking slot availability which can be checked through our mobile in a selected
area. It helps to prevent huge traffic in parking areas.
Smart cities uses smart information, communication and technologies to improve
operational efficiency for the public, help in accelerating towards improvement of quality
of life for citizens. The Internet of things, Automation, and machine learning are
emerging trends which drive towards smart city adoption. Any city can be considered as
a smart city initiative, by introducing them like, Smart parking system uses a mobile app
to help the drivers to locate parking slots, smart traffic management to track and analyze
the traffic flows, sharing information electronically, monitor the environment etc..
Any smart applications include sensors, which are deployed in the environment,
collects the information from device/sensor are processed and analyzed to manage the
applications. This approach would reduce the cost of manpower and increase the
productivity. The internet of things is a set of physical devices, vehicles, home
appliances, embedded with electronics, software, sensor, actuator and network
connectivity which enable to connect and exchange data. Sensors can be networked
together to sense several physical phenomena such as soil, vegetation, water bodies,
habitat monitoring, object tracking etc.. Smart parking system is a classic example
demonstrates how the Internet of Things will be effectively and efficiently used to make
life easy for a common citizen.
Developing countries like India, face problems for large free parking space
management. Conventional parking management systems use sensors and other
communication module, but does not address solutions for both open and closed
parking spaces. Mobile applications that are used to find a parking slot use GPS
connect through the google map API to find free parking space location, but does not
find free parking space location exactly. The main drawback of parking system detection

2
systems are low accuracy, light and weather conditions. In this work, a methodology to
implement mobile application to find parking space use IR sensors to find vacant slots.
Availability of a free slot is transmitted using NodeMCU to the server and retrieved
through adafruit. The owner of the parking slot can get analytics of the number of free
and available slots for a given period. It provides a comprehensive parking solution both
of user and owner.
Smart parking is a parking solution that can include in ground smart parking
sensors, cameras or counting sensors. These devices are usually embedded into
parking spots or positioned next to them to detect whether parking bays are free or
occupied. This happens through real-time data collection. Searching for a parking spot
has become a daily routine for a lot of people all over the world. It is usually a time
consuming and frustrating process that a lot of citizens have to go through. Next to
parking being such a daily pain, it also has a big impact on the pollution of the planet.
Inorder to overcome this type of problems and to develop the living style we have
introduced a smart parking system in which you can able to check parking slot
availability in your mobile. This can help to save your time. Smart parking and its smart
parking sensors can be seen as a part of smart cities. These smart cities are cities that
are driven by an IT infrastructure and by using this infrastructure, cities can enhance the
quality of life and improve economic developments for its inhabitants. Becoming a smart
city can be a good way to collect historical data in a relatively easy way. By collecting
this data, cities can analyze how processes like parking can be optimized. Recently, we
can see that some of the shopping malls are providing parking slots to individuals but
that is a manual process and does not provide the parking slot availability status in any
kind of internet platforms. So the project proposes some modifications to the present
existing parking system that is nothing but placing sensors at every existing parking slot.
So that by connecting the sensors to the iot platform the end users will be able to see
the parking slot availability status through an app or website. It is a simple but crucial
development which is an essential need to the era having at least one vehicle for each
family.

1.2 The need for Smart Parking System

Fishing for a parking space is a routine activity and it is estimated that nearly 30%
of urban congestion is created by drivers cruising for parking space, according to ITS
America’s market analysis, also resulting in oil wastage, almost one million barrels of
world’s oil everyday. This ever growing traffic congestion and uncertainty in the parking
availability enforced the need for a smart parking system. A Smart parking technology
that will help optimize parking space usage, improve the efficiency of the parking
operations and help smoother traffic flow.

3
1.3 Block Diagram:

The simple block diagram of Smart Parking System is as follows:

Block Diagram of Smart Parking System

In this Smart parking system using IOT, we are using five IR sensors and two
servo motors are connected to node MCU. Node MCU controls the complete Process
and sends the parking availability and parking time information to Adafruit IO so that it
can be monitored from anywhere in the world using this platform. Two IR sensors are
used at entry so that it can detect the cars at entry and exit gate and automatically open
and close the gate.

4
Two Servo motors are used as entry and exit gate, so whenever the IR sensor detects a car,
the servo motor automatically rotates, and after delay it returns to initial position. Another three
IR sensors are used to detect if the parking slot is available or occupied and the data to node
MCU. Adafruit IO dashboard also has two buttons to operate the entry and exit gate.
For this project we created a total nine feeds for exit gate, entry gate, slot1 exit and entry, slot2
exit and entry and slot3 exit and entry. To run the code, we need to install required libraries and
have to set the tool settings. For a successful compilation all needed are syntaxes, libraries and
board using.
To get started with Adafruit, you need to create an account in Adafruit IO and this is absolutely
free. You need to know your API key and username to connect Adafruit server to your project,
for that you have to select IO and you can be able to see your API key and the username. After
including those credentials into your code with correct syntax, you need to create a dashboard
to your project in Adafruit and have to feed your inputs.

5
API key in Adafruit IO

6
1.4 Components and materials used in smart parking system

The following are the components used for smart parking system:
1.4.1 Node MCU:

Node MCU is an open source firmware for which open source prototyping
board designs are available. The name Node MCU combines node and MCU
( MicroController Unit). The term “ NodeMCU” strictly speaking refers to firmware rather
than the associated development kits. Both the firmware and prototyping board designs
are open source. The firmware uses the Lua scripting language. The firmware is based
on eLua project, and built on the Espressif Non-OS SDK for ESP8266. It uses many
open source projects, such as lua-cjson and SPIFFS. Due to resource constraints, users
need to select the modules relevant for their project and build a firmware tailored to their
needs. Support for the 32-bit ESP32 has also been implemented. The prototyping
hardware typically used in a circuit board functioning as a dual in line package which
integrates a USB controller with a smaller surface mounted board containing the MCU
and antenna. The choice of the DIP format allows for easy prototyping on breadboards.
The design was initially based on the ESP-12 module of the ESP8266, which is a Wifi
soC integrated with tensilica xtensa LX106 core, widely used in IOT applications.

Picture of Node MCU

7
Pin Diagram for NodeMCU

8
1.4.2 IR sensor:

Infrared radiation is an electromagnetic wave with wavelengths of 700nm to


1mm. It is emitted by objects with temperature above 0 kelvin. Furthermore intensity and
wavelength of infrared radiation depends on the temperature of the object. An IR sensor
consists of two parts, the emitter circuit and the receiver circuit. This is collectively
known as 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 photodiode’s resistance and output voltage change in proportion to IR light
received. This is the underlying working principle of the IR sensor. This type of incidence
can be direct incidence or indirect incidence. An IR sensor can measure the heat of an
object as well as detects the motion.

Picture of IR sensor

9
1.4.3 Servo motor:

A servo motor is a rotary actuator or linear actuator that allows for precise
control of angular or linear position, velocity and acceleration. It consists of a suitable
motor coupled to a sensor for position feedback. It also requires a relatively
sophisticated controller, often a dedicated module designed specifically for use with
servomotors. Servo motors are used in applications such as robotics, CNC machinery or
automated manufacturing. Servo motors are not a specified class of motor, although the
term servomotor is often used to refer to a motor suitable for use in a closed-loop control
system. Servo motors are used in applications such as robotics, CNC machinery or
automated Manufacturing.
Picture of Servo Motor

10
1.4.4 Male to Female jumper wires:

These are jumper wires male to female used in connecting female header pins
of any development board to other development boards having male connectors.

Picture of Male to Female Jumper Wires

1.4.5 Male to Male jumper wires:


These are jumper wires male to male used in connecting the female header pin of any
development board to other development boards or breadboards. Also you can combine
it with female jumper wire to create male to female jumper wire.

Pict
ure of Male to Male jumper wire

11
1.4.6 PCB:

A printed circuit board (PCB) mechanically supports and electrically connects


electrical or electronic components using conductive tracks, pads and other features
etched from one or more sheet layers of copper laminated onto and / or between sheet
layers of a non conductive substrate. Components are generally soldered onto the PCB
to both electrically connect and mechanically fasten them to it.
Picture of Printed Circuit Board (PCB)

12
1.4.7 Female berg Strips:

The female berg strips are commonly used as low cost connectors for custom
made cables or perforated prototyping PCBs. The standard spacing is the same as on
most solderless breadboards.
Picture of Female Berg Strips

1.4.8 Male berg strips:

Male berg pin is a type of electrical connector consisting of rows of the male
connector. The pins are inserted to PCB or other board to prevent damage of wires and
cables which cannot directly soldered on PCB

Picture of Male Berg strips

13
1.4.9 NodeMCU cable:

One meter long USB cable. It has the regular sized A plug on one end and a
micro plug on the other. Ideal for new Arduino Uno boards, charging almost every new
mobile phone except those from Apple and more. It has the full five-wire configuration in
a neat flat cable style. Either for data transmission or phone charging, this 1M noodle flat
wire data line V8 micro USB to USB charging cable for android phone will bring you
much convenience and help in daily life. Adopting high quality material with fine
workmanship, this data cable is durable in use.
Picture of NodeMCU cable

14
1.5. Softwares used in Smart Parking system

1. Arduino IDE
2. Adafruit IO
1.5.1 Arduino IDE:

The Arduino integrated development environment is a cross platform application


that is written in functions from C and C++. It is used to write and upload programs to
arduino compatible boards, but also with the help of third party cores and other vendor
development boards. The source code for IDE is released under the GNU general public
license version 2. The arduino IDE supports the languages C and C++ using special
rules of code structuring. The arduino IDE supplies a software library from the wiring
project, which provides many common input and output procedures. 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 toolchain, also included with 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. By default, avrdude is used as the uploading tool to flash the user
code onto official arduino boards. With the rising popularity of arduino as a software
platform, other vendors started to implement custom open source compilers and tools
that can build and upload sketches to other microcontrollers that are not supported by
arduino’s official line of microcontrollers.

Arduino IDE software

15
1.5.1.1 Steps to install Arduino IDE

1. Go to Arduino.cc website
2. Click on the download link

16
3. Begin the Download

After clicking on the download link you will be redirected to the donation page here you can
donate or skip it if you like by clicking on just download link

4. Begin the installation process


17
Open the downloaded file

A new window will open asking you to agree to the license agreement.

Click on I agree to continue.

5. Select what to install

Now you will see all available options to install the software with.
If you do not know what you need, it is the best to keep everything checked as you can
change it later when the installation has finished.

Click on next to continue

18
6. Choose the installation path

Now

you have to choose the path the software will be installed in.
It is fine to leave it as the configured location but if you want the arduino IDE somewhere else
you can change that here.

Click on ‘Install’ to begin the installation.

7. Finish the installation

19
Wait until the installation is finished, it should not take very long.

When the installation is finished you may click on close to end the setup wizard.

8. Launch the Arduino IDE.

The Arduino IDE has been successfully installed.


To launch the IDE you can click on the desktop icon that was created for you or by
searching for it in the start menu.

20
1.5.2 Adafruit:

Adafruit IO is an open data platform that allows you to aggregate,visualize and analyze live data
on the cloud. Using Adafruit IO, you can upload, display, and monitor your data over the
internet, and make project IOT enabled. You can control motors, read sensor data and make
cool IOT applications over the internet using Adafruit IO. For test and try, with some limitation,
Adafruit IO is free to use.

21

UNIT-2
EXISTING SYSTEM

India is facing a new problem nowadays – lack of sufficient parking space. With
families getting smaller and the total number of motor vehicles exceeding the total
number of heads per family, the parking scenario is woefully falling short of the current
requirements in the country. The situation is such that on any given working day
approximately 40% of the roads in urban India are taken up for just parking the cars. The
problem has been further exacerbated by the fact that nowadays even people from low
income groups are able to own cars. The number of families with cars has become
much more than what the country is able to manage. As it is, the cities in India are highly
congested and on top of that the parked cars claim a lot of space that could otherwise
be used in a better way. Thanks to poor, and at times zero, navigability, Indian cities are
regarded as some of the worst options for living. The existing parking system in India
has parking slots with lack of navigation facilities and online checking of parking slot
availability status. That means parking slots refer to the existing system is a space
useful to park a vehicle without having no knowledge of having a vacancy slot to park
the vehicle before reaching the parking slot which can cause disturbance to the public,
increase pollution and wastage of fuel. This can cause wastage of time and affects the
mood of the driver. In some cases, Such as the parking areas having less wide roads
leads to heavy traffic which may affect the schedule plan of many people. The horn
sound causes much disturbance to the people living in nearby areas.

Existing Parking system

22
UNIT-3
PROPOSING SYSTEM

The proposed Smart Parking system consists of an on-site deployment of an IOT


module that is used to monitor and signalize the state of availability of each single
parking space. A mobile application is also provided that allows an end user to check the
availability of parking space and book a parking slot accordingly. Smart parking makes
use of sensing devices such as IR sensors, Servo motors etc… to discover the
occupancy of the parking slot. The strong sensing systems are being built to examine
and transfer data to the database in real time. The system increases the accessibility of
parking with the use of sensors. Here we introduce a mobile application in which an end
user can see the parking slot availability status through their mobile. It can save time
and reduce wastage of fuel. Here the IR sensor detects the movement or motion and
temperature of an object. So, it detects the motion of the vehicle and sends the data to
NodeMCU and the servo motor has also IR sensors connected to them externally. When
a vehicle enters the parking area the gates will automatically open and allows the
vehicle into the parking area. In our project we have used two servo motors and five IR
sensors, one sensor is placed along with the servo motor at the entry gate and another
IR sensor is placed along with another servo motor at the exit gate. Remaining three
sensors will be placed at the parking slot1, parking slot2 and parking slot3. So, here the
process is whenever a vehicle enters the parking entry gate, the entry gate will
automatically open and allow the vehicle into the parking area, this facility can be
implemented by Placing IR sensors near entry and exit gates along with servo motors.
After some delay, the entry gate will be closed and the data will be stored in our Adafruit
platform with time. Coming to the parking slots, as we have already discussed above,
that IR sensor detects the motion and temperature of an object that means it can also be
able to detect whether the vehicle is parked or not in a selected slot and sends the data
to the NodeMCU. Similar to the process at the entry gate, the exit gate also
automatically opens whenever the IR sensor detects a vehicle and sends the data to
NodeMCU. The NodeMCU will send the data to the Adafruit platform. The reason why

23
we have chosen Adafruit is that it is absolutely free of cost and technically has high
features when compared to other platforms. It can be used to monitor the data from
anywhere in this world and it does not have any extra charges for using particular
function. Actually it suits best to implement this project. Creating an account in adafruit is
much easier, all you need is an email ID. It is fully secured and can be used for low and
medium project proposals. It does not need an expert to change modifications and give
instructions that means the operation is a very easy task and can be finished in less time
when compared to other platforms. We have to accept that coding is somewhat difficult
than some other applications but it gives the best results and the user can experience
the professional feel and smooth touch. Coming to our project, we can be able to
monitor the detailed report about the parking status along with date and time much
easier. We are also able to control some of the features through Adafruit.
Smart Parking System

24
3.1 Advantages of smart parking system

● Less pollution:

Smart parking contributes to a cleaner environment. Reducing the time that is


necessary to find a parking slot will reduce the amount of fuel that is used when
looking for a parking space. This makes the process of finding a parking spot
contribute to less pollution, which is beneficial for everyone.

● The space of a municipality will be utilized more efficiently :

Because smart parking sensors transmit live data, drivers will have a real time
overview of the occupancy of parking bays. This means that free spots can be
filled quicker, which will reduce the time that a parking spot is empty.

● Safety:

The use of Smart Parking sensors can optimize safety within cities. As a result
of placing, for instance, on ground sensors on parking bays, people will not be as
stressed as when they are looking for parking spaces. Because these people will
know where they are going, they can simply navigate to their parking spot and
they will not have to stress out about it.

● Real-time parking analytics for cities:

Parking space will become intelligent by use of smart parking sensors on the
parking bays that you’re able to see historical data which is stored.

25
3.2 Application:
Here we have used the Adafruit website to monitor the status of parking slot
availability with data storage facilities. If we modify the privacy settings an end user can
be able to view the parking slot availability status.
1. To use Adafruit IO, first you have to create an account on Adafruit IO. To do this,
go to the Adafruit IO website and click on ‘ Get started for free’ on the top right of
the screen.

2. After finishing the account creation process, log in to your account and click on
‘AIO’ key on the top right corner to get your account username and AIO key.

When you click on AIO key, a window will pop up with your Adafruit IO AIO key
and Username. Copy this key and username, it will be needed later in this code.

26
3. Now, after this, you need to create a feed, click on ‘feed’. Then click on actions, and then on
‘Create a new feed’ as shown in the image below.

4. After this, a new window will open to enter the name and description of the feed. The writing
description is optional.
27
5. Click on ‘create’, after this, you will be redirected to your newly created feed.

After creating feeds, now create an Adafruit IO dashboard to show all of these
feeds on a single page. To create a dashboard, Click on dashboard option and
then click on action, and after this, click on ‘Create a new dashboard’.

In the next window, enter the name for your dashboard and click on ‘create’.

6. As the dashboard is created now, we will add our feeds to the dashboard. To add
a feed, click on the ‘+’ in the top right corner.
28
To add a button on the dashboard click on the desired block.

Here
is the block arrangement of our project Smart Parking system.
29
UNIT-4
PROGRAM AND CODE

The code will be written in Arduino IDE.

4.1 Programming NodeMCU for IOT Parking System

To program NodeMCU with an Arduino IDE go to file>Preference>settings.


Enter https://arduino.esp8266.com/stable/package_esp8266com_index.json into the
‘Additional Board Manager URL’ field and click on ‘ok’.

30
Now go to Tools>Boards>Boards Manager.

31

In Boards Manager windows, Type esp in the search box, esp8266 will be listed there
below. Now select the latest version of the board and click on install.
After installation is complete, go to Tools>Board>and select NodeMCU 1.0(ESP-12E
Module). Now you can program NodeMCU with Arduino IDE.

32
4.2 Code:

#include <ESP8266WiFi.h>
#include <Servo.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <NTPClient.h>;
#include <WiFiUdp.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
const char *ssid = "Willett"; // Enter your WiFi Name
const char *pass = "02011976"; // Enter your WiFi Password

#define MQTT_SERV "io.adafruit.com"


#define MQTT_PORT 1883
#define MQTT_NAME "ramyapravalika04"
#define MQTT_PASS "aio_elVo60mgFvqkXirzbMxhqAxY6RSo"
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 19800,60000);
Servo myservo; //servo as gate
Servo myservos; //servo as gate

int carEnter = D0; // entry sensor


int carExited = D2; //exi sensor
int slot3 = D7;
int slot2 = D6;
int slot1 = D3;
int count =0;
int CLOSE_ANGLE = 80; // The closing angle of the servo motor arm
int OPEN_ANGLE = 0; // The opening angle of the servo motor arm
int hh, mm, ss;
int pos;
int pos1;

String h, m,EntryTimeSlot1,ExitTimeSlot1, EntryTimeSlot2,ExitTimeSlot2,


EntryTimeSlot3,ExitTimeSlot3;
boolean entrysensor, exitsensor,s1,s2,s3;

33
boolean s1_occupied = false;
boolean s2_occupied = false;
boolean s3_occupied = false;

WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, MQTT_SERV, MQTT_PORT, MQTT_NAME,
MQTT_PASS);

//Set up the feed you're subscribing to


Adafruit_MQTT_Subscribe EntryGate = Adafruit_MQTT_Subscribe(&mqtt,
MQTT_NAME "/f/EntryGate");
Adafruit_MQTT_Subscribe ExitGate = Adafruit_MQTT_Subscribe(&mqtt, MQTT_NAME
"/f/ExitGate");

//Set up the feed you're publishing to


Adafruit_MQTT_Publish CarsParked = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/CarsParked");
Adafruit_MQTT_Publish EntrySlot1 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/EntrySlot1");
Adafruit_MQTT_Publish ExitSlot1 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/ExitSlot1");
Adafruit_MQTT_Publish EntrySlot2 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/EntrySlot2");
Adafruit_MQTT_Publish ExitSlot2 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/ExitSlot2");
Adafruit_MQTT_Publish EntrySlot3 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/EntrySlot3");
Adafruit_MQTT_Publish ExitSlot3 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/ExitSlot3");

void setup() {
delay(1000);
Serial.begin (9600);
mqtt.subscribe(&EntryGate);
mqtt.subscribe(&ExitGate);
timeClient.begin();
myservo.attach(D4); // servo pin to D6
myservos.attach(D5); // servo pin to D5

34
pinMode(carExited, INPUT); // ir as input
pinMode(carEnter, INPUT); // ir as input
pinMode(slot1, INPUT);
pinMode(slot2, INPUT);
pinMode(slot3, INPUT);
WiFi.begin(ssid, pass); //try to connect with wifi
Serial.print("Connecting to ");
Serial.print(ssid); // display ssid
while (WiFi.status() != WL_CONNECTED) {
Serial.print("."); // if not connected print this
delay(500);
}
Serial.println();
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP Address is : ");
Serial.println(WiFi.localIP()); //print local IP address }

void loop() {

MQTT_connect();
timeClient.update();
hh = timeClient.getHours();
mm = timeClient.getMinutes();
ss = timeClient.getSeconds();
h= String(hh);
m= String(mm);
h +" :" + m;

entrysensor= !digitalRead(carEnter);
exitsensor = !digitalRead(carExited);
s1 = digitalRead(slot1);
s2 = digitalRead(slot2);
s3 = digitalRead(slot3);

35
if (entrysensor == 1) { // if high then count and send data count=
count+1; //increment count
myservos.write(OPEN_ANGLE);
delay(3000);
myservos.write(CLOSE_ANGLE);
}
if (exitsensor == 1) { //if high then count and send count= count-
1; //decrement count
myservo.write(OPEN_ANGLE);
delay(3000);
myservo.write(CLOSE_ANGLE);
}
if (! CarsParked.publish(count)) {}

if (s1 == 1 && s1_occupied == false) {


Serial.println("Occupied1 ");
EntryTimeSlot1 = h +" :" + m;
//Serial.print("EntryTimeSlot1");
//Serial.print(EntryTimeSlot1);

s1_occupied = true;
if (! EntrySlot1.publish((char*) EntryTimeSlot1.c_str())){}
}
if(s1 == 0 && s1_occupied == true) {
Serial.println("Available1 ");
ExitTimeSlot1 = h +" :" + m;
//Serial.print("ExitTimeSlot1");
//Serial.print(ExitTimeSlot1);

s1_occupied = false;
if (! ExitSlot1.publish((char*) ExitTimeSlot1.c_str())){}
}
if (s2 == 1&& s2_occupied == false) {
Serial.println("Occupied2 ");
EntryTimeSlot2 = h +" :" + m;
//Serial.print("EntryTimeSlot2");
//Serial.print(EntryTimeSlot2);
s2_occupied = true;

36
if (! EntrySlot2.publish((char*) EntryTimeSlot2.c_str())){}
}
if(s2 == 0 && s2_occupied == true) {
Serial.println("Available2 ");
ExitTimeSlot2 = h +" :" + m;
//Serial.print("ExitTimeSlot2");
//Serial.print(ExitTimeSlot2);
s2_occupied = false;
if (! ExitSlot2.publish((char*) ExitTimeSlot2.c_str())){}
}
if (s3 == 1&& s3_occupied == false) {
Serial.println("Occupied3 ");
EntryTimeSlot3 = h +" :" + m;
//Serial.print("EntryTimeSlot3: ");
//Serial.print(EntryTimeSlot3);
s3_occupied = true;
if (! EntrySlot3.publish((char*) EntryTimeSlot3.c_str())){}
}
if(s3 == 0 && s3_occupied == true) {
Serial.println("Available3 ");
ExitTimeSlot3 = h +" :" + m;
//Serial.print("ExitTimeSlot3: ");
//Serial.print(ExitTimeSlot3);
s3_occupied = false;
if (! ExitSlot3.publish((char*) ExitTimeSlot3.c_str())){ }
}

Adafruit_MQTT_Subscribe * subscription;
while ((subscription = mqtt.readSubscription(5000)))
{

if (subscription == &EntryGate)
{
//Print the new value to the serial monitor
Serial.println((char*) EntryGate.lastread);

37
if (!strcmp((char*) EntryGate.lastread, "ON"))
{
myservos.write(OPEN_ANGLE);
delay(3000);
myservos.write(CLOSE_ANGLE);
}
}
if (subscription == &ExitGate)
{
//Print the new value to the serial monitor
Serial.println((char*) EntryGate.lastread);

if (!strcmp((char*) ExitGate.lastread, "ON"))


{
myservo.write(OPEN_ANGLE);
delay(3000);
myservo.write(CLOSE_ANGLE);
}
}
}
}
void MQTT_connect()
{
int8_t ret;

// Stop if already connected.


if (mqtt.connected())
{
return;
}

uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) // connect will return 0 for connected
{
mqtt.disconnect();
delay(5000); // wait 5 seconds

38
retries--;
if (retries == 0)
{
// basically die and wait for WDT to reset me
while (1);
}
}
}
39

UNIT-5
RESULT

In this study, the implementation of smart parking system has been presented. Its efficiency in
alleviating the traffic problem that arises especially in the city area where traffic congestion and
insufficient parking spaces are undeniable, It does so by directing patrons and optimizing the
use of parking spaces. With the study of IR sensor technology used in detecting vehicles, which
is one of the crucial parts of a smart parking system. Although there are certain disadvantages
in the implementation of smart parking systems, the advantages overweighs its disadvantages.

5.1 Expecting Outcomes:


● The system benefits of smart parking go well beyond avoiding time wasting.

● Enables cities to develop fully integrated multimodal intelligent transportation systems with
great security and efficiency.

● Developing smart parking solutions within a city solves the vandalism and pollution problem.

● Fuel saving (According to a report, smart parking can result in 220,000 gallons of fuel saving
till 2030 and approx 300,000 gallons of fuels saved by 2050.)

● More automation and less manual activity saves on labor cost and resource exhaustion

● Drivers are less distracted looking around for a spot because they know where they can park
their car. They will have full attention on the road. By having the attention on the road, the
chances of occurrence of accidents are very low.

● It reduces the traffic congestion on roads so that there will be more benefits. 40
41

UNIT-6
REFERENCES

https://www.researchgate.net/publication/303842610_IoT_based_Smart_Parking_Syste m

https://en.wikipedia.org/wiki/NodeMCU

https://en.wikipedia.org/wiki/Arduino#:~:text=The%20Arduino%20integrated%20develop ment
%20environment%20%28IDE%29%20is%20a,the%20IDE%20for%20the%20lang uages
%20Processing%20and%20Wiring.

https://io.adafruit.com/

http://www.arduino.cc/

https://github.com/arduino-libraries/NTPClient

https://github.com/adafruit/Adafruit_MQTT_Library

https://arduino.esp8266.com/stable/package_esp8266com_index.json 42

You might also like