DD3AH icon

Frosch

DD3AH | PRO | 04/14/24 10:01:27 AM UTC | 0 ⭐ | 1243 👁️ | Never ⏰ | [Wetter]
Python |

1.11 KB

|

Source Code

|

0 👍

/

0 👎

#!/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)
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