From WhatsApp command to detached GPIO automation system with animated water tank visualization.
from gpiozero import Button, OutputDevice
from time import sleep, monotonic
import signal
import sys
FLOAT_GPIO = 17
PUMP_RELAY_GPIO = 27
float_sensor = Button(FLOAT_GPIO, pull_up=True, bounce_time=0.2)
pump = OutputDevice(PUMP_RELAY_GPIO, active_high=False, initial_value=False)
def is_water_low():
return float_sensor.is_pressed
def pump_on():
pump.on()
print("[ACTION] Pump ON")
def pump_off():
pump.off()
print("[ACTION] Pump OFF")
def safe_exit(signum=None, frame=None):
pump_off()
sys.exit(0)
signal.signal(signal.SIGINT, safe_exit)
signal.signal(signal.SIGTERM, safe_exit)
while True:
if is_water_low():
pump_on()
else:
pump_off()
sleep(1)
We value your privacy
We use cookies to improve your experience and analyze traffic. Privacy Policy
No section data available yet.
Sites with documented sections will appear here.
Basic Package
Special SME traction programme by AINNA.
Every package includes a Basic AI Agent for website governance, content assistance and article management.
View SME Offer →