Voltage drift over time in charge amplifiers is a problem not fully solved yet for DC measurements and continues to be a challenge for the scientific community. In this study we analyse the factors that cause this unwanted effect and propose a new method to compensate it. An automatic electronic circuit compensates the drift effect in two stages: first, a closed-loop proportional–integral control is used to bring the output voltage of the charge amplifier to zero and hold it while no measurement is being taken; and second, the voltage drift is compensated with an open-loop control when measurement is being taken. The proposed method allows us to compensate the voltage drift whatever its magnitude. Simulation and experimental results show that the drift effect in the output voltage of the charge amplifier is attenuated up to 99%.