Hi,

I have come across a nice Arduino library for the Kalman noise filter but don't know how to use it.... wondering if anyone out there does? My sketch is measuring temperature every x seconds and I would like to smooth out the noise a bit :-)

FilteringScheme.h

`#ifndef FilteringScheme_h`

#define FilteringScheme_h

//inspired by interactive-matter

class KalmanFilter {

public:

KalmanFilter();

KalmanFilter(float q, float r, float p, float intial_value);

void KalmanInit(float q, float r, float p, float intial_value);

void set_q(float _q);

void set_r(float _r);

float q; //process noise covariance

float r; //measurement noise covariance

float x; //value

float p; //estimation error covariance

float k; //kalman gain

float intial_value;

float measureRSSI(float raw_rssi);

};

#endif //FilteringScheme_h

FilteringScheme.cpp

`#include "FilteringScheme.h"`

KalmanFilter::KalmanFilter() {}

KalmanFilter::KalmanFilter(float _q, float _r, float _p, float _intial_value) {

q = _q;

r = _r;

p = _p;

intial_value = _intial_value;

}

void KalmanFilter::KalmanInit(float _q, float _r, float _p, float _intial_value) {

q = _q;

r = _r;

p = _p;

intial_value = _intial_value;

}

float KalmanFilter::measureRSSI(float raw_rssi) {

p = p+q;

k = p/(p+r)*1.0;

x = x+k*(raw_rssi - x);

p = (1 - k)*p*1.0;

return x;

}

void KalmanFilter::set_q(float _q) {

q = _q;

}

void KalmanFilter::set_r(float _r) {

r = _r;

}