error in try routine
parent
7b94fef947
commit
80b00a0efc
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
while [ /bin/true ]; do
|
||||
python /home/pi/rasolar/tri.py
|
||||
sleep 5
|
||||
done
|
5
tri.py
5
tri.py
|
@ -97,7 +97,7 @@ while a > 1:
|
|||
ch_val[channel_names.index("pressure")]=int(1000*bme_data.pressure) # Pressure
|
||||
ch_val[channel_names.index("humidity")]=int(1000*bme_data.humidity) # Humidity
|
||||
|
||||
timefile=round(timestamp/3600)
|
||||
timefile=round(timestamp/3600000)
|
||||
f1=open("/home/pi/log/data_{:d}.txt".format(int(timefile)),"a")
|
||||
payload={}
|
||||
for i in range(len(ch_val)):
|
||||
|
@ -110,6 +110,9 @@ while a > 1:
|
|||
json_out={"time": ch_val[channel_names.index("time")],"device": "rasolar","payload":payload}
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
except:
|
||||
print("{}: could not connect to database".format(time.time()))
|
||||
else:
|
||||
s.connect((HOST, PORT))
|
||||
s.sendall(json.dumps(json_out))
|
||||
s.close()
|
||||
|
|
Loading…
Reference in New Issue