Aiming at the conventional quantitative continuous application method of greenhouse hanging crops, the spray equipment cannot automatically adjust the spray flow according to the crop gap and density, which is easy to cause pesticide waste and environmental pollution. A greenhouse target variable spray control system based on fuzzy PID control algorithm is designed. The system uses STM32 microcontroller as the control center, and uses multi-sensor real-time monitoring of crop height, density, spray flow and other information as the control basis. The fuzzy inference of the fuzzy controller is used to adjust the PID parameters online and real-time to achieve precise adjustment of the drug return flow. The response time, overshoot and stability time of the existing variable spraying control algorithm are optimized to achieve the precise control of the target variable spraying in the greenhouse. In order to verify the superiority of fuzzy PID control algorithm in greenhouse target variable spray control system, the traditional PID and fuzzy PID control algorithms are modeled and simulated in Simulink platform. The results show that the lag time of fuzzy PID control is shortened by 0.62 s, the maximum overshoot is reduced by 15.2 %, and the stability time is shortened by 1.31 s. In the actual spraying operation of the greenhouse, the target variable sprayer based on the fuzzy PID control algorithm saves the amount of drug by 31.3 % compared with the conventional continuous spraying, and saves the amount of drug by 1.9 % compared with the traditional PID control algorithm.