The SimpleKalmanFilter class is designed for unidimensional models to process streams of single values (e.g., from barometric, temperature, or motion sensors).
To use the library, instantiate the class with three parameters:
e_mea (Measurement Uncertainty): How much you expect your measurement to vary.e_est (Estimation Uncertainty): Can be initialized with the same value as e_mea; the filter will adjust this value automatically.q (Process Variance): Represents how fast your measurement moves. Usually a small number between 0.001 and 1. A recommended starting value is 0.01. This should be tuned to your specific application.
Use the updateEstimate(x) method to pass a new measurement and receive the filtered estimate.
// Initialization
// e_mea: Measurement Uncertainty
// e_est: Estimation Uncertainty
// q: Process Variance (recommended 0.01)
SimpleKalmanFilter kf = SimpleKalmanFilter(e_mea, e_est, q);
while (1) {
float x = analogRead(A0);
float estimated_x = kf.updateEstimate(x);
// ... use estimated_x
}