diff --git a/site/fichiersRPI/Rpi_to_server.py b/site/fichiersRPI/Rpi_to_server.py index 836e4fd..004dd8d 100755 --- a/site/fichiersRPI/Rpi_to_server.py +++ b/site/fichiersRPI/Rpi_to_server.py @@ -3,7 +3,7 @@ import serial import requests import datetime - +import os date_comp = datetime.datetime.now() A = str(date_comp.year) M = str(date_comp.month) @@ -13,12 +13,22 @@ m = str(date_comp.minute) s = str(date_comp.second) date = A + '-' + M + '-' + J + ' ' + h + ':' + m + ':' + s +os.system("ip r | cut -f9 -d' ' > ip_address.txt") + +file = open("ip_address.txt", 'r') +ip_address = file.readline() +ip_address = file.readline()[:-1] + +num_capteur = int(os.path.abspath(".")[-1]) + + ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) value = ser.readline() while (value in ['\r', '', '\n']): value = ser.readline() data = str(float(value[0:4])) -params = {"ip_address":"172.26.145.111", "numero":"2", "name":"Solaris", "data": data, "date": date} -r = requests.post("http://serveur-etu.polytech-lille.fr/~grouille/PROJET/requests.php", data = params) + +params = {"ip_address": ip_address, "numero": num_capteur, "data": data, "date": date} +r = requests.post("http://projet-p10.plil.fr/requests.php", data = params) print(data) \ No newline at end of file -- libgit2 0.21.2