Commit 3e65a6b901332ec90f972f573cfa2a17c9496197
1 parent
91e408f2
Fichier python
Showing
1 changed file
with
13 additions
and
3 deletions
Show diff stats
site/fichiersRPI/Rpi_to_server.py
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | import serial |
4 | 4 | import requests |
5 | 5 | import datetime |
6 | - | |
6 | +import os | |
7 | 7 | date_comp = datetime.datetime.now() |
8 | 8 | A = str(date_comp.year) |
9 | 9 | M = str(date_comp.month) |
... | ... | @@ -13,12 +13,22 @@ m = str(date_comp.minute) |
13 | 13 | s = str(date_comp.second) |
14 | 14 | date = A + '-' + M + '-' + J + ' ' + h + ':' + m + ':' + s |
15 | 15 | |
16 | +os.system("ip r | cut -f9 -d' ' > ip_address.txt") | |
17 | + | |
18 | +file = open("ip_address.txt", 'r') | |
19 | +ip_address = file.readline() | |
20 | +ip_address = file.readline()[:-1] | |
21 | + | |
22 | +num_capteur = int(os.path.abspath(".")[-1]) | |
23 | + | |
24 | + | |
16 | 25 | ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) |
17 | 26 | value = ser.readline() |
18 | 27 | while (value in ['\r', '', '\n']): |
19 | 28 | value = ser.readline() |
20 | 29 | data = str(float(value[0:4])) |
21 | 30 | |
22 | -params = {"ip_address":"172.26.145.111", "numero":"2", "name":"Solaris", "data": data, "date": date} | |
23 | -r = requests.post("http://serveur-etu.polytech-lille.fr/~grouille/PROJET/requests.php", data = params) | |
31 | + | |
32 | +params = {"ip_address": ip_address, "numero": num_capteur, "data": data, "date": date} | |
33 | +r = requests.post("http://projet-p10.plil.fr/requests.php", data = params) | |
24 | 34 | print(data) |
25 | 35 | \ No newline at end of file | ... | ... |