In that program, I send the output to a tkinter window and use the high kwhr value to draw one of the needles on a meter.
However, occasionally there must be a spike or something in the system because it records an incorrect (high) value.
In order to overcome this, I would like to take average of (say) the last 5 values and use that calculation to do the comparison.
The code I use currently is shown below, so if the last value is less than 4 and it is higher than the previous high, the last value becomes the new high but I cannot work out the programming change to cover the proposed change to find an average.
Code: Select all
if float(kwhr) < 4: if float (kwhrlast) > float (kwhrhigh): kwhrhigh = kwhrlast