18b2ac95
grouille
Ajout dossier con...
|
1
2
3
4
5
|
#!usr/bin/env python
import serial
import requests
import datetime
|
3e65a6b9
grouille
Fichier python
|
6
|
import os
|
18b2ac95
grouille
Ajout dossier con...
|
7
8
9
10
11
12
13
14
15
|
date_comp = datetime.datetime.now()
A = str(date_comp.year)
M = str(date_comp.month)
J = str(date_comp.day)
h = str(date_comp.hour)
m = str(date_comp.minute)
s = str(date_comp.second)
date = A + '-' + M + '-' + J + ' ' + h + ':' + m + ':' + s
|
3e65a6b9
grouille
Fichier python
|
16
17
18
19
20
21
22
23
24
|
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])
|
18b2ac95
grouille
Ajout dossier con...
|
25
26
27
28
29
30
|
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]))
|
3e65a6b9
grouille
Fichier python
|
31
32
33
|
params = {"ip_address": ip_address, "numero": num_capteur, "data": data, "date": date}
r = requests.post("http://projet-p10.plil.fr/requests.php", data = params)
|
18b2ac95
grouille
Ajout dossier con...
|
34
|
print(data)
|