SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
air_density.cpp
Go to the documentation of this file.
1#include "air_density.h"
2
3#include "math.h"
4
5namespace sensesp {
6
7// dew point
8
10
12 inputs[inputChannel] = input;
13 received |= 1 << inputChannel;
14 if (received ==
15 0b111) { // for 2 channels, use 0b11. For 3 channels, use b111 and so on.
16 received = 0; // recalculates after all values are updated. Remove if a
17 // recalculation is required after an update of any value.
18
19 // For more info on the calculation see
20 // https://en.wikipedia.org/wiki/Density_of_air
21
22 float temp_kelvin = inputs[0];
23 float temp_celsius = temp_kelvin - 273.15;
24 float relative_humidity = inputs[1];
25 float pressure = inputs[3];
26
27 // Saturation vapor pressure of water
29 6.1078 * pow(10, ((7.5 * temp_celsius) / (temp_celsius + 237.3)));
30
31 // Vapor pressure of water
33
34 // Partial pressure of dry air
36
37 // air density of humid air
38 // const float specific_gas_constant_dry_air = 287.058;
39 // const float specific_gas_constant_water_vapor = 461.495;
40 const float molar_mass_dry_air = 0.0289652;
41 const float molar_mass_water_vapor = 0.01801;
42 const float universal_gas_constant = 8.31446;
47
48 this->emit(air_density_humid_air);
49 }
50}
51
52} // namespace sensesp
virtual void set_input(float input, uint8_t inputChannel) override
Construct a new transform based on a single function.