A lightweight and fast signal smoothing library for the Arduino platform.
This library provides implementations of signal processing algorithms like:
- Simple Moving Average (
- Cumulative Moving Average (
- Exponential Moving Average (
- Savitzky Golay Filter (
- Ramer Douglas Peucker Algorithm (
- Kolmogorov Zurbenko Algorithm (
Use the standard process for Arduino libraries. The following steps are involved:
- Create a folder
librariesin your Sketchbook
- Git clone, or download and extract, this library in that folder. So, your sketchbook should have the following structure ->
/libraries/microsmooth/microsmooth.[cpp|h]and additional files.
- In your sketch, add
#include <microsmooth.h>and compile.
The library can be used as shown below:
- First, initialize the library:
uint16_t *history = ms_init(SMA);where
SMAcan be replaced with any of the three alphabet codes given above.
- Then, input your analog signal value using
intvariable, referred here as
- Pass the variable into the filter initialized in the first step:
int processed_value = sma_filter(channel_value, history);
- Repeat for input channel for a time domain signal.
- When done, deinit library with:
ms_deinit(history);(This releases the memory being utilized)
The filters all have the same interface:
<Three digit code>_filter(channel_value, history)
<Three digit code> can be
A simple code sample for using any of the filters in the library is available here.
The best performing filter at present is
EMA with alpha parameter
The ranking strategy for the filters is discussed in this paper.