예제 #1
0
def callback(channel):
    if GPIO.input(channel):
        print "LED off"
        lcd = Lcd()
        lcd.clear()
        lcd.display_string(message_need_water, 1)
        savedata(1, "Need water")
    else:
        print "LED on"
        lcd = Lcd()
        lcd.clear()
        lcd.display_string(message_noneed_water, 1)
        savedata(1, "No need water")
예제 #2
0
def pumpswitchOn(request):
    #lcd = Lcd()
    #lcd.clear()
    #lcd.display_string("pump on",1)
    #relay = Relay()
    #relay.switch(3,1)
    lcd = Lcd()
    lcd.clear()
    pumpStatus = "ON"
    lcd.display_string("Water Pump %s" % pumpStatus, 1)
    moistureLevel = getLatestMoistureLevel()
    savedata(1, moistureLevel, pumpStatus)

    response_mesage = {"result": "pump is on"}
    return JsonResponse(response_mesage)