diff --git a/RaspberryPi/.gitignore b/RaspberryPi/.gitignore new file mode 100644 index 0000000..881a44b --- /dev/null +++ b/RaspberryPi/.gitignore @@ -0,0 +1,2 @@ +*.c~ +*.h~ diff --git a/RaspberryPi/calculate.c b/RaspberryPi/calculate.c new file mode 100644 index 0000000..2422868 --- /dev/null +++ b/RaspberryPi/calculate.c @@ -0,0 +1,83 @@ +#include +#include +#include /* link against math lib */ +#include "calculate.h" + + +/* +Bezeichnungen: +r = relative Luftfeuchte +T = Temperatur in °C +TK = Temperatur in Kelvin (TK = T + 273.15) +TD = Taupunkttemperatur in °C +DD = Dampfdruck in hPa +SDD = Sättigungsdampfdruck in hPa + +Parameter: +a = 7.5, b = 237.3 für T >= 0 +a = 7.6, b = 240.7 für T < 0 über Wasser (Taupunkt) +a = 9.5, b = 265.5 für T < 0 über Eis (Frostpunkt) + +R* = 8314.3 J/(kmol*K) (universelle Gaskonstante) +mw = 18.016 kg/kmol (Molekulargewicht des Wasserdampfes) +AF = absolute Feuchte in g Wasserdampf pro m3 Luft + +Formeln: + + SDD(T) = 6.1078 * 10^((a*T)/(b+T)) + DD(r,T) = r/100 * SDD(T) + r(T,TD) = 100 * SDD(TD) / SDD(T) + TD(r,T) = b*v/(a-v) mit v(r,T) = log10(DD(r,T)/6.1078) + AF(r,TK) = 10^5 * mw/R* * DD(r,T)/TK; AF(TD,TK) = 10^5 * mw/R* * SDD(TD)/TK +*/ + +float sdd(float temperature) { + //select constant based on input temperature + float a = 7.5, b = 237.3; + if (sensor->temperature >= 0) { + a = 7.6; + b = 240.7; + } + return 6.1078 * pow(10, (a*temperature) / (b*temperature)); +} + +float dd(float relativeHumidity, float temperature) { + return relativeHumidity / 100 * sdd(temperature); +} + +float r(float temperature, float dewTemperature) { + /* This is optional. Necessary with dew point measurements. */ + return 100 * sdd(dewTemperature) / sdd(temperature); +} + +//TD(r,T) = b*v/(a-v) mit v(r,T) = log10(DD(r,T)/6.1078) + +float v(float relativeHumidity, float temperature) { + log10(dd(relativeHumidity, temperature)/6.1078); +} + +float td(float relativeHumidity, float temperature) { + //select constant based on input temperature + float a = 7.5, b = 237.3; + if (sensor->temperature >= 0) { + a = 7.6; + b = 240.7; + } + return b * v(relativeHumidity, temperature) / (a - v(relativeHumidity, temperature)); +} + +float absoluteHumidity(sensor *sensor) { + //select constant based on input temperature + float a = 7.5, b = 237.3; + if (sensor->temperature >= 0) { + a = 7.6; + b = 240.7; + } + + + float sdd_T = sdd(sensor->temperature); + float dd = dd(sensor->humidity, sensor->temperature); + float relativeHumidity = r( + +} + diff --git a/RaspberryPi/calculate.h b/RaspberryPi/calculate.h new file mode 100644 index 0000000..e62bd13 --- /dev/null +++ b/RaspberryPi/calculate.h @@ -0,0 +1,4 @@ +/* Include guard */ +#include "dht22.h" + +double absoluteHumidity(sensor *sensor);