Automatic Water Dispenser
Optimization and hygiene device providing automatic, contactless water dispensing. Combining container detection by an ultrasonic sensor, timed control with a dynamic display on an LCD screen and anti-overflow hydraulic...
Optimization and hygiene device providing automatic, contactless water dispensing. Combining container detection by an ultrasonic sensor, timed control with a dynamic display on an LCD screen and anti-overflow hydraulic safety, the system ensures precise filling of glasses while eliminating the risks of cross-contamination and waste.
1. CONTEXT AND PROBLEM STATEMENT
1.1 Context
In public spaces, schools, companies and healthcare centers, traditional water fountains with a manual button or mechanical lever are areas with a high risk of cross-contamination through physical contact. Moreover, manual dispensing often leads to water overflows caused by user inattention or imprecise dosing, resulting in waste and unsanitary floors.
1.2 Problem solved
The system simultaneously solves the problems ofsanitary hygiene and water waste.
The device eliminates the need for direct physical interaction thanks to a fully automated process driven by a state machine:
- Safe initialization: Startup with a welcome screen displayed for 1.5 seconds (DISPENSER / Automatic) and forced shutdown of the pump for safety reasons.
- Automatic detection: The ultrasonic sensor detects when a container is placed under the nozzle (distance less than or equal to 10 cm) and instantly triggers the 12V water pump relay.
- Flicker-free dynamic display: During the 5 seconds of service, the remaining time is calculated and refreshed only when the second changes on the 16x2 I2C LCD screen.
- Instant interruption safety: If the glass is removed before the end of the 5 seconds (distance greater than 10 cm), the pump is cut off immediately, the screen shows INTERRUPTED! / Glass removed for 1.5 seconds and the system goes back to standby.
- Automatic reset: Once filling is complete (FILLING / DONE!), the system prompts the user to remove their glass before going back to standby for the next user.
2. PROPOSED SOLUTION AND ARCHITECTURE
To guarantee smooth and hygienic dispensing, this project implements a standalone embedded solution built around the ESP8266 NodeMCUboard, an HC-SR04 ultrasonic sensor, a 16x2 I2C LCD screen and a 5V relay module driving the 12V pump.
Operation relies on a reactive finite state machine (FSM) paced by a 60 ms loop delay to ensure the stability of the ultrasonic measurements:
- In standby phase: The system displays instructions on the screen and measures the distance continuously.
- In filling phase: The relay is activated (logic LOW), the countdown is displayed (from 5 to 1 sec), and the pump stops after 5000 ms (or instantly if the glass is removed).
- At the end of service: The screen prompts the user to remove their glass before resetting the cycle as soon as the area is cleared.
3. PROGRAM LOGIC (FINITE STATE MACHINE)
The embedded program is built around a three-state dynamic machine:
State 1: ATTENTE_VERRE
The relay is deactivated (RELAIS INACTIF = HIGH).
- LCD display:
- Plaintext
- Place a glass
- Waiting...
Logic: The microcontroller calculates the distance via the function lireDistanceCM() (with a 25 ms timeout on the Echo pin). If the distance is valid (distance less than or equal to ), the relay engages (RELAIS_ACTIF = LOW), the internal timer (millis()) is initialized and the system switches to the state REMPLISSAGE.
State 2: REMPLISSAGE
The relay stays engaged to power the 12V pump for 5000 ms.
Immediate Removal Safety: If the distance becomes greater than 10 cm, the pump stops instantly, the screen displays for 1500 ms:
- Plaintext
- INTERRUPTED!
- Glass removed
Then the system goes back to the state ATTENTE_VERRE.
Anti-Flicker LCD Management: During the 5 seconds, the remaining second is calculated by (5000 - tempsEcoule + 999) / 1000. The screen updates only when the second changes :
- Plaintext
- Filling...
- Time: X sec
Normal end of cycle: Once the 5 seconds have elapsed, the pump is cut off, the screen displays for 1500 ms:
- Plaintext
- FILLING
- DONE!
Then the system switches to the state RETIRER_VERRE.
State 3: RETIRER_VERRE
The pump stays off (RELAIS_INACTIF = HIGH).
- LCD display:
- Plaintext
- Remove the glass
- please
Logic: The system continuously scans for the presence of the glass. As soon as the user removes their glass (distance greater than 10 cm), the state machine is reset and switches to the state ATTENTE_VERRE
Dynamic 16x2 I2C LCD Visual Interface:
Hardware I2C communication on GPIO 4 (SDA / D2) and GPIO 5 (SCL / D1) at address 0x27. Smart flicker-free screen refresh during the countdown.
Overflow Protection & Instant Interruption:
Immediate shutdown of the 12V relay as soon as the distance exceeds 10 cm during the filling cycle, preventing any accidental water spillage.
Power Control via Relay (Active-LOW Logic):
Control of the 12V circuit via pin GPIO 14 (D5). Safe control logic at startup (RELAIS INACTIF = HIGH).
Technologies used
Hardware
|
Component |
link to the components on Youpilab |
Technical role |
|
ESP8266 Microcontroller |
https://youpilab.com/components/product/module-wifi-node-mcu-esp-8266-12 |
Core of the system, processing of analog data and management of the Wi-Fi network stack. |
|
Ultrasonic distance sensor (HC-SR04) |
https://youpilab.com/components/product/capteur-a-ultrasons-hc-sr04 |
Contactless glass detection ( 10 cm) and overflow safety control during filling. |
|
5V Relay Module |
https://youpilab.com/components/product/module-relais-5v-1-canal-high |
Opening/closing control of the 12V pump power circuit (Active-LOW logic switching). |
|
16x2 I2C LCD screen |
https://youpilab.com/components/product/ecran-lcd-16x02-avec-iici2c |
Dynamic visual interface displaying user instructions, interruption alerts and the 5-second countdown. |
5. Software
- Language & IDE: Embedded C++ in the Arduino IDE.
- Serial speed: 115200 baud (debug logs on the serial monitor).
- Libraries used:
Wire.h : Custom I2C initialization via Wire.begin(4, 5).
LiquidCrystal_I2C.h : Control of the 16x2 LCD display at I2C address 0x27.
6. APPLICATIONS AND USE CASES
- School and University Water Fountains: Provides safe and autonomous access to drinking water for students without touching taps.
- Catering Areas and Companies: Avoids queues and mess around the fountain thanks to timed filling and automatic shutoff.
- Hospital Environments & Clean Rooms: Limits the spread of hand-borne infections.
No comments yet. Be the first!