If you’re looking to get rid of a very occasional spike, use a 1D median filter. It’s a very good filter which introduces minimal delay and is bog-simple to implement.
If it’s really just a single data point then you can get away with a 3 sample filter, which will introduce at most a 2 sample delay, but realistically the delay will hover around 0-1 samples.
So assuming that your original data series was:
0.1, 0.2, 0,1, 0.3, 2.0, 0.1, 0.2, 0,1, 0.3
then the output of a three sample median filter would be:
0.1, 0.2, 0.1, 0.2, 0.3, 0.3, 0.2, 0.1, 0.2
Afterwards, you can pass it through an 8-sample averaging filter:
0.1, 0.15, 0.133, 0.18, 0.24, 0.2, 0.2, 0.1875, .2
Which will give you a much better average now that you’ve thrown out the outliers.
Another approach is to average together a long window throwing out the max and min value as outliers, but in your case if your minimum values are reliable and only your maximum values are unreliable than you could do something like throw out the peak value (or peak two values, or three, or four, etc…) before taking your average. Either filter will work much better than simply averaging in known erroneous data.