Water Dispenser

Water Dispenser:

Inspiration and Sketch:


Development:

Prototype 1 of the Smart Paw Water Dispenser: Principle of the Water Jug Dispenser



Principle of the Water Jug Dispenser

A dog water dispenser with a water jug works using a simple system of pressure and gravity. The operation is detailed below:

Initial Position

The water jug is placed upside down on a base with a bowl for the water. The mouth of the jug is submerged in the bowl.

Pressure Balance

When the jug is full and placed on the base, a water seal is created at the mouth of the jug, maintained by the air pressure inside the jug and the water pressure in the bowl.

Water Release

As the dog drinks water from the bowl, the water level drops, reducing the pressure at the mouth of the jug. This allows air to enter the jug, displacing an equivalent amount of water into the bowl to refill it.

Restoration of Balance

The water flow continues until the water level in the bowl reaches the mouth of the jug again, creating a new pressure seal and stopping the water flow.

Problem When Perforating the Jug

When the jug is perforated at the top, the system stops working due to the loss of pressure balance:

Broken Pressure Balance

Perforating the jug allows air to enter freely, eliminating the hermetic seal necessary to maintain internal pressure.

Uncontrolled Water Flow

Without the pressure balance, the water inside the jug no longer stops at the mouth and flows freely into the bowl, causing spills and inefficient water supply.

Attempt to Create a Smart Water Dispenser

In a smart water dispenser project, perforations were made in the jug to install sensors and a hose. Despite sealing the perforations with silicone, the system did not work correctly due to pressure leakage through the hose:

Insufficient Sealing

Although the perforations were sealed with silicone, any small air leak through the hose or seals can break the necessary pressure balance.

Pressure Leakage Through the Hose

The hose introduces an additional path for air entry, making it difficult to maintain the hermetic seal necessary for the system to function correctly.

Conclusion

For a water jug dispenser to function correctly, it is essential to maintain a hermetic seal that ensures the pressure balance. Any perforation that allows air to enter, even if sealed with silicone, can compromise the system and cause uncontrolled water flow. In the case of a smart water dispenser, it is crucial to ensure that perforations for sensors and hoses are completely sealed to prevent pressure leaks.

Improvements:

3D design and printing

The initial idea was 2 sensors and 1 pump that could supply water from an external place every time it was finished, but when it came to drilling the jug to insert the motors and the hose, there was an air leak which the system could not do. compression causing the water to always be irrigated, so I had to redesign the drinking fountain, making it like a fountain and only using a sensor which detects when there is no water and turns off the pump, the disadvantage is that here the water is provided the user



Download 3D model

In these images, we can observe that the water dispenser has space for a pump with a hose responsible for cycling the water until it runs out. The blue component next to it is a level sensor, which ensures that when the water is depleted, it signals the pump to stop supplying water, thereby protecting the pump from damage and preventing unnecessary energy consumption. When the user refills the water, the sensor detects the new water level, reactivates the pump, and resumes its operation.


Components

Quantity Description Cost (USD) Photo
1 ESP32 $11.11 ESP32
1 level sensor $16.67 Servomotor
1 Water Pump $14 Water Pump
6 Resistors 220Ω $2.78 Resistors
3 Buttons $1.67 Buttons
10 jumpers $11.11 Cables
1 Resistances 0Ω $0.20 Resistances 0Ω
3 Capacitors 1 µF 50V $3.00 Capacitors 50V
3 Pin Header Female $1.00 Pin Header Female
1 AMS1117 $2.50 AMS1117
1 USBFT232 USB $10 AMS1117

Processes

Description Cost (USD) Photo
3D Printing (Approx. 1 kg) $35 3D Printing
Soldering $5.56 Soldering
Copper for PCB $5.56 Copper for PCB
50 cm water hose $2.5 Copper for PCB

electronic production

PCB

ESP32 Controlled Water Dispenser Schematic Explanation

This schematic is a PCB design for a water dispenser system controlled by an ESP32. Below is an explanation of each part of the schematic:

1. Microcontroller ESP32 (U1)

  • The brain of the system that will control the water dispenser. It has multiple GPIO (General Purpose Input/Output) pins used to connect sensors and the water pump.
  • Highlighted pins:
    • EN: Enable pin for the ESP32.
    • GPIO: General purpose input/output pins used to connect sensors, the pump, and other components.

2. Power Supply

  • J1 and J3: Pin header connectors that allow the connection of sensors and other external devices.
  • U2 (AMS1117-3.3): Voltage regulator that converts the input voltage to 3.3V needed to power the ESP32.
  • C2, C3, C4: Decoupling capacitors to stabilize the voltage and filter noise.

3. Relay (RL1)

  • Used to control the water pump, allowing the ESP32 to turn the pump on or off as needed.
  • D2: LED diode indicating the relay status.
  • Q1: Transistor acting as a switch to control the relay.
  • R1, R2, R3: Resistors that limit the current through the LED and transistor.

4. Sensors

  • Connections for two sensors (likely water level or flow sensors) connected through pin headers (J2 and J3).
  • R4, R5, R6, R7: Pull-up/pull-down resistors to ensure the sensors provide stable signals to the ESP32.

5. Tactile Switches (SW1, SW2, SW3)

  • These switches allow manual interaction with the system, such as manually turning the pump on/off or adjusting settings.
  • R8, R9, R10: Resistors that limit the current through the switches and ensure stable signals.

