Open tfppcn opened 4 years ago
The code to convert RH to AH is inaccurate.
ESP8266
The RHtoAbsolute(float relHumidity, float tempC) function to calculate absolute humidity is inaccurate double eSat = 6.11 * pow(10.0, (7.5 * tempC / (237.7 + tempC))); double vaporPressure = (relHumidity * eSat) / 100; double absHumidity = 1000 * vaporPressure * 100 / ((tempC + 273) * 461.5);
double eSat = 6.11 * pow(10.0, (7.5 * tempC / (237.7 + tempC)));
double vaporPressure = (relHumidity * eSat) / 100;
double absHumidity = 1000 * vaporPressure * 100 / ((tempC + 273) * 461.5);
Use this code instead double absHumidity = 216.7 * ((relHumidity / 100.0) * 6.112 * exp((17.62 * tempC) / (243.12 + tempC)) / (273.15 + tempC));
double absHumidity = 216.7 * ((relHumidity / 100.0) * 6.112 * exp((17.62 * tempC) / (243.12 + tempC)) / (273.15 + tempC));
The new code should return more accurate calculation for absolute humidity
What makes the original code inaccurate? Typecasting or other?
Assuming it's a formula you've found, where does your code originate?
Subject of the issue
The code to convert RH to AH is inaccurate.
Your workbench
ESP8266
Steps to reproduce
The RHtoAbsolute(float relHumidity, float tempC) function to calculate absolute humidity is inaccurate
double eSat = 6.11 * pow(10.0, (7.5 * tempC / (237.7 + tempC)));
double vaporPressure = (relHumidity * eSat) / 100;
double absHumidity = 1000 * vaporPressure * 100 / ((tempC + 273) * 461.5);
Expected behaviour
Use this code instead
double absHumidity = 216.7 * ((relHumidity / 100.0) * 6.112 * exp((17.62 * tempC) / (243.12 + tempC)) / (273.15 + tempC));
Actual behaviour
The new code should return more accurate calculation for absolute humidity