Skip to content

Commit

Permalink
Merge pull request #2 from RobTillaart/develop
Browse files Browse the repository at this point in the history
fix #1 added windchill functions
  • Loading branch information
RobTillaart authored May 26, 2020
2 parents 4244879 + e463506 commit 5fdeac5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
@@ -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":
[
Expand All @@ -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"
}
}
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=Temperature
version=0.2.0
version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
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=*
Expand Down
39 changes: 34 additions & 5 deletions temperature.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//
// FILE: temperature.h
// VERSION: 0.2.0
// VERSION: 0.2.1
// PURPOSE: temperature functions
//
// HISTORY:
Expand All @@ -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)
{
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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 --

0 comments on commit 5fdeac5

Please sign in to comment.