The charger’s operation in the power grid will cause harmonic pollution, affecting the service life of the equipment and the quality of the power grid. The harmonic characteristics and detection during the charging process are studied. The simulation model of charger is established first using MATLAB, the results of the experiment show that odd harmonics are mainly generated during charging, and the distortion rate of the current harmonics remains between 0.231 and 0.443 during the charging process. A new wavelet neural network is proposed to detect the harmonic method. Experimental results indicate that, compared with previous detection methods, this network has better detection efficiency and accuracy for harmonics. But detection result of this network is unstable and does not even converge. A new adaptive bat algorithm with improved focusing distance is presented here to optimize the wavelet neural network, which effectively solves the defect of being sensitive to the node number of hidden layer, resulting in higher detection accuracy, faster detection speed, and stable convergence. The detection error range is reduced from −0.03 to 0.02, and the number of iterations is reduced to around 1000.