In recent years, we have vigorously developed new energy power generation to help reduce carbon emissions in the power grid and respond to the national dual carbon goals. However, the grid connection of new energy generation will generate a large number of harmonics, leading to many problems in traditional energy metering schemes. In the paper, we propose an improved bi-directional metering method with harmonic detection. Firstly, an improved harmonic detection method with a Blackman window is proposed for a large number of harmonics present in the grid. Then, based on the harmonic detection results, a new energy measurement scheme is constructed, in which the strategies of user compensation and harmonic penalty are considered, and a new solution for user electricity billing is provided. Finally, the effectiveness and applicability were verified through numerical analysis.