Automatic bottle filling with ESP32 and KY-032 sensor

ESP32 29-01-25
15 0

Tutorial plan

1- Presentation of Automatic bottle filling

2- How does ESP32 board controls the system ?

3- Necessary components of system

4- Circuit setup of system

5- Programming the ESP32 board

 

 

Presentation of Automatic bottle filling

An Automatic Bottle Filling System is a modern industrial solution designed to fill bottles with liquids efficiently and accurately. These systems are widely used in industries like food and beverage, pharmaceuticals, cosmetics, and chemicals, where precision and hygiene are critical.

Working Principle

The system consists of various components that work together to ensure smooth operation:

🔹 Bottle Conveyor System – Moves bottles to the filling station.
🔹 Liquid Dispensing Mechanism – Uses pumps, gravity, or pressure to fill bottles.
🔹 Sensors & Controllers – Detect bottle presence and control liquid flow.
🔹 Capping & Sealing Unit – Seals the bottles after filling.
🔹 Labeling & Packaging System (optional) – Applies labels and prepares bottles for distribution.

Advantages of Automatic Bottle Filling Systems

Increased Productivity – Faster and more efficient than manual filling.
Precision & Consistency – Ensures uniform volume in every bottle.
Reduced Waste – Minimizes spillage and overfilling.
Hygienic & Safe – Designed to comply with food and pharmaceutical standards.
Cost-Effective – Reduces labor costs in large-scale production.

 

How does ESP32 board controls the system ?

This project utilizes an ESP32 board along with a HC-SR04 sensor, a 28BYJ-48 stepper motor, a water pump, a relay module, a timing belt, a support structure, and a disc to automate the bottle filling process. Below is a breakdown of its working principle and operation.

Step 1: Bottle Detection Using HC-SR04

The ESP32 continuously checks for a bottle at the filling position.

If the HC-SR04 detects an object (bottle) within a set distance, it sends a signal to the ESP32.

Step 2: Stopping the Conveyor

The ESP32 stops the 28BYJ-48 stepper motor, ensuring the bottle is correctly positioned.

Step 3: Activating the Water Pump

The ESP32 triggers the relay, turning ON the water pump.

The pump dispenses liquid into the bottle for a predefined time or until the correct volume is reached.

Step 4: Stopping the Water Pump

Once the filling process is complete, the ESP32 turns OFF the relay, stopping the pump.

Step 5: Moving the Next Bottle

The stepper motor restarts, moving the next empty bottle into position.

The cycle repeats.

 

Necessary components of system

1. ESP32 Board

It controls all components and processes.

It processes input from the HC-SR04 sensor and controls the stepper motor, relay, and water pump.

2. HC-SR04 Ultrasonic Sensor

HC-SR04

It detects the presence of a bottle at the filling position.

Working Principle:

a) Sends out ultrasonic pulses.

b) Measures the time taken for the echo to return.

c) Calculates the distance of an object (bottle).

d)The ESP32 reads the sensor output and determines whether a bottle is present.

3. 28BYJ-48 Stepper Motor with ULN2003 Driver

Conveyor Belt Movement: Moves bottles into position using the timing belt.
Precise Control: Allows step-by-step motion for accurate positioning.

4. Water Pump (Controlled via Relay Module)

Pumps the liquid into the bottle when activated.

5. Relay module

The relay module acts as a switch, turning the pump ON/OFF.

6. Timing Belt:

Ensures synchronized movement of bottles.

7. Support Structure

Holds all components in place.

8. Disc Mechanism

May be used to rotate or align bottles properly.

Jumper Wires :

Jumper wires

Jumper wires will be used to make connections between the components.

Breadboard (Optional):

Breadboard

A breadboard is a versatile and reusable platform used for prototyping and testing electronic circuits without the need for soldering.

 

Circuit setup of system

1- Mounting the ESP32 board and the HC-SR04 sensor

The HC-SR04 sensor is used to detect if there is a bottle in the right position to fill it.

Connect :

- the VCC pin of the sensor to the 3.3V pin of the ESP32 board

- the GND pin of the sensor to the GND pin of the ESP32 board

- the Trig pin of the sensor to pin N°5 of the ESP32 card

- the Echo pin of the sensor to pin N°18 of the ESP32 board

2- Mounting the ESP32 board with the stepper motor

The role of the stepper motor is to turn the disc containing the bottles

Connect:

- the UNL2003 module to the stepper motor

- the IN1 pin of the UNL2003 module to pin N°32 of the ESP32 card

- the IN2 pin of the UNL2003 module to pin N°33 of the ESP32 card

- the IN3 pin of the UNL2003 module to pin N°25 of the ESP32 card

- the IN4 pin of the UNL2003 module to pin N°26 of the ESP32 card

3- Mounting the ESP32 board with the water pump

The relay is the intermediate component between the ESP32 board and the water pump. It allows the ESP32 board to control the water pump

The role of the relay is to start or stop the pump responsible for filling the bottles.

Connect:

- the (-) terminal of the relay to the GND pin of the ESP32 board

- the (+) terminal of the relay to the 3.3V pin of the ESP32 board

- the terminal (S) of the relay to pin No. 19 of the ESP32 board

 

Programming the ESP32 board

Here is the micropython program which allows to control the automatic bottle filling system by the ESP32 card.

You have to use these two libraries servo and Stepper.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info