Project Requirements
: 1. This design utilizes a control system comprised of an AG32VF303 CPLD microcontroller and an ESP8266 WIFI module.
2. The infusion set has three different functions, controlled via independent buttons and mobile WIFI switching.
3. Functions such as infusion drip rate control, drug solution temperature control, and low-level alarm are achieved through button control and WIFI communication.

Project Analysis
Requirements: When the infusion temperature is low, an alarm and warming action are required; the drip rate needs to be controlled using a stepper motor, with clockwise rotation increasing the drip rate and counterclockwise rotation decreasing it; when the solution level is low, the stepper motor needs to be controlled to rotate to the appropriate position to stop the infusion and trigger an alarm, etc.
Overall Design Scheme Block Diagram:

Schematic Design Description
1. Hardware Design: The AG32VF303 CPLD microcontroller is selected as the core processor of the system, and sensor modules are selected according to requirements for the acquisition of infusion parameters:
DS18B20 is a commonly used high-precision single-bus digital temperature measurement sensor with a temperature range of -55℃ to +125℃ and an error of ±0.4° within the range of -10℃ to +85℃. It does not require any external components and can complete the work independently;
FTR9606 is a high-sensitivity slot-type optocoupler with a slot width of 5mm. Its output signal is compared by an LM393 comparator, which can achieve a high level output when there is obstruction and a low level output when there is no obstruction. A high-low level change is a pulse. Take N pulses, calculate the interval time between each pulse, and calculate the average time interval between each pulse. Finally, convert it into a drip rate value in units of (drops/min);
Water level sensor, which works by using five exposed traces connected to the system ground. A sensing trace is interleaved between every two ground traces, for a total of five ground traces and five sensing traces. The sensing traces are connected to a 1-megohm pull-up resistor. The sensing traces are pulled high until a drop of water or a horizontal surface grounds them. Theoretically, this sensor will output an analog signal between 0 and 1024. This signal, after being compared by an LM393 comparator, can output a high level at a specific water level to detect the presence of medication. Considering portability requirements, most components are surface-mount devices, and a lithium battery is included for operation without an external power source.
2. Communication Module: Wireless transmission via ESP8266 WIFI module using AP mode facilitates data observation by medical staff, ensuring stable and reliable data transmission.
PCB Design Notes:
The board size is controlled within 10x10cm, using a 10x8.9cm FR4 PCB.

Software Notes:
The attached software designs the basic components but does not yet include EEPROM memory.
The following is the main program flowchart:

Note that
resistor R16 in this project should ideally be replaced with a 130kΩ resistor to ensure 5V output. The lithium battery charge/discharge module has not been verified; similar modules can be purchased directly.
Other attachments are available in
the project attachments, including some source code and a mobile app.