Applying near infrared reflectance spectroscopy (NIRS) on farmlands can effectively estimate the total nitrogen (TN) content of soil online. We developed a NIRS-based portable detector of soil TN content that measures spectral data at 940, 1050, 1100, 1200, 1300, 1450, and 1550nm. The soil spectral data are sensitive to external environmental conditions, particularly soil moisture content and particle size. The interference of these factors on predicting soil TN content must be eliminated when using the portable detector. First, soil samples were collected from a farm in Beijing, China, and scanned using the detector to obtain their absorbance data under varying soil moisture and particle size. Second, absorbance correction method and mixed calibration set method were proposed to correct the original spectral data and to eliminate the interference of soil moisture and particle size, respectively. The absorbance of the soil sample at 1450nm exhibited a high correlation with soil moisture content. Thus, a moisture absorbance correction method (PMAI) was proposed to normalize the original spectral data into the standard spectral data and consequently eliminate the interference of soil moisture. A NIRS-based mixed calibration set based on the additivity of NIR spectra was produced with varying particle sizes, separated from the original soil samples, to eliminate the interference of soil particle size on the measurements of the portable soil TN detector. An estimation model of soil TN content was established based on the corrected absorbance data at six wavelengths (940, 1050, 1100, 1200, 1300, and 1550nm) using an algorithm of the back propagation neural network. The correlation coefficient of calibration, correlation coefficient of validation, root mean square error of calibration, root mean square error of prediction, and residual prediction deviation were used to evaluate the model. Compared with the model used the original spectral data, the accuracy and stability of the new model were significantly improved. These methods could efficiently eliminate the interference of soil moisture and particle size on predicting soil TN content.