Display average of data points over the last hour?

Thanks for you help!

I am trying to aggregate sensor data over the last hour (or any period) to determine an uptime/downtime percentage using a vibration or electrical current sensor.

If checked once per second, what percentage of the last 3600 seconds was there vibration or more than X current draw? Assuming vibration means the machine is running, this would give us a uptime/downtime percentage from the last hour.

Is it possible to display data like this in Blynk?

You could use Superchart to show the data, but this has 1 minute and 6 hour granularity and doesn’t show averages.

I do something with my weather station where I hold values in an array for calculating average rainfall over the past hour and 24 hours. I accumulate the readings over a 1 minute period, giving me the 1 minute average, then write this into an array that has 60 elements 0-59). I leap a running total (so that 8 don’t have to keep re-calculating the total of the 60 values) and when the array is full
I read-in the oldest value, deduct that from the total, replace it with the newest reading then add that to the total. The total gives me cumulative rainfall over the past hour and dividing that by 60 gives me an average. Obviously the average is only valid once the array is fully populated.
I do the same with an array of 24 elements, writing the hourly average into it once per hour.

You could then use either labelled value widgets, Superchart, or a table to show the data (or a combination of both). I think in your situation I’d keep a peak value as well.

Pete.

2 Likes

Thanks Pete! I have been so stuck on data analyzing and storage on the server, I didn’t even think about coding the device to hold some basic information over time.

I’m very new to this but that will solve my issue. A few variables and a battery backup to keep them maintain during a power flicker will give me all the data I need.

Thank you again!

1 Like