loading

A DIY Tutorial for Building an Smart Parking Meter

Cities are getting smarter, and a vocal group of us hopes that the first issue they solve is traffic. And one cause of the headaches of traffic is parking. So, how do we solve it?

A DIY Tutorial for Building an Smart Parking Meter 1

With smart parking meters!This tutorial demonstrates how to build a prototype of an IoT-enabled smart parking meter application using IBM Bluemix and PubNub. The app has three core functions:Showing the driver a realtime view of available and taken parking spotsAllowing the driver to reserve a parking spaceAutomatically tracking billing based on the drivers actions (like entering and leaving the parking space)Project Setup and Full Code RepoThis project is a great DIY experiment for IoT enthusiasts.

So if youre interested in trying it out, head over to GitHub for the complete source code of the bluemix-parking-meter project.Refer to the build instructions and readme file for detailed steps, right from configuring the hardware to hosting and running the application. For hosting this application, youll need to create a Bluemix and PubNub account.

Visit the IBM Bluemix signup page and PubNub add-on page to create your respective accounts. Both of the services offer a free tier account to play around with their offerings. ComponentsThere are three components of the application:Parking Management Server (PMS) monitors all the parking spaces and manages metering and billing for all users.

IoT hardware platform connects the parking spaces to PMS and also detects the presence or absence of a vehicle.Mobile App offers an easy interface to assist the driver to find a vacant space and manage his parking usage and billing. The hardware platform is powered by Arduino Yun and uses ultrasonic sensors to detect the presence or absence of a vehicle in a parking space.

A DIY Tutorial for Building an Smart Parking Meter 2

The PMS is implemented as an application server running on Python. It keeps track of all the devices and manages billing and reservations. The Mobile App (also known as Auto Park) is a Cordova and JavaScript-based Android app.

The PMS application server is hosted on the IBM Bluemix cloud platform and the entire communication between PMS to hardware and PMS to the mobile app is powered by PubNubs Realtime Data Stream Network.HardwareThe following is the list of hardware components used for this project:Arduino YunHC-SR04 ultrasonic sensor (3 nos. )A sample setup on a breadboard is shown below:And the associated schematic diagram for the hardware circuit is below:There are three functional parts of the hardware:Master Controller The WiFi-enabled Arduino Yun acts as the master controller for controlling a few parking spaces.

It periodically monitors and gets the status of each parking space within its jurisdiction, via ultrasonic sensors. It also interfaces with PMS via PubNub and publishes the parking statusSensor Controller This is an internal component of Arduino Yun board, powered by ATMega32 chip. It directly interfaces with the sensors and runs a loop, every few seconds, to get the latest status of each sensorUltrasonic Sensor Three HC-SR04 sensors are used to simulate three parking spaces.

The source code for hardware setup is available under yun_pubnub directory (for master controller) and device/hcsr04 directory (for sensor controller) in the GitHub repository.Parking Management Server (IBM Bluemix)The PMS is written in Python and can be installed as an IBM Bluemix hosted service. IBM Bluemix provides the computing horsepower for the PMS to monitor hardware devices and manage parking metering and billing for the users.

Additionally, you will need to associate the PubNub add-on service with your IBM Bluemix account for the PMS to work with PubNub. Refer to the steps in README.md to understand how to setup and host a Python application under Bluemix with PubNub.

The source code for PMS is located under the parking-meter directory in the GitHub repository.Mobile AppThe mobile app is a standard Cordova based Android app. It displays a map of the parking area with color coded parking spaces to assist the user in choosing a vacant space.

The source code for the mobile app is located under MobileApp directory in the GitHub repository.PubNubPubNub acts as the communication middleware for the entire system. It provides a cloud-based realtime Data Stream Network which supports more than 70 SDKs, such that it can enable any device to communicate with any other device on the Internet.

This application uses three of PubNubs SDKs for all components to seamlessly communicate with each other. These are:Javascript SDK for the mobile appPython SDK for PMSPOSIX C SDK for the Arduino YunThis application relies on several PubNub channels to enable communication between the components, as depicted below:The private-channel in the above diagram refers to a dedicated channel between the PMS and one mobile app. All messages exchanged through the PubNub channels are in JSON format.

For every mobile app requesting for parking reservation, the PMS initiates messages through this channel for that particular mobile app. The significance of all the channels will be clarified in the next section.System Operation and ScenariosThe complete operation of this system can be divided into the following five scenarios.

Scenario 1: App InitializationWhen the mobile app is launched for the first time after installation, it asks for the license plate/registration number of the users vehicle. This acts as a unique identifier for the PMS to track the app for billing purposes.Subsequently, the app sends a request to the PMS to get the status of all the parking spaces.

