01Hardware e softwareHardware & software
Pool-Pomp-Control
Sistema IoT per l'automazione e il monitoraggio da remoto della pompa di una piscina.
IoT system for remote automation and monitoring of a pool pump.
Il problemaThe problem
La pompa di una piscina di solito si accende e si spegne con un timer meccanico, da regolare a mano sul posto. Pool-Pomp-Control (PPC) permette di comandarla e controllarla da remoto, senza però esporre nulla su Internet.
A pool pump is usually switched on and off by a mechanical timer that has to be set by hand, on site. Pool-Pomp-Control (PPC) lets you operate and monitor it remotely, without exposing anything to the internet.
Come funzionaHow it works
Il cuore è un ESP32, chiuso in una piccola cassetta a tenuta insieme all'alimentazione, che comanda la pompa tramite un relè. Da un'interfaccia web si può accendere o spegnere la pompa in modalità manuale, oppure impostare fino a dieci fasce orarie giornaliere. Fasce e stato vengono salvati nella memoria non volatile della scheda: dopo un riavvio, il sistema riparte da dove era rimasto.
At its core is an ESP32, housed in a small sealed box together with the power supply, that drives the pump through a relay. From a web interface you can switch the pump on or off in manual mode, or set up to ten daily time slots. Slots and state are stored in the board's non-volatile memory, so after a reboot the system picks up where it left off.
Raggiungibile solo tramite VPNReachable only through the VPN
L'ESP32 non è mai esposto direttamente su Internet. È un peer di una VPN WireGuard, il cui hub gira con wg-easy in Docker su un Raspberry Pi. Il server web risponde soltanto agli indirizzi della VPN (10.9.0.0/24) e rifiuta tutto il resto con un 403; sul router è aperta solo la porta UDP di WireGuard. Telefoni e PC entrano nella stessa VPN e raggiungono la pompa come se fossero in casa: è WireGuard a occuparsi di autenticazione e cifratura.
The ESP32 is never exposed directly to the internet. It is a peer of a WireGuard VPN whose hub runs wg-easy in Docker on a Raspberry Pi. The web server only answers requests from addresses inside the VPN (10.9.0.0/24) and rejects everything else with a 403; the only port open on the router is WireGuard's UDP port. Phones and PCs join the same VPN and reach the pump as if they were at home, with WireGuard handling authentication and encryption.
Pensato per non fermarsiBuilt to keep running
Il dispositivo deve lavorare da solo per mesi, quindi buona parte del firmware serve a gestire i guasti. Un keepalive tiene aperto il tunnel e ogni minuto una sonda verifica che l'hub risponda. Se il tunnel cade, il firmware prova prima a riconnettere il Wi-Fi, poi riavvia l'intero stack di rete; il riavvio della scheda è l'ultima risorsa e avviene solo a pompa spenta.
The device has to work on its own for months, so a good part of the firmware deals with failures. A keepalive holds the tunnel open and a probe checks every minute that the hub answers. If the tunnel drops, the firmware first tries to reconnect the Wi-Fi, then restarts the whole network stack; rebooting the board is the last resort, and only happens while the pump is off.
La scheda non ha un orologio interno e prende l'ora via NTP: finché non è sincronizzata, le fasce orarie non toccano la pompa. Dopo ripetuti cali di tensione la pompa non viene riaccesa, per non sollecitare relè e motore con continui riavvii.
The board has no real-time clock and gets the time over NTP: until it is synced, the schedule never touches the pump. After repeated brownouts the pump is not switched back on, to spare the relay and motor from constant restarts.
Diagnostica e documentazioneDiagnostics and documentation
Due endpoint, /telemetry e /logs, mostrano uptime, stato della pompa e del Wi-Fi, memoria libera, motivo dell'ultimo riavvio e gli eventi recenti, così si capisce cosa è successo senza collegarsi via seriale. Nel repository ci sono anche lo schema elettrico, la distinta dei componenti e la documentazione dell'architettura di rete.
Two endpoints, /telemetry and /logs, show uptime, pump and Wi-Fi state, free memory, the reason for the last reset and recent events, so you can tell what happened without a serial connection. The repository also holds the wiring diagram, the bill of materials and the network architecture documentation.




