Blame view

raspberry/Rpi_to_server.py 699 Bytes
1824ee6a   grouille   Ajout du dossier ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #!usr/bin/env python
  
  import serial
  import requests
  import datetime
  
  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
  
  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)
  print(data)