Skip to content

Commit

Permalink
add absoluteHumidity + boiling functions (#20)
Browse files Browse the repository at this point in the history
- add **absoluteHumidity(TC, RH)** from relative humidity
- add **boilingFahrenheit(feet)** boiling temperature Fahrenheit at height in feet.
- add **boilingCelsius(meter)** boiling temperature Celsius at height in meter.
- add **boilingMeter(Celsius)** inverse function of above.
- add example
- update keywords.txt
- update readme.md
- update GitHub actions
- update license 2023
- minor edits
  • Loading branch information
RobTillaart committed Feb 18, 2023
1 parent be2c0c5 commit 89155e6
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 18 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.3.6] - 2023-02-17
- add **absoluteHumidity(TC, RH)** from relative humidity
- add **boilingFahrenheit(feet)** boiling temperature Fahrenheit at height in feet.
- add **boilingCelsius(meter)** boiling temperature Celsius at height in meter.
- add **boilingMeter(Celsius)** inverse function of above.
- add example
- update keywords.txt
- update readme.md
- update GitHub actions
- update license 2023
- minor edits


## [0.3.5] - 2022-11-26
- added RP2040 to build-CI
- simplified changelog
- optimized Steadman's formula (HeatIndex).
- update readme.md


## [0.3.4] - 2022-04-15
- fix #16 Split .h in .h and .cpp

Expand Down
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) 2017-2023 Rob Tillaart
Copyright (c) 2015-2023 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
64 changes: 56 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Note: pre-0.3.1 versions have incorrect heat-index.

## Interface

```cpp
#include "temperature.h"
```

### Conversion

Expand Down Expand Up @@ -65,6 +68,13 @@ Indicative table
| > 130 | > 54 | extreme hot | purple |


### Absolute Humidity

- **float absoluteHumidity(float Celsius, float relHumidity)**
Converts relative humidity and temperature to absolute humidity.
Return unit is grams/m3.


### WindChill

Wind speed @ 10 meter, if **convert** is true => wind speed will be converted to 1.5 meter
Expand All @@ -86,9 +96,33 @@ Indicative table (subjective).
| < -55 | serious dangerous |


### Boiling temperature water

When you are in the mountains the cooking point of water drops.
This can be so much that you can't boil an egg on mount Everest.

Temperature in F and C at which water cooks.
Based upon: https://en.wikipedia.org/wiki/High-altitude_cooking

- **boilingFahrenheit(feet)** boiling temperature Fahrenheit at height in feet.
- **boilingCelsius(meter)** boiling temperature Celsius at height in meter.
- **boilingMeter(Celsius)** returns height in meters for a given the boiling point in Celsius.
Note this is an approximation by reversing the formula.
Do not expect it to be very exact.


For Celsius from feet call:
```cpp
C = boilingCelsius(feet * 0.3048);
```
For Fahrenheit from meters call:
```cpp
F = boilingFahrenheit(meter * 3.2808); // * 3.280839895 == / 0.3048
```

----

# temperatureConverter class
# TemperatureConverter class

Since version 0.3.2 a temperature convertor class is added to convert to and from
other (less known) temperature scales.
Expand Down Expand Up @@ -118,6 +152,10 @@ prevents to have 8 x 7 optimized functions.

## Interface

```cpp
#include "temperature.h"
```

#### Constructor

- **temperatureConverter()** Constructor sets the default to zero degrees C.
Expand Down Expand Up @@ -158,14 +196,24 @@ See examples for typical usage.

# Future

#### must
#### Must

- split of TemperatureConversion class as a library of its own.
- 0.4.0

#### Should

#### should
- improve documentation
- add short explanation?
- add formula for water boiling height
- https://en.wikipedia.org/wiki/High-altitude_cooking
- multiMap needed?
- add short explanation per conversion unit?
- freeze/boil temps.
- unit tests
- absoluteHumidity
- boiling tests.

#### Could

- TEMPERATURE_VERSION => TEMPERATURE_LIB_VERSION
- when split of the converter? 0.4.0

#### could
#### Wont

73 changes: 73 additions & 0 deletions examples/boilingPoint_test/boilingPoint_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// FILE: boilingPoint_test.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for boiling point formula
// URL: https://github.com/RobTillaart/Temperature
//


#include "temperature.h"

uint32_t stop, start;


void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("TEMPERATURE_VERSION: ");
Serial.println(TEMPERATURE_VERSION);
Serial.println();

for (int meters = 0; meters < 5000; meters += 100)
{
Serial.print(meters);
Serial.print("\t");
Serial.print(boilingCelsius(meters));
Serial.print("\t");
Serial.print(boilingFahrenheit(meters * 3.2808));
Serial.print("\n");
}
Serial.println();


for (int feet = 0; feet <= 15000; feet += 100)
{
Serial.print(feet);
Serial.print("\t");
Serial.print(boilingCelsius(feet * 0.3048));
Serial.print("\t");
Serial.print(boilingFahrenheit(feet));
Serial.print("\n");
}
Serial.println();


for (float temp = 100; temp >= 80; temp -= 1)
{
Serial.print(temp);
Serial.print("\t");
Serial.print(boilingMeter(temp));
Serial.print("\n");
}
Serial.println();

