Esempio n. 1
0
def alarm_check(): 
    """Check for alarm condition"""
    global temp_alarm_lim,temperature,temp_alarm,unit
    if((unit==1 and temperature>(int(sensorRead.todegF(temp_alarm_lim)))) 
    or (unit==0 and temperature>int(temp_alarm_lim))):
        set_alarm()
    elif((unit==1 and temperature<(int(sensorRead.todegF(temp_alarm_lim-1)))) 
    or (unit==0 and temperature<int(temp_alarm_lim)-1)):
        reset_alarm()
Esempio n. 2
0
def update_data():
    """ function to update temp, humidity and Alarm data on display """
    global update_interval, temperature, unit

    threading.Timer(
        update_interval,
        update_data).start()  # to autorun function once every update interval

    humidity, temperature = sensorRead.get_TempHum()
    time = datetime.now().strftime('%b-%d-%Y %H:%M:%S')
    ui.label_updateTime.setText(time)

    if (unit == 1 and temperature !=
            None):  # if unit is set to degF convert temperature to degF
        temperature = sensorRead.todegF(temperature)

    if (temperature == None):  # handling data not being sent
        ui.lcd_temperature.display("Err")
    else:
        ui.lcd_temperature.display(temperature)

    if (humidity == None):  # handling data not being sent
        ui.lcd_humidity.display("Err")
    else:
        ui.lcd_humidity.display(humidity)

    alarm_check()
    update_last_temp()
    update_avg_temp()
    update_max_temp()
    update_min_temp()
    update_last_hum()
    update_avg_hum()
    update_max_hum()
    update_min_hum()
Esempio n. 3
0
def ws_last_temp(unit):
    """function to provide last value of temp from database 
    in the format that the jquery script needs"""
    ts,val = calcLastVal("temperature")
    if(unit==1):
        val=sensorRead.todegF(val)
    return('last_temp'+','+ts.strftime('%b-%d-%Y %H:%M:%S')+','+str(round(val,2)))
Esempio n. 4
0
def ws_min_temp(unit):
    """function to provide minimum temp data in the format that the jquery script needs"""
    ts, val = calcDayMinimum("temperature")
    if (unit == 1):
        val = sensorRead.todegF(val)
    return ('min_temp' + ',' + ts.strftime('%b-%d-%Y %H:%M:%S') + ',' +
            str(round(val, 2)))
Esempio n. 5
0
def update_min_temp():
    global unit
    ts, val = dbops.calcDayMinimum("temperature")
    ui.temp_unit_4.setText('degC')
    if (unit == 1):
        val = sensorRead.todegF(val)
        ui.temp_unit_4.setText('degF')
    ui.min_temp.setText(str(round(val, 2)))
    ui.min_temp_ts.setText(ts.strftime('%b-%d-%Y %H:%M:%S'))
Esempio n. 6
0
def update_last_temp():
    global unit
    ts, val = dbops.calcLastVal("temperature")
    ui.temp_unit_1.setText('degC')
    if (unit == 1):
        val = sensorRead.todegF(val)
        ui.temp_unit_1.setText('degF')
    ui.last_temp.setText(str(round(val, 2)))
    ui.last_temp_ts.setText(ts.strftime('%b-%d-%Y %H:%M:%S'))
Esempio n. 7
0
def getData(unit):
    """ function to get latest data from sensors , 
    accounts for unit change from the webpage and
    converts temperature values accordingly"""
    h,t= sensorRead.get_TempHum()
    if(t==None):
        t=-1
    if(h==None):
        h=-1
    if(unit==1):
        t=sensorRead.todegF(t)
    return (str(round(t,2))+','+str(round(h,2)))