Current measurment sync with pwm

Good day,

I have a brushed DC Motor and I want to measure the used current. For measuring I am using a ina219. The measurment is quite spiky and noisy. So I figured it also depends on the measurment timing due to the RL behavior of the Motor. Is it possible to sync the pwm with the i2c reading of the ina219? Or is there an easier way to smooth the measurment hardware side?


Do you have a 10nf cap directly across the motor terminals?

I have a 100nf cap across the terminals.

So I change the motor with a 6.8k Resistor and now I am measuring the current flowing from 5V to GND over the 6.8k resistor. Still it jumps from 0.8mA to 1.2mA. How can I improve the measurment?