Transfer function in the sheet:
Transfer Function:
Vout = VS × (0.2 × P(kPa)+0.5) ± 6.25% VFSS
VS = 5.0 Vdc
TA = 10 to 60°C
IS this code correct now?
#include <SimpleKalmanFilter.h> // get from: GitHub - denyssene/SimpleKalmanFilter: A basic implementation of Kalman Filter for single variable models.
SimpleKalmanFilter DPKalmanFilter(50, 50, 0.01);
/*
SimpleKalmanFilter pressureKalmanFilter(e_mea, e_est, q);
e_mea: Measurement Uncertainty - How much do we expect to our measurement vary
e_est: Estimation Uncertainty - Can be initilized with the same value as e_mea since the kalman filter will adjust its value.
q: Process Variance - usually a small number between 0.001 and 1 - how fast your measurement moves. Recommended 0.01. Should be tunned to your needs.
*/
const long SERIAL_REFRESH_TIME = 10;
long refresh_time;
int DPPin = A0;
float vout;
float DP;
float DP_kalman;
float rho = 1.225; //ISA density in kg/m3.
float V_IAS;
float V_kmh;
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
vout = analogRead(DPPin); // read the input pin
DP = 1000*((vout+0.625*Vfss)/1023.00) -0.5)/0.2 ; // Transfer function converted in Pa (Check datasheet page 6)
DP_kalman = DPKalmanFilter.updateEstimate(DP);
V_IAS = sqrt(2*DP/rho); // Indicated Air Speed in m/s. This is not TRUE!!! If you want true, get a static pressure port and a temperature probe. Something like the BMP280.
V_kmh = V_IAS * 3600; //km/h
if (millis() > refresh_time) {
Serial.print(DP);
Serial.print(",");
Serial.print(DP_kalman);
Serial.print(",");
Serial.print(V_IAS);
Serial.print(",");
Serial.print(V_kmh);
Serial.println();
refresh_time=millis()+SERIAL_REFRESH_TIME;
}
}