Skip to content

Commit

Permalink
fix adjustment (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Jan 7, 2022
1 parent 9354eab commit c45965e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand All @@ -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

Expand Down
16 changes: 16 additions & 0 deletions examples/heatindex_table/heatindex_table.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ void setup()
Serial.println();
Serial.println();

for (int hum = 0; hum <= 100; hum += 2)
{
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();

/*
for (int hum = 40; hum <= 100; hum += 5)
{
Serial.print(hum);
Expand All @@ -41,6 +56,7 @@ void setup()
}
Serial.println();
Serial.println();
*/

Serial.print("Done...");
}
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.0",
"version": "0.3.1",
"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.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.
Expand Down
2 changes: 1 addition & 1 deletion temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
33 changes: 33 additions & 0 deletions test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c45965e

Please sign in to comment.