This is used to display the map, where each space is identified with a slot number (001, 002 and 003). Here is how the message exchange takes place between the PMS and mobile app:The JSON request from the app contains a parameter RequestType with the value 1 to indicate a request for fetching the bulk status of all parking spaces. The JSON response from PMS contains the parking spaces slot number as the parameter and its status as either 0 or 1 , to indicate that the space is either vacant or occupied.

For the map display in the mobile app, parking spaces which are currently vacant are indicated as green, whereas the ones that are occupied or reserved are indicated as red.Scenario 2: Device Status UpdateWhenever the parking space detects presence or absence of a vehicle, it immediately signals the PMS.Here, 001 identifies the slot identification number of the space and the value 1 indicates that the parking space is occupied.

Alternately, a value of 0 indicates that the space is vacant. The PMS also relays this information on a global PubNub channel parkingapp-resp so that all apps can update their parking map display.Scenario 3: Reservation request & Billing StartA user approaching a vacant parking space can reserve it in advance by tapping on a desired vacant parking slot on the app.

This prompts the PMS to initiate a billing session for the user. PMS sends a message to the app on its private channel to initiate the start of billing. Along with this, PMS also starts a timer.

Here is a closer look at the format of JSON messages in this interaction:The parameter RequestType with a value 2 indicates a request for reservation is the license registration number of the vehicle is identified by itselfA sessionType with value 0 indicates the start of billing session for the user who has reserved the slot number identified by the value of deviceID.Upon receiving the message on its private channel, the mobile app displays a message to the user to confirm his parking reservation request:Additionally, the PMS also sends an update on the channel parkingapp-respto inform all mobile apps that the said parking space is now occupied.Scenario 4: Reservation ConfirmationAfter reserving, when the user finally pulls in and parks his vehicle in the designated parking space, the hardware sends a status update to the PMS to indicate reservation confirmation.

At this moment, the PMS stops the timer. Scenario 5: Billing StopLater, when the user pulls out his vehicle from the parking space, the hardware device again senses this and sends a status update to PMS indicating that the space is now vacant. Upon receiving this update, PMS calculates the bill for the user and sends a billing session stop message along with bill details to the mobile app via its private channel.

The JSON message received by the mobile app contains the parameters for the bill details: is the start time of parking is the end time of parking is the total time of parking (in minutes) is the billed amount. Finally, the mobile app displays the bill details on the screen as follows:PMS is programmed to charge $10 for every sixty minutes of parking.Alternate ScenariosIn case the user reserves the parking space but does not show up, the PMS timer, which is started in scenario 3, counts down from 60 seconds to 0 and then finally performs scenario 5 without the hardware trigger.

In this case the user is charged with a minimum bill $10. Further, this application does not have any provision to authenticate the user during parking (as part of scenario 4), so as to ensure that the user who reserved the parking space is the one who actually parks his vehicle in that space. This is left as an exercise for the readers who would want to further enhance this application and make it feasible for a closer to real life deployment.

We had a great time building and playing with this application, and testing the end-to-end scenario was quite interesting considering that there are quite a few subsystems involved. Using IBM Bluemix & PubNub services greatly simplifies the developmental challenges as the developer can focus on the application logic without worrying about how to make the communication work between different subsystems. Apart from this, both the services are capable of handling massive scale which can be leveraged to build similar real world applications which require 247 uptime and thousands of random users coming in.

Originally published at all the latest advances and tech news sent directly to your inbox?. RELATED QUESTION I didn't get Google Glass Explorer Edition.

Is trying to learn Glass dev without the hardware a futile effort? No, you can still learn the fundamentals of Glass development without the hardware. There are three main approaches for accomplishing this: 1) Visit the Mirror API documentation, get into the playground, and start hashing up some code.

Download the PHP, Java, and Python library, whichever you're most comfortable with. Familiarize yourself with the jargon and converntions (timeline, bundles, menus, etc). Read the support documentation (second link below) to see how the Glass hardware actually functions.

Build some apps to this specification. Soon enough, you will find a friend with hardware to t

GET IN TOUCH WITH Us
recommended articles
Cases
no data
Shenzhen Tiger Wong Technology Co., Ltd is the leading access control solution provider for vehicle intelligent parking system, license plate recognition system, pedestrian access control turnstile, face recognition terminals and LPR parking solutions.
no data
CONTACT US

Shenzhen TigerWong Technology Co.,Ltd

Tel: +86 13717037584

E-Mail: info@sztigerwong.com

Add: 1st Floor, Building A2, Silicon Valley Power Digital Industrial Park, No. 22 Dafu Road, Guanlan Street, Longhua District,

Shenzhen,GuangDong Province,China  

                    

Copyright © 2024 Shenzhen TigerWong Technology Co.,Ltd  | Sitemap
Contact us
skype
whatsapp
messenger
contact customer service
Contact us
skype
whatsapp
messenger
cancel
Customer service
detect