Smoothing data / Rolling Average

Hey guys,

I’m using the emonlib with an arduino and an LCD screen in a fixture to calibrate the power draw of some LED lights I’ve been making. I’ve been getting some fluctuations in the wattage (+/- 3W) reported to the LCD and I would like to implement a rolling average to help smooth out the data. My question is, is there already an averaging function in emonlib that I can modify to get smoother results? I don’t want to write my own function if one already exists that I can modify.
My next question is, how much deviation do you typically see in the wattage reported by emonlib? Perhaps I am trying to cover up a hardware issue with a software band-aid.

I appreciate any feedback!

I assume you mean to average consecutive readings? No, there isn’t. But the values reported are all averages over the measuring period that you specified. EmonLib measure a short sample of current, defined by the number of zero crossings (if you’re measuring voltage as well) or the number of samples. You can change that and the longer the averaging time, the less fluctuation (and fewer readings) you will see. If you’re not measuring voltage, you should adjust the number of samples so that you get as close as possible to a whole number of complete mains cycles.

What is the fluctuation you’re seeing - 3 W in how many? 3 W in 24 kW is nothing. 3 W in 3 W might be a lot or it might be noise, depending on the maximum you have designed your system for.