SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
dew_point.cpp
Go to the documentation of this file.
1#include "dew_point.h"
2
3namespace sensesp {
4
5// dew point
6
7void DewPoint::set(const float& /*input*/) {
8 // Dew point is calculated with Arden Buck Equation and Arden Buck valuation
9 // sets For more info on the calculation see
10 // https://en.wikipedia.org/wiki/Dew_point#Calculating_the_dew_point
11
12 float const temp_celsius = inputs[0] - 273.15;
13 float const relative_humidity = inputs[1];
14
15 // valuation set for temperatures above 0°C
16 float b = 17.368;
17 float c = 238.88;
18 const float d = 234.5;
19
20 // valuation set for temperatures below 0°C
21 if (temp_celsius < 0.0) {
22 b = 17.966;
23 c = 247.15;
24 }
25
26 float gamma =
27 log(relative_humidity *
28 exp((b - (temp_celsius / d)) * (temp_celsius / (c + temp_celsius))));
29 float const dew_point = (c * gamma) / (b - gamma);
30
31 this->emit(dew_point + 273.15); // Kelvin is Celsius + 273.15
32}
33
34} // namespace sensesp
virtual void set(const float &input) override
Definition dew_point.cpp:7
void emit(const float &new_value)