Smart and Autonomous parking.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

#Authors: Oulis Evangelos, Oulis Nikolaos, Drosos Katsibras
#===================================================================
#!/usr/bin/env python
import json
import requests
server_ip = "iot-smart-parking.herokuapp.com"
server_port = "443"
API_ENDPOINT = 'https://' + server_ip + ':' + server_port + '/'
try:
ser = serial.Serial(
port='/dev/ttyACM0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
c = requests.get(url=API_ENDPOINT, params = {})
doc = c.json()
parking = None
for park in doc:
if doc[str(park)] == 1:
parking = park
break
print ("Free parking is Number: " + parking)
ser.write("b'" + parking + "'")
ser.flush()
except (NameError, TypeError) as e:
print ("No free parking")
except requests.exceptions.ConnectionError:
print("No Internet access")