Example #1
0
def main():

    # Menyimpan pin-pin relay dan memasukkan nilai "state"nya ke dalam Dictionary bernama "pins" yang telah diinisiasi sebelumnya
    for pin in pins:
        pins[pin]['state'] = GPIO.input(pin)

# memasukkan Dictionary "pins" ke dalam dictionary "templateData":
    templateData = {'pins': pins}

    var_mainTankWaterLvl = JSNDistance.measureTank(GPIO_TRIGGER_MAIN,
                                                   GPIO_ECHO_MAIN,
                                                   mainTankDistance)
    var_secondaryTankWaterLvl = JSNDistance.measureTank(
        GPIO_TRIGGER_SECONDARY, GPIO_ECHO_SECONDARY, secondTankDistance)

    var_mainTankTemperature = DSTemp.read_temp(device_file1)
    var_secondaryTankTemperature = DSTemp.read_temp(device_file2)

    return render_template(
        'home.html',
        mainTankWaterLvl=var_mainTankWaterLvl,
        secondaryTankWaterLvl=var_secondaryTankWaterLvl,
        mainTankTemperature=var_mainTankTemperature,
        secondaryTankTemperature=var_secondaryTankTemperature,
        **templateData)
Example #2
0
def main():
    # Menyimpan pin-pin relay dan memasukkan nilai "state"nya ke dalam Dictionary bernama "pins" yang telah diinisiasi sebelumnya
    for pin in pins:
        pins[pin]['state'] = GPIO.input(pin)

# memasukkan Dictionary "pins" ke dalam dictionary "templateData":
    templateData = {'pins': pins}

    var_mainTankWaterLvl = JSNDistance.measureTank(GPIO_TRIGGER_MAIN,
                                                   GPIO_ECHO_MAIN,
                                                   mainTankDistance)
    var_secondaryTankWaterLvl = JSNDistance.measureTank(
        GPIO_TRIGGER_SECONDARY, GPIO_ECHO_SECONDARY, secondTankDistance)

    var_mainTankTemperature = DSTemp.read_temp(device_file1)
    var_secondaryTankTemperature = DSTemp.read_temp(device_file2)

    hour, minutes = CurrentACS.simulate_battery_usage()

    #    hour, minutes = CurrentACS.get_battery_estimated_life(50,4.187,20)

    return render_template(
        'home.html',
        mainTankWaterLvl=var_mainTankWaterLvl,
        secondaryTankWaterLvl=var_secondaryTankWaterLvl,
        mainTankTemperature=var_mainTankTemperature,
        secondaryTankTemperature=var_secondaryTankTemperature,
        **templateData,
        hour=str("%.0f" % hour),
        minutes=str("%.0f" % minutes),
        powerMode="Baterai")
Example #3
0
def getSensorsValue():
    var_mainTankTemperature = DSTemp.read_temp(device_file1)
    socketio.emit('main_tank_temp', {
        'mainTankTemp': var_mainTankTemperature,
    },
                  namespace='/home')
    socketio.send('main_tank_temp', {
        'mainTankTemp': var_mainTankTemperature,
    },
                  namespace='/home')
    print("Main Tank Temp : " + var_mainTankTemperature)
Example #4
0
def main_tank_temp(main_tank_temp):
    var_mainTankTemperature = DSTemp.read_temp(device_file1)
    send('main_tank_temp', {
        'mainTankTemp': var_mainTankTemperature,
    },
         broadcast=True)