Arduino Historical Data

Hi. I have downloaded the historical data but the problem is the data set is too large. I did a monitoring for 31 days and I just want the data containing the daily average not every second. Is it possible?

Yes. Pseudo code for data.

int day; // day of the month
unsigned long dailyAverage[31]; // 31 daily averages
unsigned long dailyAccumulator; // add all data stored every second in one day
const unsigned long dailySeconds = 86400; // seconds per day
unsigned long currentData = 0; // data received

void setup() {}

void loop()
{
  .
  .
  if (currentData) // data received
  {
    dailyAccumulator += currentData; // accumulate the data
    secondsCount++; // count seconds per day
    currentData = 0; // reset data, wait for new data
  }
  .
  .
  if (secondsCount == dailySeconds)
  {
    dailyAverage[day] = dailyAccumulator / dailySeconds; // get the average for the day
    secondsCount = 0; // reset seconds/data
    day++; // new day
  }
  .
  .
  for (int i = 0; i < 31; i++)
  {
    Serial.println(dailyAverage[i]; // data dump
  }
}

Hi, may I ask where I can input this code?

It is pseudo code, meant to show the idea of storing a daily average of the data, and retrieving a month of averages. You know your code better than I do.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.