The ideal grid voltage should be constant in amplitude, frequency and phase. Amplitude variation frequency fluctuation and waveform distortion are potential power quality problems. These will affect the normal operation of electrical equipment. Voltage sag i one of the prominent problems of voltage anomaly, so the existing detection algorithms focus on voltage sag. Other detection methods of voltage anomaly are less involved. For the above reasons, a voltage anomaly detection method based on least square fitting is proposed in this paper. By sampling and fitting the voltage waveform, the method obtains the four characteristic quantities of sinusoidal voltage, and compares them with the four characteristic quantities of standard sinusoidal voltage to judge whether they exceed the threshold value. Finally, this method can effectively detect the voltage anomaly.