You could look at code for a rolling average, either by maintaining a history of readings in an array, or simply by subtracting a fraction off a running total, and adding in the same fraction of each new reading.
runningTotal = (runningTotal - (runningTotal / timeConstant)) + (newReading / timeConstant);