Handheld X-ray fluorescence spectrometers have been widely used in the detection of elemental content in ore exploration. In this study, a miniaturized tube-excited X-ray fluorescence measurement instrument was designed to meet the lightweight needs of instruments for ore exploration. On this basis, the wavelet denoising algorithm and polynomial fitting method are used to optimize the XRF meter spectra in order to enhance its anti-interference ability. The XRF instrument was applied to detect the heavy metal elements in the ore, and it was found that the optimized XRF instrument spectrum obtained good denoising effect, which effectively smoothed the spectrum and reduced the background interference, and the coefficient of determination of the instrument was improved to 0.9598-0.9972, which indicated that the linear relationship between the content of each heavy metal element in the ore samples and the intensity of the characteristic peaks of X-ray fluorescence spectra was good. Meanwhile, it is verified that the optimized instrument has good precision and correctness, the relative standard deviation is enhanced to 1.17%~4.29%, and the relative error is reduced to 0.21%~2.43%, which can be applied in the field rapid screening of practical ore exploration.