rdz_ttgo_sonde
rdz_ttgo_sonde copied to clipboard
RS41 Humidity calculation
In RX_FSK/src/RS41.cpp, there's code based on https://github.com/einergehtnochrein/ra-firmware
Around line 648 the code is:
float Tp = (sensorTemp - 20.0f) / 180.0f;
float sum = 0;
float powc = 1.0f;
float p = pressure / 1000.0f;
for ( int i = 0; i < 3; i++) {
float l = 0;
float powt = 1.0f;
for ( int j = 0; j < 4; j++) {
l += calibration->value.matrixBt[4*i+j] * powt;
powt *= Tp;
}
float x = calibration->value.vectorBp[i];
sum += l * (x * p / (1.0f + x * p) - x * powc / (1.0f + x));
powc *= Cp;
}
Cp -= sum;
// Should sum be set to 0 here?
float xj = 1.0f;
for ( int j = 0; j < 7; j++) {
float yk = 1.0f;
for ( int k = 0; k < 6; k++) {
sum += xj * yk * calibration->value.matrixU[j][k];
yk *= Tp;
}
xj *= Cp;
}
float RH = sum
However, in the original version of the code https://github.com/einergehtnochrein/ra-firmware/blob/master/src/rs41/rs41metrology.c at line 271, sum is set to 0 between the two loops, but that seems to be missing here.