Normalize the sensors data

Arduino with an SD card, real-time clock module, and temperature sensor. The Arduino reads temperature data every second and I want to save these readings to the SD card module along with a timestamp, at one-minute intervals. The one-minute value will be derived from 60 seconds of readings, where the highest reading from each 10-second interval is selected, and then the average of the highest six values over 60 seconds is saved to the SD card module along with a timestamp.
kindly help me in normalizing the values

what do you mean by normalizing?

and why not just collect the raw data you describe and do any averaging when processing it?

is the temperature likely to change rapidly? why no just record the timestamp/temperature when it changes by 0.1 deg?

1 Like

Hi, @AliGul1234567890

What is the application that needs rapid temperature logging?

What model Arduino are you using?
Have you got code working to read the temperature sensor?
Have you got code working that writes and reads from the SD card?
Have you got code that reads the RTC?

Do you have any code?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

1 Like

Yes, I have all these codes, but I need the function to store the highest value of 10 seconds and the six highest values of 60 seconds. Then, I need to calculate the average of these six values to obtain a one-minute normalized value and store one minute value into the SD card

Yes, I have all these codes, but I need the function to store the highest value of 10 seconds and the six highest values of 60 seconds. Then, I need to calculate the average of these six values to obtain a one-minute normalized value and store the minute value in the SD card

so you mean the average max in each minute?

"normalize" typically mean some proportion to a reference value (i.e value / refernce)

Arduino Uno

Seems fairly simple.

Use an array to save the sixty samples during the one-minute interval.

Go through each ten-second period to find the highest values during those.

Then sort the sixty samples to find the highest six values.

Look for RunningMedian library, you have lot of useful functions there, just what you need:
https://github.com/RobTillaart/RunningMedian

This is a bit confusing, are the highest values from each ten-second interval and the six highest values from the 60-second period going to be averaged separately and both saved to SD card, or are you referring to the same six numbers with only a single average?

@noobmastha brings up another point, what type average do you want, mean, medium, or mode?

See if this works for you


  int i, j;
  unsigned long average=0;
  unsigned long temperatures [60];
  unsigned long max_temps [6] {0, 0, 0, 0, 0, 0};

  for (i = 0; i < 6; i++)
  {
    for (j = 0; j < 10; j++)
    {
      max_temps[i] = max(max_temps[i], temperatures [(i * 10) + j]);
    }
  }

  for (i = 0; i < 6; i++)
  {
    average = average + max_temps[i];
    Serial.println(max_temps[i]);
  }
  average = average / 6;
  Serial.println();
  Serial.println(average);
}



1 Like

yes i need the Max average of each minutes

Yes I need only the highest average of 60-second values and i am interested only in the highest values

That still is a very confusing description.

Assuming you want to take the highest temperature from each ten-second period, then at the end of each minute calculate the average of those six values, you could do something like this:

During each ten-second period, record the highest temperature.

At the end of each ten-second period, add the high temperature to a cumulative total for the minute. (also reset highest temperature reading)

At the end of each minute, divide the cumulative total by six to get the average over the minute. (set cumulative total back to 0)

simple 60-second data in one minute and 1 highest values from 10 seconds of data. and the total 6 highest values from 60 seconds of data then add the 6 values and divide by 6. I need that function code for this part only

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