Monday, May 4, 2015

Smart Parking -

My final project is to demonstrate Smart Parking using Internet of Things. I have used Django framework - Python web framework which follows model-view-controller (MVC) architectural pattern. Using Django made my work easy as I  just need to concentrate on my application code. I have used RESTful API to collect data from sensors and to get data from user. I'm using sqlite3 which is default one in Django frame work  and basic HTML to create web page. 

The total project is majorly divided in to three systems, Controller program that monitors the sensor data and update those details in to data base, Views program that monitors the request from the front end and renders the information that it fetched from database to webpage , and frontend HTML page that  displays the details.

Sensor and Wiring : 

 I have used HC-SR04 sensor to measure the distance as I found it affordable and is having good range detection 4 to 400 cm. But I found it working good if the object is place some where between 4 to 250 cm. It actually works well if you place the object with in 30 degrees of angle.

Let us see how to wire it. 

VCC - Connected to 5V as sensor needs 5V power
Trig - Connect this to GPIO output 
Echo - Connect this to GPIO input 
GND - Connected to ground

The output signal form sensor will be 5V, but the Raspberry Pi can only handle 3.3v or less. So in order to protect GPIO pins we need resistors to get down voltage to 3.3V or less. I have used two resistors 180 and 330 k ohm which are connected in parallel. 


Vout =   Vin * R2/(R2+R1)
Vout = Vin * 180 /(180 + 330)
Vout = 5V * 0.352941176
Vout = 1.8V 



Wiring 

Controller :

Controller generates the trigger which will be reflected back when it hits some obstacle. We will measure time that sound took to get back to echo and calculate distance using distance formula.

Distance = Speed * Time

Speed of Sound = 340m/s

Controller checks the distance of object every 5 seconds and updates those details in Database. I have designed this in such a way that if the distance of object is greater than 50, then update the Parking status as "empty" otherwise update it as "occupied". Controller will update database only when it senses a change in parking state.  


Smart parking Dash board shows Empty count and Occupied count and will allow you to reserve a parking lot for you if parking is available.  Default time vale to book would be 1 hour and you can change it. In case if parking is already occupied, it shows you expected parking available timestamp.
Every Booking is Request Post, which will validates the data and sum up the number of hours entered to current time stamp and store it as next parking available timestamp, which is then showed on webpage. 

I would like to enhance this project adding features like dynamic pricing - combining the earlier parking patterns and current need and available parking slots, Informing towing company - Adding more sensors to make complete system and handling them. I can use same sensors combining with Pi-camera and buzzer  for parking assist in car. This would display the distance of car behind you and alerts you.