-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPycom.py
64 lines (64 loc) · 1.63 KB
/
Pycom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from network import LoRa
import struct
import socket
lora=LoRa(mode=LoRa.LORA,frequency=868000000, sf=7)
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) #create a LoRa socket
i=0
while 1:
if i==0:
t=s.recv(4)
rx_data= struct.unpack('f', t)
temperature = rx_data
elif i==1:
t=s.recv(4)
rx_data= struct.unpack('f', t)
humidite = rx_data
elif i==2:
t=s.recv(4)
rx_data= struct.unpack('f', t)
pressure=rx_data
elif i==3:
t=s.recv(4)
rx_data= struct.unpack('f', t)
temp2=rx_data
elif i==4:
t=s.recv(4)
rx_data= struct.unpack('f', t)
tempWater=rx_data
elif i==5:
t=s.recv(2)
rx_data= struct.unpack('i', t)
luminosity=rx_data
elif i==6:
t=s.recv(1)
rx_data= struct.unpack('b', t)
immerged=rx_data
elif i==7:
t=s.recv(1)
rx_data= struct.unpack('b', t)
magnet=rx_data
elif i==8:
t=s.recv(4)
rx_data= struct.unpack('f', t)
numero=rx_data
print("Releve, temperature DHT11 : ")
print(temperature)
print(", humidite : ")
print(humidite)
print(", temperature MPL115A2 : ")
print(temp2)
print(", pression : ")
print(pressure)
print(", temperature eau : ")
print(tempWater)
print(", luminosite : ")
print(luminosity)
print(", immerge ? : ")
print(immerged)
print(", signal magnetique ? : ")
print(magnet)
print("numero : ")
print(numero)
elif i==9:
t=s.recv(4)
i = (i+1)%10