4
0
Fork 0
mirror of https://github.com/Robertofon/bienenchaos.git synced 2024-06-06 22:06:23 +02:00
bienenchaos/src/weight-datageneration.py

31 lines
968 B
Python
Raw Normal View History

2020-07-13 21:50:17 +02:00
import nau7802py
import time,os
myScale = nau7802py.NAU7802()
grafanaurl="%GRAFANA_URL%"
2021-01-15 19:53:47 +01:00
hiveeyesurl="https://swarm.hiveeyes.org/api/hiveeyes/Kryvle/Zietenaugust/"
2020-07-13 21:50:17 +02:00
if myScale.begin():
while True:
currentReading = myScale.getReading()
currentWeight = myScale.getWeight()
print('Reading: ' + str(currentReading)+" "+ str(round(currentWeight, 4)))
try:
cmd="curl -i -XPOST '"+grafanaurl+"' --data-binary 'weight,location=bees01 value="+str(currentWeight)+"'"
print (cmd)
os.system(cmd)
except:
print("no access to grafana?")
pass
time.sleep(1)
2021-01-15 19:53:47 +01:00
try:
cmd="curl --header \"Content-Type: application/json\" -XPOST -d '{\"weight\": "+str(currentWeight)+"}' "+hiveeyesurl+"Beute2/data"
print (cmd)
os.system(cmd)
except:
print("no access to hiveeyes.org?")
pass
time.sleep(1)