Scientific Journal of Technology Volume 6 Issue 4, 2024
ISSN: 2688‐8645
Drip Detection System based on STM32 Microcontroller
Feng Zhou
Suzhou Vocational Institute of Industrial Technology, Suzhou 215104, China
[email protected]Abstract
This design of the drip detection system is based on the STM32 microcontroller, making
it highly practical and innovative. The system combines multiple sensors and control
modules to achieve high‐precision detection and monitoring of intravenous drip
infusions. By integrating various sensors such as a drip rate detection module, a
temperature sensor, and a water level detection module, the system can
comprehensively monitor the status of the intravenous drip, including drip rate, liquid
level, and temperature. Through data processing and control by the STM32
microcontroller, the system can real‐time monitor the drip rate, liquid level, and
temperature of the intravenous drip, and display these data on an OLED screen,
providing intuitive information feedback. After conducting tests and analysis on the
system, its stability and reliability have been verified. With its high‐precision drip
detection capability, the system can meet the needs of life science experiments for
droplet detection. This system is widely applicable in various fields such as medical,
chemistry, and biology. In the medical field, it can be used for precise drug delivery,
thereby improving treatment effectiveness. In chemical and biological experiments, it
can be used for accurate dispensing of liquid reagents, ensuring the accuracy of
experimental results. The system features an OLED display, providing a user‐friendly
interface, and also comes with button operations, enabling users to conveniently set and
operate system parameters. Overall, this drip detection system based on the STM32
microcontroller not only possesses a high level of technological sophistication but also
has broad prospects for practical applications. It provides an efficient and accurate
solution for droplet detection and will play a significant role in related fields.
Keywords
STM32 Microcontroller; Droplet Speed Detection; OLED Liquid Crystal Display.
1. Introduction
The drip detection system based on the STM32 microcontroller represents an innovative
project that integrates modern electronics with medical applications. In the medical field,
intravenous infusion is a commonly used treatment method to provide patients with necessary
medications and nutrients. However, traditional intravenous infusion processes mainly rely on
medical staff's observation and manual adjustments, which not only results in low work
efficiency but also poses certain safety risks. Therefore, developing a system that can
automatically detect, control, and record the intravenous infusion process is crucial for
improving the efficiency and quality of medical services. With the continuous development of
microcontroller technology, the STM32 microcontroller has become the preferred choice for
embedded system design due to its high performance, low power consumption, and ease of
development. The STM32 microcontroller boasts rich peripheral interfaces and powerful
computing capabilities, enabling real‐time monitoring and precise control of the intravenous
infusion process. The drip detection system based on the STM32 microcontroller can achieve
the following functions: Firstly, it monitors the speed and flow rate of intravenous infusion in
11
Scientific Journal of Technology Volume 6 Issue 4, 2024
ISSN: 2688‐8645
real‐time through sensors, ensuring the stability and safety of the infusion process. Secondly,
the system can automatically adjust the speed of the infusion pump based on preset parameters
to cater to the needs of different patients. Furthermore, it records key data during the infusion
process, such as infusion volume and infusion time, providing medical staff with detailed
patient treatment records. Lastly, the system supports remote monitoring and alarm functions,
enabling prompt alerts to medical staff in case of abnormalities, thereby ensuring patient safety.
In practical applications, the drip detection system based on the STM32 microcontroller offers
several advantages. Firstly, it improves work efficiency by automatically completing the tasks
of monitoring and controlling intravenous infusion, reducing the workload of medical staff.
Secondly, it enhances treatment safety by continuously monitoring abnormalities during the
infusion process and promptly issuing alarms to prevent medical accidents caused by human
error. Thirdly, it provides rich data support by recording detailed infusion information,
assisting medical staff in making more scientific and reasonable treatment plans. However,
there are also some challenges in the design and implementation of the drip detection system
based on the STM32 microcontroller. Firstly, the system requires precise and stable monitoring
and control of the intravenous infusion process, necessitating careful sensor selection and
calibration. Secondly, the system must possess high reliability and anti‐interference capabilities
to ensure stable operation in complex medical environments. Additionally, the communication
protocol and data security of the system must be thoroughly considered to protect patient
privacy and information security[1‐10].
In conclusion, the drip detection system based on the STM32 microcontroller represents an
innovative project with broad application prospects. By fully utilizing the performance
advantages and technical characteristics of the STM32 microcontroller and combining them
with the actual needs of the medical field, an efficient, safe, and reliable drip detection system
can be developed, contributing significantly to improving the quality of medical services. With
continuous technological advancements and the increasing popularity of its applications, this
system is expected to play a more prominent role in the future[11‐16].
2. Hardware System Design
The STM32F103C8T6 microcontroller is a micro‐controller based on the ARM Cortex‐M3 core,
boasting high performance and low power consumption, making it suitable for the design of
embedded systems. It is equipped with a rich array of peripherals and interfaces, providing
flexible options for various applications. By utilizing three independent buttons, basic user‐
system interaction can be achieved, enabling threshold adjustment functionality. These three
buttons are specifically the set button, the increment button, and the decrement button. By
grounding one end of the button and connecting the other end to a microcontroller pin, the
state change of the pin can be detected to determine whether the button is pressed. This simple
yet effective button detection method is commonly used in embedded systems, realizing basic
user‐system interaction while reducing system complexity and cost. This design allows users
to conveniently adjust system parameters, enhancing the system's customizability and user‐
friendliness. Additionally, due to the simplicity of the button functions, users can easily
understand and operate them, making the system's usage more intuitive and convenient.
The buzzer module plays a vital role in the intravenous drip detection system, triggering alert
reminders. Using an active buzzer is a simple and effective choice because it has a built‐in drive
circuit that can directly generate sound through a voltage signal, eliminating the complexity of
controlling external PWM signals. In the design, the output signal of the STM32 microcontroller
is used to control the buzzer's operation. Since the buzzer requires a 5V power supply, while
the STM32 microcontroller typically outputs a 3.3V signal, a triode is required to amplify the
signal and drive the buzzer. Typically, an NPN‐type triode (such as the commonly used PN2222)
12
Scientific Journal of Technology Volume 6 Issue 4, 2024
ISSN: 2688‐8645
can be selected as the amplifier. Under this connection, when the output pin of the STM32
microcontroller outputs a high voltage level, the triode conducts, enabling the buzzer to work
and emit sound.
OLED is indeed a widely used display technology in embedded systems. Connection methods
for OLED display modules are as follows: 1. VCC (power positive): It is connected to the positive
pole of the power supply, which is usually the positive pole of the system's power supply. 2.
GND (ground): It is connected to the ground (GND) of the system to ensure the common ground
of the circuit. 3. SCL (clock signal line): SCL is the clock signal line of the I2C bus, used to
synchronize the clock signal for data transmission. 4. SDA (data transmission line): SDA is the
data transmission line of the I2C bus, used to transmit actual data. 5. OLED display module is a
very popular display device, which has been widely used in single‐chip applications.
This photoelectric sensor module is used in the intravenous drip detection system to detect the
speed of the drip in real time, with high sensitivity, high speed, adjustable sensitivity, and other
features. In the system, the DO pin is connected to a certain GPIO pin of the STM32
microcontroller, and the microcontroller reads signals from the ITR9606 speed detection
module through this pin. When the DO pin outputs a high voltage level, it indicates that the
medicine liquid has been detected passing through; when the DO pin outputs a low voltage level,
it indicates that no medicine liquid has been detected. By monitoring the state changes of the
DO pin, the system can detect the flow of intravenous liquid in real time, thereby calculating the
speed of the drip. This simple and effective working principle makes the ITR9606 module an
ideal choice for intravenous drip detection systems.
LM393 is a dual comparator, commonly used to convert analog signals into digital signals. It
features two comparators, and the voltage difference (threshold voltage) between the non‐
inverting input (‐) and the inverting input (+) of each comparator determines the trigger point
of the comparator. When the voltage of the non‐inverting input is higher than that of the
inverting input, the comparator outputs a high voltage level; when the voltage of the non‐
inverting input is lower than that of the inverting input, the comparator outputs a low voltage
level. The non‐inverting input of the LM393 comparator is connected to the output of the SW‐
A1 water level detection module, and the inverting input is connected to a fixed reference
voltage (which can be a fixed voltage generated by a voltage divider circuit), thus determining
the trigger point of the comparator. When the output voltage of the SW‐A1 water level detection
module is higher than the reference voltage, the LM393 comparator outputs a high voltage level,
indicating that the water level has been detected; when the output voltage is lower than the
reference voltage, the comparator outputs a low voltage level, indicating that the water level
has not been detected.
The DS18B20 temperature sensor is a commonly used digital temperature sensor that
communicates through a single‐bus interface. The DS18B20 temperature sensor uses a three‐
wire interface, including a data line (DQ), a power line (VCC), and a ground line (GND). Here is
a summary of the functions of these connections: Data Line (DQ): The data line is used for
transmitting temperature data and control signals. During communication, the STM32
microcontroller sends a temperature reading command through the data line, and the sensor
returns the current temperature value to the STM32 microcontroller in binary form. The data
line should use a single‐bus interface during communication. Power Line (VCC): The power line
is used for power supply, providing the operating voltage required by the DS18B20 sensor.
According to the information you provided, the operating voltage should range from 3.0V to
5.5V. Ground Line (GND): The ground line is used for grounding, ensuring a stable potential
reference in the circuit.
A relay is an electrical control component that can control the current after being turned on. It
can convert a small current into a large current and is often used to control the switch of a
single‐chip microcomputer. The relay consists of a coil, an iron core, contacts, and fixed contacts.
13
Scientific Journal of Technology Volume 6 Issue 4, 2024
ISSN: 2688‐8645
During its operation, once the coil outside the iron core is connected to the power supply, a
magnetic field will be generated in the iron core. This magnetic field may cause the contacts to
engage or disengage. When the contacts engage, the fixed contacts of the relay are connected to
the contacts, allowing the control of the large current path.
The STM32 main control module, button module, display module, stepper motor drive module,
drip rate detection module, water level detection module, DS18B20, and power module jointly
constitute the hardware of the personnel access management system under epidemic
prevention and control. The hardware works in a sequential order as follows: The STM32 reads
and parses the temperature, and simultaneously retrieves the numerical value from the drip
rate detection module. The current data of the system is displayed through the OLED display
module. Check if any buttons have been triggered, and execute the corresponding instructions
only if no buttons are triggered. The system automatically detects the water temperature. If it
detects that the temperature is below the threshold, it will issue an alarm, and the relay will
close to activate the heating element for warming. The system automatically detects the drip
rate. If it detects that the drip rate is not within the threshold, the relay will automatically drive
the stepper motor to rotate, thus bringing the drip rate back within the desired range.
3. Software Design
The current drip detection system mainly consists of five modules: DS18B20 temperature
detection module, drip rate detection module, water level detection module, alarm module, and
display module. These modules mainly function as follows: responsible for detecting the
temperature data within the medicine; responsible for detecting the dripping speed of the
intravenous drip; responsible for checking if there is any remaining medicine inside;
responsible for initiating the alarm when the system value triggers the threshold; and
responsible for displaying the sensor data of the system. The OLED display module used this
time requires the I2C protocol for communication. It cannot complete the subsequent processes
by directly using the OLED display module. It also needs to initialize its communication port
before use and set the OLED parameters, including resolution, brightness, and contrast. These
parameter settings need to be done in the initialization function. Additionally, the size of fonts
and characters should also be set appropriately. After initialization, the STM32 microcontroller
will transmit the content to the OLED display module for display in the corresponding location.
When programming the drip rate detection module, not only the external interrupt within the
STM32 is used, but also a timer. Before using the timer, its time needs to be set to 1 second.
When a drop of medicine passes through the drip rate detection module, it will detect and
trigger an external interrupt. The number of external interrupts triggered within the 1‐second
timer period can be used to calculate the liquid dripping rate. Since the signal generated by the
water level sensor is not an actual signal but an analog signal, it cannot be processed on the
microcontroller. Although the signal cannot be processed, the water level detection circuit
designed this time completes the signal processing by converting the analog signal into a digital
signal. The key to this process is the LM393 comparator. This allows the water level sensor to
react differently when it detects the presence or absence of liquid in the medicine. When there
is liquid, it will transmit a high‐level signal to the microcontroller through the IO port. When
there is no liquid, it will transmit a low‐level signal to the microcontroller through the IO port.
The alarm program is mainly used for reminders. When the system detects that the sensor value
is out of range and exceeds the threshold, it will trigger the alarm device to send an alert. It will
not only detect the value but also check if there is water in the medicine bottle, and if the
dripping rate and temperature are within a reasonable range. If these are not within the
reasonable range, the alarm device will also be triggered to activate the buzzer as a reminder.
14
Scientific Journal of Technology Volume 6 Issue 4, 2024
ISSN: 2688‐8645
When controlling the 28BYJ‐48 stepper motor, the STM32 microcontroller is still required. The
driving process of the stepper motor begins with defining the motor's pins. The five pins of the
28BYJ‐48 stepper motor serve two purposes. Four of them are used to control the stepping,
while the remaining one is for controlling the direction. After defining the pins, it is necessary
to determine how to control the signal for each step of the stepper motor. The 28BYJ‐48 stepper
motor is a four‐phase, five‐wire motor. To rotate the motor clockwise, different signals need to
be sent to each phase. Similarly, to rotate the motor counterclockwise, different signals also
need to be sent to each phase. The key to controlling the stepper motor lies in the driving
program. When the dripping speed is too high or too fast, the system will detect it and control
the stepper motor to reverse. The DS18B20 is a digital temperature sensor that communicates
through a single data bus. It cannot be used directly but requires initialization of the connection
between the bus type and the DS18B20 before use. During this process, a series of commands
need to be sent for reset and initialization. After this operation, the DS18B20 can be used. When
using it, it is also necessary to send commands to the sensor, such as reading the sensor ID,
initiating temperature conversion, and reading the temperature value. When sending
commands, it is essential to follow the protocol specified by the DS18B20 to ensure accurate
data transmission. When initiating the temperature converter, it is not advisable to rush the
conversion. It is necessary to check the response of the DS18B20 to determine if the conversion
can be completed. After the temperature is converted, the temperature value measured by the
DS18B20 can be read. When reading the temperature value, it should also be done according to
the DS18B20 protocol by sending read commands and receiving data. The temperature read is
represented in a 16‐bit binary two's complement format, which needs to be converted to the
actual temperature value for display.
4. Conclusion
The design scheme introduced in this paper is a drip detection system based on STM32
microcontroller. This system uses photoelectric sensors to detect the liquid level height. The
data obtained after measurement will be processed and analyzed by the STM32 microcontroller,
and finally displayed. Throughout the design process, it is necessary to continuously conduct
practical tests on the system to ensure that it can stably and accurately detect the dripping
speed in actual operation, and promptly issue alarms to remind of unreasonable issues.
References
[1] Chandrasekhar P T , Chakravarthi J S .Automatic Drip Irrigation System[J].[2024‐03‐24].
[2] Wavhal*1 M D N .Intelligent Drip Irrigation System[J].International Journal of Engineering Sciences
& Research Technology, 2014, 3(5).
[3] Kumar J , Luthra S K , Ratan R .Design & Development of Zigbee Based Automatic Drip Irrigation
system[J].[2024‐03‐24].
[4] Mahendra S , Bharathy M L .Microcontroller Based Automation of Drip Irrigation System[J].[2024‐
03‐24].
[5] Patel N R , Lanjewar R B , Mathurkar S S ,et al.Microcontroller based drip irrigation system using
smart sensor[C]//IEEE India Conference.IEEE, 2013.DOI:10.1109/indcon.2013.6726064.
[6] Ibrahim D , Saeed R R .Design and implementation of a microcontroller based infusion pump system
for automatic drug delivery[J].Global Journal on Technology, 2013.
[7] N V Gowtham DeekshithuluG Ravi BabuR Ganesh BabuM Siva Ramakrishna. Performance
Evaluation of Developed Low Cost Microcontroller BasedAutomated Drip Irrigation System[J].
Andhra Agricultural Journal, 2016, 63(3).
[8] Parameswaran G , Sivaprasath K , System P S I E .Arduino Based Smart Drip Irrigation System Using
Internet of Things[J]. [2024‐03‐24].
15
Scientific Journal of Technology Volume 6 Issue 4, 2024
ISSN: 2688‐8645
[9] Debnath M , Patel N .Performance of a Developed Low Cost Microcontroller based Automated Drip
Irrigation System in Kinnow Crop[J].[2024‐03‐24].
[10] Prabhu S R B , Sophia S , Mathew A I .A Review of Efficient Information Delivery and Clustering for
Drip Irrigation Management using WSN[J].Social Science Electronic Publishing[2024‐03‐24].
[11] Ruixia T , Jiaosai L , Yunjie L ,et al.Design of the Water Leakage Detection and Alarm System based
on EPICS[J]. 2017.
[12] Shiyong,Zheng,Zhao,et al.The design of liquid drip speed monitoring device system based on MCU
[C] //2017:20123‐20123.DOI:10.1063/1.4992940.
[13] Dutta P K , Mallikarjuna K , Satish A .Sensor based solar tracker system using electronic circuits for
moisture detection and auto‐irrigation[C]//IEEE International Conference on Power, Control,
Signals and Instrumentation Engineering.0[2024‐03‐24].DOI:10.1109/ ICPCSI. 2017.8391956.
[14] Capraro F , Tosetti S R , Manrique P L C .Sensor Network For Monitoring And Fault Detection In Drip
Irrigation Systems Based On Embedded Systems[J].IEEE Latin America Transactions, 2020,
18(2):383‐391.DOI:10.1109/TLA.2019.9082252.
[15] Wei‐Chao H , Lian‐Shuai H , Nan‐Hong P .Design of Intelligent Drip Irrigation System Based on
STM32[J].Journal of Anhui Agricultural Sciences, 2017.
16