0.3.1 Temperature

This commit is contained in:
rob tillaart 2022-01-07 09:05:22 +01:00
parent e8e9103a90
commit ac5a35fbbc
6 changed files with 62 additions and 5 deletions

View File

@ -28,7 +28,7 @@ void setup()
Serial.println();
Serial.println();
for (int hum = 40; hum <= 100; hum += 5)
for (int hum = 0; hum <= 100; hum += 2)
{
Serial.print(hum);
for (int t = 80; t <= 110; t += 2)
@ -42,6 +42,22 @@ void setup()
Serial.println();
Serial.println();
/*
for (int hum = 40; hum <= 100; hum += 5)
{
Serial.print(hum);
for (int t = 80; t <= 110; t += 2)
{
float hi = heatIndex(t, hum);
Serial.print("\t");
Serial.print(round(hi));
}
Serial.println();
}
Serial.println();
Serial.println();
*/
Serial.print("Done...");
}

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/Temperature"
},
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=Temperature
version=0.3.0
version=0.3.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library with weather related functions.

View File

@ -19,6 +19,8 @@ These functions are approximations based on work of NOAA a.o.
These functions can be used with temperature and humidity sensors e.g.
DHT22 or Sensirion, to make a weather station application.
Note: pre-0.3.1 versions have incorrect heat-index.
## Interface
@ -42,7 +44,9 @@ DHT22 or Sensirion, to make a weather station application.
- **float heatIndex(float Fahrenheit, float humidity)** idem.
- **float heatIndexC(float Celsius, float humidity)** idem.
**0.3.0**
#### 0.3.0
The formula for the **heatIndex()** was taken from https://en.wikipedia.org/wiki/Heat_index.
Since version 0.3.0 the more elaborated version of https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
will be used. Note: there will be performance differences.
@ -57,6 +61,10 @@ Indicative table
| 105-129 | 40-54 | very hot | red |
| > 130 | > 54 | extreme hot | purple |
#### 0.3.1
Fixed the adjustment which was incorrectly added.
### WindChill

View File

@ -117,7 +117,7 @@ float heatIndex(float TF, float RH)
HI = A + B + C;
if ((RH < 13) && (TF <= 112))
{
HI += ((13 - RH) / 4) * sqrt((17 - abs(TF - 95.0)) / 17);
HI -= ((13 - RH) / 4) * sqrt((17 - abs(TF - 95.0)) / 17);
}
if ((RH > 87) && (TF < 87))
{

View File

@ -75,6 +75,39 @@ unittest(test_heatIndex)
}
unittest(test_heatIndex_2)
{
// Fahrenheit reference points
assertEqualFloat( 77, heatIndex(80, 00), 1);
assertEqualFloat( 78, heatIndex(80, 10), 1);
assertEqualFloat( 80, heatIndex(80, 40), 1);
assertEqualFloat( 82, heatIndex(80, 60), 1);
assertEqualFloat( 86, heatIndex(80, 90), 1);
assertEqualFloat( 89, heatIndex(80, 100), 1);
fprintf(stderr, "\n");
assertEqualFloat( 84, heatIndex(90, 00), 1);
assertEqualFloat( 85, heatIndex(90, 10), 1);
assertEqualFloat( 91, heatIndex(90, 40), 1);
assertEqualFloat(100, heatIndex(90, 60), 1);
assertEqualFloat(122, heatIndex(90, 90), 1);
assertEqualFloat(132, heatIndex(90, 100), 1);
fprintf(stderr, "\n");
assertEqualFloat( 91, heatIndex(100, 00), 1);
assertEqualFloat( 94, heatIndex(100, 10), 1);
assertEqualFloat(109, heatIndex(100, 40), 1);
assertEqualFloat(129, heatIndex(100, 60), 1);
assertEqualFloat(176, heatIndex(100, 90), 1);
assertEqualFloat(195, heatIndex(100, 100), 1);
fprintf(stderr, "\n");
assertEqualFloat( 99, heatIndex(110, 00), 1);
assertEqualFloat(104, heatIndex(110, 10), 1);
assertEqualFloat(136, heatIndex(110, 40), 1);
assertEqualFloat(171, heatIndex(110, 60), 1);
assertEqualFloat(247, heatIndex(110, 90), 1);
assertEqualFloat(278, heatIndex(110, 100), 1);
}
unittest(test_windChill)
{
assertEqualFloat(107.108, WindChill_F_mph (100, 10, true), 0.001);