China has had the highest fertilizer use rate in the world for years, but today a large number of farmlands still use traditional manual fertilizer application methods, which rely entirely on personal experience and not only cause the waste of fertilizer and water resources but also make the local ecological environment polluted. This paper researches and designs a BP neural network PID controller based on PSO optimization to address the above problems. The PSO algorithm is used to optimize the initial weights of the BP neural network, and then optimize the control parameters of the PID to achieve accurate control of the liquid fertilizer flow. A precision fertilizer control system based on the STM32 microcontroller was also developed, and the performance of this controller was verified in tests. The results showed that compared with the conventional PID controller and BP neural network-based PID controller, this controller had good control accuracy and robustness, the average maximum overshoot was 6.35%, and the average regulation time was 41.17 s; when the fertilizer application flow rate was 0.6 m3/h, the shortest adjustment time is 30.85 s, which achieves the effect of precise fertilizer application.