Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- print ("init")
- from sense_hat import SenseHat
- import time
- import requests
- s = SenseHat()
- nmax=10
- count = nmax-2
- sleepsec = 30
- requests.get ("https://nobs.furry.de/klima/")
- print ("ok")
- while True:
- t1 = []
- t2 = []
- p = []
- h = []
- for n in range(nmax):
- print (".", end='', flush=True)
- t1.append(s.get_temperature())
- t2.append(s.get_temperature_from_pressure())
- p.append(s.get_pressure())
- h.append(s.get_humidity())
- time.sleep (sleepsec)
- t1.remove(min(t1))
- t2.remove(min(t2))
- h.remove(min(h))
- p.remove(min(p))
- t1.remove(max(t1))
- t2.remove(max(t2))
- h.remove(max(h))
- p.remove(max(p))
- timestamp = time.strftime('%Y-%m-%d %H:%M:%S')
- payload = {'timestamp':timestamp, 't1': sum(t1)/count, 't2':sum(t2)/count, 'p':sum(p)/count, 'h':sum(h)/count}
- requests.get ("https://nobs.furry.de/klima/klima.php", params=payload)
- print ("#", flush=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement