Advertisement
DD3AH

Frosch

Apr 14th, 2024
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | Source Code | 0 0
  1. #!/usr/bin/python3
  2.  
  3. print ("init")
  4. from sense_hat import SenseHat
  5. import time
  6. import requests
  7.  
  8. s = SenseHat()
  9. nmax=10
  10. count = nmax-2
  11. sleepsec = 30
  12.  
  13. requests.get ("https://nobs.furry.de/klima/")
  14. print ("ok")
  15.  
  16. while True:
  17.         t1 = []
  18.         t2 = []
  19.         p  = []
  20.         h  = []
  21.  
  22.         for n in range(nmax):
  23.                 print (".", end='', flush=True)
  24.                 t1.append(s.get_temperature())
  25.                 t2.append(s.get_temperature_from_pressure())
  26.                 p.append(s.get_pressure())
  27.                 h.append(s.get_humidity())
  28.                 time.sleep (sleepsec)
  29.  
  30.         t1.remove(min(t1))
  31.         t2.remove(min(t2))
  32.         h.remove(min(h))
  33.         p.remove(min(p))
  34.  
  35.         t1.remove(max(t1))
  36.         t2.remove(max(t2))
  37.         h.remove(max(h))
  38.         p.remove(max(p))
  39.  
  40.         timestamp = time.strftime('%Y-%m-%d %H:%M:%S')
  41.         payload = {'timestamp':timestamp, 't1': sum(t1)/count, 't2':sum(t2)/count, 'p':sum(p)/count, 'h':sum(h)/count}
  42.         requests.get ("https://nobs.furry.de/klima/klima.php", params=payload)
  43.         print ("#", flush=True)
  44.  
Tags: Wetter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement