Browse Source

Fixes & pi software

master
cs151051 5 years ago
parent
commit
8f5cb2612b
  1. 4
      iNode/Makefile
  2. 25
      iNode/parking.py
  3. 4
      sensorNode/sensor.ino
  4. 14
      serverNode/serv.py

4
iNode/Makefile

@ -0,0 +1,4 @@
all:
sudo chmod +x /dev/ttyACM0
python3 parking.py

25
iNode/parking.py

@ -0,0 +1,25 @@
#!/usr/bin/env python
import time
import serial
ser = serial.Serial(
port='/dev/ttyACM0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
counter=0
while 1:
park_status = ser.readline()
try:
if park_status != prev_status:
if b'1' in park_status:
print("parking reserved.\n")
elif b'0' in park_status:
print("parking not reserved.\n")
except NameError:
print("**Not already prev variable.\n")
prev_status = park_status

4
iNode/sensor.ino → sensorNode/sensor.ino

@ -43,11 +43,11 @@ distance= duration*0.034/2;
//Serial.println(distance); //Serial.println(distance);
if (distance < 5){ if (distance < 5){
Serial.println("0"); Serial.println("0"); //parking isn't available.
digitalWrite(response, LOW); digitalWrite(response, LOW);
} }
else{ else{
Serial.println("1"); Serial.println("1"); //parking is available.
digitalWrite(response, HIGH); digitalWrite(response, HIGH);
} }

14
serverNode/serv.py

@ -0,0 +1,14 @@
#Authors: Oulis Evangelos, Oulis Nikolaos, Drosos Katsibras
from flask import Flask, request
from flask_restful import Resource, Api
from json import dumps
from flask.ext.jsonpify import jsonify
app = Flask(__name__)
apy = Api(app)
parking =[]
class Parking(Resource):
def get(self):
Loading…
Cancel
Save