SensESP 2.7.2
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
8
10 inputs[inputChannel] = input;
11 received |= 1 << inputChannel;
12 if (received ==
13 0b11) { // for 2 channels, use 0b11. For 3 channels, use b111 and so on.
14 received = 0; // recalculates after all values are updated. Remove if a
15 // recalculation is required after an update of any value.
16
17 // Dew point is calculated with Arden Buck Equation and Arden Buck valuation
18 // sets For more info on the calculation see
19 // https://en.wikipedia.org/wiki/Dew_point#Calculating_the_dew_point
20
21 float temp_celsius = inputs[0] - 273.15;
22 float relative_humidity = inputs[1];
23
24 // valuation set for temperatures above 0°C
25 float b = 17.368;
26 float c = 238.88;
27 const float d = 234.5;
28
29 // valuation set for temperatures below 0°C
30 if (temp_celsius < 0.0) {
31 b = 17.966;
32 c = 247.15;
33 }
34
35 float gamma =
37 (temp_celsius / (c + temp_celsius))));
38 float dew_point = (c * gamma) / (b - gamma);
39
40 this->emit(dew_point + 273.15); // Kelvin is Celsius + 273.15
41 }
42}
43
44} // namespace sensesp
virtual void set_input(float input, uint8_t inputChannel) override
Definition dew_point.cpp:9
Construct a new transform based on a single function.