6. Capacitors

  • C1, C2, C3, C4: Help filter and stabilize signals and voltage in different parts of the circuit.

7. Connections

  • VCC and GND: Voltage and ground connections distributed throughout the circuit to power components and establish a common reference point.

This schematic shows a typical design of a control system based on the ESP32 with the ability to control a water pump via a relay and receive inputs from multiple sensors, along with a simple user interface with tactile switches.



ESP32 Design Improvements

The black top part of the ESP32 is an antenna. Currently, my design operates without interference, but it is important to consider some improvements to ensure optimal efficiency in the long term:

PCB Design

It is crucial to ensure that there is no copper directly under the antenna when milling the PCB. This helps to prevent signal interference and allows the antenna to operate effectively. In my current design, I have considered this aspect to avoid potential issues.

Placement

Similar to development boards, it is recommended to place the antenna outside the main area of the PCB or on the edge of the board. This minimizes obstructions and maximizes signal strength. Although my current design is functioning well, considering this recommendation can further improve performance.

Clearance

Maintaining sufficient clearance around the antenna is essential to avoid interference from other components and traces. I have tried to follow this practice in my design, but it is always good to review and ensure it is adequately met.

Integrating these points into the design can significantly improve the performance of the ESP32 antenna on my PCB. Although I currently have no interference issues, considering these improvements can be beneficial for future developments.


Download to cut PCB


Programming of Sensors and Actuators:

This PHP file manages reading and writing the water dispenser level in a text file and displays it in real-time.

<?php
// If the datosbebedero.txt file doesn't exist, create it with the initial value "0\r\n".
if (!file_exists("datosbebedero.txt")) {
    file_put_contents("datosbebedero.txt", "0\r\n");
}

// If a value is sent via a POST form, save it in the datosbebedero.txt file.
if (isset($_POST['valor'])) {
    $VAR1 = $_POST['valor']; // Assign the POST value to the $VAR1 variable
    $TEXTO = $VAR1 . "\r\n"; // Add a new line to the value
    file_put_contents("datosbebedero.txt", $TEXTO); // Save the value in the file
}

// Read the content of the datosbebedero.txt file.
$ARCHIVO = file_get_contents("datosbebedero.txt");
// Find the position of the first newline character.
$pos = strpos($ARCHIVO, "\r\n");
// Extract the value up to the first newline character.
$VAR1 = substr($ARCHIVO, 0, $pos);
?>

<!DOCTYPE html>
<html>
<head>
    <!-- Refresh the page every 1 second -->
    <meta http-equiv="refresh" content="1">
</head>
<body>
    <!-- Display the value stored in $VAR1 on the page -->
    <p style="font-size:20px; font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: #707070; line-height: 0;"><?php echo $VAR1 ?> </p>
</body>
</html>

Code Explanation

  1. File Creation: Checks if the `datosbebedero.txt` file exists. If not, it creates it with "0\r\n" as the initial value.
  2. Value Update: If a value is sent via a POST form, it saves this value in `datosbebedero.txt`.
  3. Value Reading: Reads the content of the file and extracts the value up to the first newline character.
  4. Auto Refresh: Reloads the page every second to show the updated value.

Download code

Arduino Code for Water Dispenser Control

This Arduino code reads the water level sensor and controls a pump based on the sensor state. It also sends the sensor and pump states to a server.


// Libraries included
#include <WiFi.h>
#include <HTTPClient.h>

// Global Variables
String serverName = "https://7b1bd7318-bc4d-4740-a62d-d7195741dcee-00-2biv5sob6tgpp.spock.replit.dev/bebedero.php";
int sensorLevel = 34; // Pin where the level sensor is connected
int pumpPin = 5; // Pin where the pump is connected

void setup() {
    Serial.begin(115200);
    pinMode(sensorLevel, INPUT);
    pinMode(pumpPin, OUTPUT);

    WiFi.begin("frank", "franlopez");
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("WiFi connected.");
}

void loop() {
    if (WiFi.status() == WL_CONNECTED) {
        HTTPClient http;
        http.begin(serverName);
        http.addHeader("Content-Type", "application/x-www-form-urlencoded");

        int sensorState = digitalRead(sensorLevel);
        int pumpState = (sensorState == HIGH) ? HIGH : LOW;
        digitalWrite(pumpPin, pumpState);

        String httpRequestData = "sensor=" + String(sensorState) + "&pump=" + String(pumpState);
        int httpResponseCode = http.POST(httpRequestData);

        if (httpResponseCode > 0) {
            String response = http.getString();
            Serial.println(httpResponseCode);
            Serial.println(response);
        } else {
            Serial.print("Error on sending POST: ");
            Serial.println(httpResponseCode);
        }

        http.end();
    }

    delay(1000);
}
    

The water dispenser on the page is shown as 1 or 0 due to the water level sensor. If the sensor detects no water, it will switch to 0, turning off the pump and indicating that 0 means no water, prompting the user to add more water. If it is at 1, there is water, and the pump will be running.


Download code

system integration


To store the electronic components, I created a 3D printed box that can be closed with either an acrylic cover for visibility of the components or a 3D printed cover that does not allow visual access.



Download box

Final water dispenser prototype.


files