Added running average methods to determine if we should send temperature / humidity reports
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// FILE: runningAverageMinMaxTest.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.00
|
||||
// DATE: 2015-apr-10
|
||||
//
|
||||
// PUPROSE: demo
|
||||
//
|
||||
|
||||
#include "RunningAverage.h"
|
||||
|
||||
RunningAverage myRA(10);
|
||||
int samples = 0;
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("\nDemo runningAverageMinMaxTest");
|
||||
Serial.print("Version: ");
|
||||
Serial.println(RUNNINGAVERAGE_LIB_VERSION);
|
||||
myRA.clear(); // explicitly start clean
|
||||
|
||||
Serial.println("\nCNT\tMIN\tAVG\tMAX");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
long rn = random(0, 1000);
|
||||
myRA.addValue(rn * 0.001);
|
||||
samples++;
|
||||
Serial.print(samples);
|
||||
Serial.print("\t");
|
||||
Serial.print(myRA.getMin(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(myRA.getAverage(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.println(myRA.getMax(), 3);
|
||||
|
||||
if (samples == 100)
|
||||
{
|
||||
samples = 0;
|
||||
myRA.clear();
|
||||
Serial.println("\nCNT\tMIN\tAVG\tMAX");
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
Reference in New Issue
Block a user