Umeed Kothavala
Published © LGPL

Smarty Lot

Using a mobile app or an Alexa skill, the users would be able to check availability of parking spot in any connected parking lot.

IntermediateProtipOver 1 day964
Smarty Lot

Things used in this project

Hardware components

Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×4
2K Ohm Resistor
×4
Jumper wires (generic)
Jumper wires (generic)
×1
Ultrasonic Ranging Module HC SR04
×1

Story

Read more

Schematics

Smarty Lot - VUI Diagram

Code

Smarty Lot - Concept

Python
Additional credits go to: https://www.youtube.com/watch?v=xACy8l3LsXI and their channel for assisting in the ultrasonic sensor and breadboard setup with the Raspberry Pi. Their version of the Python code laid down the basis on which we built this.
import RPi.GPIO as GPIO #Imported GPIO library 
import time #Imported time library 
import requests #Imported requests library
import dweepy #Imported dweet library
import sys #Imported sys library

sys.setdefaultencoding() #set default encoding which is ascii in this version of Python

Trig = 23 #This will trigger the sensor
Echo = 24 #Will read return signal from sensor

print"In progress..."

while True:
		GPIO.setmode(GPIO.BCM)
		GPIO.setup(Trig, GPIO.OUT) #Setting it as output
		GPIO.setup(Echo, GPIO.IN) #Setting it as input

		GPIO.output(Trig, False) #Setting trigger pin to low
		print "Waiting for sensor to stabilize..."
		time.sleep(4) #waiting for the sensor to stabilize
		GPIO.output(Trig, True) #Sensor requires 10 microsecond pulse, hence powering it...
		time.sleep(0.00001)
		GPIO.output(Trig, False) #then setting it to low again

		while GPIO.input(Echo) == 0: #Checking if receiving any Echo
			pulse_start = time.time()
	
		while GPIO.input(Echo) == 1: #Checking if receiving any Echo
			pulse_end = time.time()
	
		pulse_duration = pulse_end - pulse_start #Pulse duration is the difference between start and end

		distance = pulse_duration*17100 #Distance is time * speed of sound which in this case is halved because we're only receiving the signal
		distance = round(distance, 2) #rounding off distance to 2 places

	if distance>=2 and distance<=50: #Check if distance is between 2cm and 40cm to determine occupancy
		dweepy.dweet_for(u'parkingLot', {u'free': u'false'}) #To send data to dweet if occupied
		print "Distance is",distance,"Occupied"
		time.sleep(120)
	else:
		dweepy.dweet_for(u'parkingLot', {u'free': u'true'}) #To send data to dweet if available
		print "Distance is",distance,"Available"
GPIO.cleanup() 

Credits

Umeed Kothavala

Umeed Kothavala

5 projects • 5 followers
Thanks to Aritra Chattaraj, Arjun Sabharwal, Manish Oswal, Onkareshwar Veer, Harshal Deshmukh, and Anagha Karve.

Comments