ESP-01 based controller for electronic sprayer bottle
This is really brainchild of my 3 year old requesting a remote controlled water sprayer having been asked what he'd like to make!
Key Features:
🌐 Dual control via Web UI and MQTT topics
⚙️ Configurable pulse duration (e.g., ON:250 for 250 ms relay activation)
📶 Wi-FiManager captive portal for network setup
🔁 Persistent multi-Wi-Fi connection logic (primary + fallback)
🔔 MQTT Last Will & Testament + status updates
🛠️ OTA updates for remote firmware upgrades
💾 Web-based configuration page with instant feedback
Using parts I had to hand I came up with this very basic (but functional) circuit to directly mimic a physical press of the momentary button used to toggle power to the sprayer pump using a cheap Chinese tlp176a opto-isolating relay to briefly short across the sprayers momentary switch contacts (the sprayer PCB has a latching circuit and so a second momentary button press is needed to turn the pump off again).
The ESP-01 is powered by a HT7333 LDO voltage regulator driven by the sprayers own 18650 Li-ion cell with a 10uf tantalum smoothing capacitor. The supplied 18650 is of pretty low capacity but 24hrs standby time appears to be possible... A decent 3500mAh cell lasts closer 48hrs. obviously these timings will drop with greater pump usage.
The photos (but not the schematic) show a set of 4 header pins (used for initial code upload via a FTDI adapter) and a switch which simply connects GPIO0 to GND for code upload... Both of which are redundant following initial code upload as I've added OTA upload and could have been removed altogether.
Coding wise I am a beginner really and as such heavily reliant on ChatGPT for most of this... there could well still be bugs left to find!
A Wifi AP point is created, accessible at 192.168.4.1 where WIFI STAs can be configured along with MQTT server and Topic details can be set if required. Webserver control is accessible via IP assigned by router (or http://smart_sprayer/) or 192.168.4.1 (if connected to AP) MQTT publishes online/offline status to 'sprayer/status' whilst control is possible by publishing messages to the cmd topic 'sprayer/button/cmd' - or as set in AP / wifi config page with value format ON:duration (in ms e.g.) Topic: 'sprayer/button/cmd' Value: 'ON:1000'
Unless changed in code... The default spray time= 1000ms (1sec) Min spray time= 250ms (1/4sec) and Max spray time = 120000ms (2min).
I've probably spent more time creating this repo than I did actually creating the controller (I know it shows!). This was a very quick rough and ready, throw it together type project to keep a 3 y.o. interested & happy... it has, though, proved to work even better than I'd expected and maybe deserves more time in future to refine it.