Traditional electric energy metering system sampling the power grid signal by electronic energy meter, the meter designed the frequency tracking circuit, under the condition of the power grid waveform frequency fluctuation can be synchronous sampling, electricity measurement error is small, in digital power metering system the A/D sampling module have a fixed frequency in the merging unit, and it can not real-time tracking grid frequency synchronous sampling, under the condition of frequency fluctuation, electricity measurement error is bigger, therefore, in order to reduce the error of electricity energy metering, this paper proposes A new algorithm of digital power metering, the method by using the Lagrange interpolation algorithm to extract the power grid frequency, and by using the fence effect of discrete Fourier transform algorithm to extract the waveform component, realize the energy calculation, this method is simple, through the experimental simulation verified its electricity measurement error is small, has A practical value.