A MicroPython-based MQTT watering system controller for the Raspberry Pi Pico W, designed to be managed from Home Assistant or any MQTT-capable service.
This is the Pico W port of Draco.
- MQTT control — subscribe to topics and toggle GPIO pins remotely from Home Assistant or any MQTT broker.
- Relay/GPIO interface — drives a relay shield to control a water pump and a refill tank pump.
- Heartbeat — publishes a keep-alive signal to an MQTT topic every 30 seconds so Home Assistant can detect disconnections.
- Healthchecks.io integration — optional periodic HTTP ping so you can monitor uptime and get alerts if the Pico stops responding.
- NTP time sync — sets the Pico's clock on boot via NTP.
- Auto-recovery — resets the device automatically on WiFi loss or MQTT errors.
| Component | Notes |
|---|---|
| Raspberry Pi Pico W | Main controller |
| Relay shield | Controls pumps via GPIO |
| Water pump | Connected to GP20 by default |
| Refill tank pump | Connected to GP21 by default (future use) |
draco-micropython/
├── main.py # Entry point — WiFi init, MQTT loop, timers
├── requirements.py # Installs MicroPython packages via mip
├── draco/
│ ├── config.py # Configuration template (copy & fill in your values)
│ ├── mqtt_interface.py # MQTT client wrapper
│ └── wificonnection.py # WiFi connection helper
└── test/
└── blinking.py # LED blink test
Copy draco/config.py and fill in your values:
WIFI_SSID = "your_ssid"
WIFI_PASSWD = "your_wifi_password"
MQTT_CLIENT = "draco-pico"
MQTT_BROKER_IP = "192.168.1.100"
MQTT_BROKER_PORT = 1883
WATERPUMP_TOPIC = "home/watering/waterpump"
DRACO_HB_TOPIC = "home/watering/DRACOHB"
WATERPUMP_PIN_OUT = "GP20"
REFILL_TANK_PIN_OUT = "GP21"
# Healthchecks.io (set to False to disable)
HEALTHCHECKSIO_ENABLE = True
HEALTHCHECKIO_URL = "https://hc-ping.com/your-uuid-here"
HEALTHCHECKIO_TIME_MS = 600000 # ping interval in ms (10 minutes)Then update the import in main.py and requirements.py to point to your config file.
Run this once on the Pico W to install the required MicroPython packages over WiFi:
python requirements.py
This installs:
umqtt.simple— lightweight MQTT clienturllib.urequest— HTTP requests (used for healthchecks.io pings)
Upload all files to the Pico W (e.g. with Thonny or mpremote), then run:
python main.py
On boot the device will:
- Connect to WiFi (LED blinks during connection, stays on when connected).
- Sync time via NTP.
- Connect to the MQTT broker and subscribe to the water pump topic.
- Start the heartbeat timer (every 30 s) and, if enabled, the healthchecks.io timer.
- Enter the main loop, polling MQTT messages and toggling the relay accordingly.
Publish 1 to WATERPUMP_TOPIC to turn the pump on, 0 to turn it off:
mosquitto_pub -h 192.168.1.100 -t "home/watering/waterpump" -m "1"- Soil moisture sensor support for automatic watering.
- Temperature and relative humidity sensor integration.
- Physical switch + second pump for autonomous tank refill.
Open a GitHub Discussion for questions or ideas.