Abstract:High-precision detection of harmful gases is urgently required in key sectors, such as livestock farming, agricultural product quality monitoring, and industrial environmental management. However, fluctuations in indoor ambient temperature and humidity can lead to frequency drift in gas sensors, thereby affecting detection accuracy. To address this issue, electromagnetic simulations are conducted to analyze the electromagnetic loss characteristics of the microstrip resonator, thereby identifying the optimal coating position for the gas-sensitive material and enhancing the microwave sensor′s sensitivity to ammonia. Furthermore, the correlation between the sensor′s radiation gain and ammonia concentration. A wireless ammonia detection system based on a wireless power transmission model is constructed. By utilizing the detection principles of radio frequency identification, an experimental platform is developed to test sensor performance under various temperature and humidity conditions. The back propagation (BP) neural network temperature-humidity compensation algorithm is introduced to the model, analyze, and correct the frequency drift caused by environmental variations, combined with Pearson correlation analysis. Experimental results indicate that temperature and humidity significantly affect the microwave ammonia sensor′s frequency stability. After compensation, the frequency drift amplitude is reduced by 14 MHz, the concentration error is decreased to 0.06×10-6, and the relative error is limited to 2%, resulting in a 31.11% improvement in gas detection accuracy. Compared with the temperature compensation model of the BP network or the temperature-humidity compensation model of the support vector machine, the proposed method demonstrates superior performance. In conclusion, this research effectively enhances the detection accuracy of microwave ammonia gas sensors under complex temperature and humidity environmental conditions. It provides a more robust technical foundation for high-precision harmful gas monitoring.