eLandon_Miix c14968ea64 added bmm150 in ahrs calculation, and smothing tries | hace 3 años | |
---|---|---|
.. | ||
examples | hace 3 años | |
src | hace 3 años | |
LICENSE | hace 3 años | |
README.md | hace 3 años | |
keywords.txt | hace 3 años | |
library.properties | hace 3 años |
An Arduino library to store and smooth sensor inputs using various methods including:
Unlike many other smoothing/filtering libraries, Smoothed uses a template class to ensure sensor readings in any numerical data type can be handled. This makes it both lightweight and flexible.
Smoothed can be installed from the Arduino IDE Library Manager. For more details on how to install libraries in the Arduino IDE, please see the Arduino website.
A full example of using each smoothing method is provided with the library and can be found in the Arduino IDE under "File->Examples->Smoothed".
Firstly, you must include the library in your sketch:
#include <Smoothed.h>
Next, create an instance of the class defining what data type to use. The example below uses a type of float:
Smoothed <float> mySensor;
You can replace float with any numeric data type to suit your sensor readings and desired accuracy. See the included library example for a full list of supported data types.
Within the setup function, initialize the instance, defining the smoothing method and accuracy:
mySensor.begin(SMOOTHED_AVERAGE, 10);
In the above example we are using a simple average of the last 10 sensor readings.
And finally, write in a new sensor value and read the smoothed result:
// Read a sensor value from analogue pin 0
mySensor.add(analogRead(SENSOR_PIN));
// Output the smoothed sensor value to the serial
Serial.println(mySensor.get());