Advertisement
pavelsayekat

dew point function

Oct 15th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. double BME280::dewPoint(void)
  2. {
  3. double celsius = (double)readTempC();
  4. double humidity = (double)readFloatHumidity();
  5. // (1) Saturation Vapor Pressure = ESGG(T)
  6. double RATIO = 373.15 / (273.15 + celsius);
  7. double RHS = -7.90298 * (RATIO - 1);
  8. RHS += 5.02808 * log10(RATIO);
  9. RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;
  10. RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
  11. RHS += log10(1013.246);
  12.  
  13. // factor -3 is to adjust units - Vapor Pressure SVP * humidity
  14. double VP = pow(10, RHS - 3) * humidity;
  15.  
  16. // (2) DEWPOINT = F(Vapor Pressure)
  17. double T = log(VP/0.61078); // temp var
  18. return (241.88 * T) / (17.558 - T);
  19. }
  20.  
  21. // delta max = 0.6544 wrt dewPoint()
  22. // 6.9 x faster than dewPoint()
  23. // reference: http://en.wikipedia.org/wiki/Dew_point
  24. double BME280::dewPointFast(void)
  25. {
  26. double celsius = (double)readTempC();
  27. double humidity = (double)readFloatHumidity();
  28. double a = 17.271;
  29. double b = 237.7;
  30. double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
  31. double Td = (b * temp) / (a - temp);
  32. return Td;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement