Exemple #1
0
     }, {
         "name": "gyroscope",
         "data": sense.get_gyroscope(),
         "unit": "deg"
     }]
     dataJSON = json.dumps(data)
     msg = dataJSON.encode('utf-8')
     connection.sendall(msg)
 if cmd == b'get_env':
     data = [{
         "name": "TemmperatureFromHumidity",
         "data": sense.get_temperature_from_humidity(),
         "unit": "C"
     }, {
         "name": "TemmperatureFromPressure",
         "data": sense.get_temperature_from_pressure(),
         "unit": "C"
     }, {
         "name": "Pressure",
         "data": sense.get_pressure(),
         "unit": "hPa"
     }, {
         "name": "Humidity",
         "data": sense.get_humidity(),
         "unit": "%"
     }]
     dataJSON = json.dumps(data)
     msg = dataJSON.encode('utf-8')
     connection.sendall(msg)
 else:
     break
Exemple #2
0
import time
from sense_emu import SenseHat
sense = SenseHat()

while True:
    #Temperatura
    t1 = sense.get_temperature_from_humidity()
    t2 = sense.get_temperature_from_pressure()
    t = (t1 + t2) / 2
    t = round(t)

    #Umiditate
    h = sense.get_humidity()
    h = round(h)

    #Presiune
    p = sense.get_pressure()
    p = round(p)

    print("************")
    print("Temp:")
    print(t)
    print("Umid:")
    print(h)
    print("Pres:")
    print(p)
    print("************")
    time.sleep(3)