for (float temp = 100; temp >= 98; temp -= 0.1)
{
Serial.print(temp);
Serial.print("\t");
Serial.print(boilingMeter(temp));
Serial.print("\n");
}
Serial.println();

}


void loop()
{

}


// -- END OF FILE --
10 changes: 10 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@ temperatureConverter KEYWORD1
Fahrenheit KEYWORD2
Celsius KEYWORD2
Kelvin KEYWORD2

dewPoint KEYWORD2
dewPointFast KEYWORD2
humidex KEYWORD2

heatIndex KEYWORD2
heatIndexC KEYWORD2

WindChill_F_mph KEYWORD2
WindChill_C_kmph KEYWORD2
WindChill_C_mps KEYWORD2

absoluteHumidity KEYWORD2

boilingFahrenheit KEYWORD2
boilingCelsius KEYWORD2
boilingMeter KEYWORD2



# temperatureConverter class
setKelvin KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/Temperature"
},
"version": "0.3.5",
"version": "0.3.6",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Temperature
version=0.3.5
version=0.3.6
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library with weather and temperature conversion functions.
Expand Down
45 changes: 42 additions & 3 deletions temperature.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//
// FILE: temperature.cpp
// VERSION: 0.3.5
// AUTHOR: Rob Tillaart
// VERSION: 0.3.6
// DATE: 2015-03-29
// PURPOSE: collection temperature functions
// URL: https://github.com/RobTillaart/Temperature


#include "temperature.h"
Expand Down Expand Up @@ -74,7 +76,7 @@ float humidex(float celsius, float dewPoint)
}


// 0.3.0 => https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
// 0.3.0 => https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
// previous https://en.wikipedia.org/wiki/Heat_index
// TF = temp in Fahrenheit
// RH = relative humidity in %
Expand Down Expand Up @@ -118,7 +120,7 @@ float heatIndex(float TF, float RH)
}


// 0.3.0 => https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
// 0.3.0 => https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
// previous https://en.wikipedia.org/wiki/Heat_index
// TC = temp in Celsius
// RH = relative humidity in %
Expand Down Expand Up @@ -148,6 +150,21 @@ float heatIndexC(float TC, float RH)
}


// https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/
// Absolute Humidity (grams/m3) = 6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 2.1674
// -----------------------------------------------
// (273.15+T)
float absoluteHumidity(float Celsius, float relHumidity)
{
float TC = Celsius;
float AH = (2.1674 * 6.112) * relHumidity;
AH *= exp((17.67 * TC)/(243.5 + TC));
AH /= (273.15 + TC);
return AH;
}



// https://en.wikipedia.org/wiki/Wind_chill
// US = Fahrenheit / miles / hour
// METRIC = Celsius / meter / hour (sec)
Expand Down Expand Up @@ -217,5 +234,27 @@ float altitudeToSeaLevel( float pressure, float celsius, float altitude)
}


// https://en.wikipedia.org/wiki/High-altitude_cooking
float boilingFahrenheit(float feet)
{
if (feet >= 0) return 212.1309 - feet * 1.86176954e-3;
return 212;
}


float boilingCelsius(float meter)
{
if (meter > 0) return 100.08143 - meter * 3.39670635e-3;
return 100;
}

// Celsius = 80..100
float boilingMeter(float Celsius)
{
if (Celsius >= 100) return 0;
return 29458.542 - Celsius * 294.34149;
}


// -- END OF FILE --

27 changes: 24 additions & 3 deletions temperature.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#pragma once
//
// FILE: temperature.h
// VERSION: 0.3.5
// AUTHOR: Rob Tillaart
// VERSION: 0.3.6
// DATE: 2015-03-29
// PURPOSE: collection temperature functions
// URL: https://github.com/RobTillaart/Temperature


#include "Arduino.h"


#define TEMPERATURE_VERSION (F("0.3.5"))
#define TEMPERATURE_VERSION (F("0.3.6"))


float Fahrenheit(float celsius);
Expand Down Expand Up @@ -56,6 +58,12 @@ float heatIndex(float TF, float RH);
float heatIndexC(float TC, float RH);


// https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/
// Absolute Humidity (grams/m3) = 6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 2.1674
// -----------------------------------------------
// (273.15+T)
float absoluteHumidity(float Celsius, float relHumidity);


// https://en.wikipedia.org/wiki/Wind_chill
// US = Fahrenheit / miles / hour
Expand Down Expand Up @@ -90,7 +98,20 @@ float altitudeToSeaLevel( float pressure, float celsius, float altitude);



/////////////////////////////////////////////////////////////
// https://en.wikipedia.org/wiki/High-altitude_cooking
// temperature at which water cooks
// 1 feet = 0.3048 meter
float boilingFahrenheit(float feet); // feet = 0..15000
float boilingCelsius(float meter); // meter = 0..4500

// inverse function
// Celsius = 80°..100°
float boilingMeter(float Celsius);




///////////////////////////////////////////////////////////////////////////////////////////////////
//
// TEMPERATURE CONVERTER CLASS
//
Expand Down

0 comments on commit 89155e6

Please sign in to comment.