Hi, I am getting sets of data strings from a sensor that I would like to average as new data comes out. Would the average library allow me to do this, if so how can I get individual data points using the ave.push function?, Thanks.
Hi, I am getting sets of data strings from a sensor that I would like to average as new data comes out. Would the average library allow me to do this, if so how can I get individual data points using the ave.push function?, Thanks.
Here´s the code. Waht I need to do is get an average for X number of outputs coming from each individual channel. Similarly I want to be able to print out the group of data being averaged.
Thanks.
#include <Wire.h>
#include "Adafruit_TCS34725.h"
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_101MS, TCS34725_GAIN_4X);
void setup(void)
{
Serial.begin(9600);
if (tcs.begin())
{
Serial.println("Found sensor");
}
else
{
Serial.println("No TCS34725 found ... check your connections");
while (1);
}
}
void loop(void)
{
uint16_t r, g, b, c, colorTemp, lux;
tcs.getRawData(&r, &g, &b, &c);
Serial.print(r,DEC); Serial.print(","); Serial.print(g,DEC); Serial.print(",");
Serial.print(b,DEC); Serial.print(","); Serial.println(c,DEC);
delay(1000);
}
Alejandro, yes you can use the averages library for this.
Have a look at the example https://github.com/MajenkoLibraries/Average/blob/master/examples/AverageExample/AverageExample.ino
You should be able to merge that in with your current code.
Looking at how push works you can keep adding values and it keeps the last X and throws away the oldest values.