diff --git a/LICENSE b/LICENSE index 3d51ae3..ed401f2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Rob Tillaart +Copyright (c) 2017-2020 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a78b695..e1d5d68 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # Temperature + Arduino library with dewPoint humidex and heatIndex functions. ## Description + This library contains some weather related functions. These functions are approximations based on work of NOAA a.o. These functions can be used with temperature and humidity sensors e.g. -to make a weather station application. +DHT22 or sensirion ones to make a weather station application. ## Operations diff --git a/library.json b/library.json index fc4075e..9c70a9f 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Temperature", - "keywords": "Temperature, Kelvin, Celsius, Fahrenheit, dewPoint, humidex, heatIndex", + "keywords": "Temperature, Kelvin, Celsius, Fahrenheit, dewPoint, humidex, heatIndex, windChill", "description": "Library with weather related functions.", "authors": [ @@ -15,10 +15,10 @@ "type": "git", "url": "https://github.com/RobTillaart/Temperature" }, - "version":"0.2.0", + "version":"0.2.1", "frameworks": "arduino", "platforms": "*", "export": { - "include": "libraries/Temperature" + "include": "Temperature" } } diff --git a/library.properties b/library.properties index e34da97..be2e582 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=Temperature -version=0.2.0 +version=0.2.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library with weather related functions. -paragraph=Kelvin Celsius Fahrenheit dewPoint humidex heatIndex +paragraph=Kelvin Celsius Fahrenheit dewPoint humidex heatIndex windChill category=Data Processing url=https://github.com/RobTillaart/Temperature architectures=* diff --git a/temperature.h b/temperature.h index 0fc5861..fb24d06 100644 --- a/temperature.h +++ b/temperature.h @@ -1,7 +1,7 @@ #pragma once // // FILE: temperature.h -// VERSION: 0.2.0 +// VERSION: 0.2.1 // PURPOSE: temperature functions // // HISTORY: @@ -10,8 +10,10 @@ // 0.2.0 - 2020-04-04 #pragma once, removed WProgram.h, readme.md, comments // replaced obsolete links with new ones, // tested and removed some code +// 0.2.1 2020-05-26 added windchill formulas +// -#define TEMPERATURE_VERSION "0.2.0" +#define TEMPERATURE_VERSION "0.2.1" inline float Fahrenheit(float celsius) { @@ -36,7 +38,7 @@ inline float Kelvin(float celsius) // calculation of the saturation vapor pressure part is based upon NOAA ESGG(temp) float dewPoint(float celsius, float humidity) { - // Calculate saturation vapor pressure + // Calculate saturation vapor pressure // ratio 100C and actual temp in Kelvin float A0 = 373.15 / (273.15 + celsius); // SVP = Saturation Vapor Pressure - based on ESGG() NOAA @@ -46,7 +48,7 @@ float dewPoint(float celsius, float humidity) SVP += 8.1328e-3 * (pow(10, (-3.49149 * (A0 - 1.0 ))) - 1.0 ) ; SVP += log10(1013.246); - // calculate actual vapor pressure VP; + // calculate actual vapor pressure VP; // note to convert to KPa the -3 is used float VP = pow(10, SVP - 3) * humidity; float T = log( VP / 0.61078); // temp var @@ -55,7 +57,7 @@ float dewPoint(float celsius, float humidity) // dewPointFast() is > 5x faster than dewPoint() - run dewpoint_test.ino -// delta mdewPointFastax with dewpoint() - run dewpoint_test.ino ==> ~0.347 +// delta mdewPointFastax with dewpoint() - run dewpoint_test.ino ==> ~0.347 // (earlier version mentions ~0.6544 but that testcode is gone :( // http://en.wikipedia.org/wiki/Dew_point float dewPointFast(float celsius, float humidity) @@ -122,5 +124,32 @@ float heatIndexC(float celcius, float humidity) return A + B + C; } +// https://en.wikipedia.org/wiki/Wind_chill +// US = Fahrenheit / miles +// METRIC = Celsius / meter/sec +// windspeed @ 10 meter, +// if convert is true => windspeed will be converted to 1.5 meter +// else ==> formula assumes windspeed @ 1.5 meter + +// US +float WindChill_F_mph(const float fahrenheit, const float milesPerHour, const bool convert = true) +{ + float windSpeed = milesPerHour; + if (convert) windSpeed = pow(milesPerHour, 0.16); + return 35.74 + 0.6125 * fahrenheit + (0.4275 * fahrenheit - 35.75) * windSpeed; +} + +// METRIC +float WindChill_C_mps(const float celcius, const float meterPerSecond, const bool convert = true) +{ + return WindChill_C_kmph(celsius, meterPerSecond * 3.6, convert); +} + +float WindChill_C_kmph(const float celcius, const float kilometerPerHour, const bool convert = true) +{ + float windSpeed = kilometerPerHour; + if (cconvert) windSpeed = pow(kilometerPerHour, 0.16); + return 13.12 + 0.6215 * celcius + (0.3965 * celcius - 11.37) * windSpeed; +} // -- END OF FILE --