0.2.5 Temperature

This commit is contained in:
rob tillaart 2021-12-28 19:11:26 +01:00
parent 091e1c673a
commit 67780741b7
15 changed files with 90 additions and 60 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
- leonardo
- m4
- esp32
- esp8266
- mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017-2021 Rob Tillaart
Copyright (c) 2017-2022 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

View File

@ -1,7 +1,6 @@
//
// FILE: dewpoint_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-04
@ -16,6 +15,7 @@ uint32_t duration2;
float maxError;
volatile float dp;
void setup()
{
Serial.begin(115200);
@ -68,9 +68,11 @@ void setup()
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: heatindexC_table.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-04
@ -11,6 +10,7 @@
volatile float hi;
void setup()
{
Serial.begin(115200);
@ -40,13 +40,14 @@ void setup()
Serial.println();
Serial.println();
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: heatindexC_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-04
@ -14,6 +13,7 @@ uint32_t duration1;
volatile float hi;
void setup()
{
Serial.begin(115200);
@ -32,13 +32,14 @@ void setup()
duration1 = millis() - start;
Serial.println(duration1);
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: heatindex_table.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-04
@ -11,6 +10,7 @@
volatile float hi;
void setup()
{
Serial.begin(115200);
@ -40,13 +40,14 @@ void setup()
Serial.println();
Serial.println();
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,10 +1,9 @@
//
// FILE: heatIndex_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-04
//
#include "temperature.h"
@ -13,6 +12,7 @@ uint32_t duration1;
volatile float hi;
void setup()
{
Serial.begin(115200);
@ -31,13 +31,14 @@ void setup()
duration1 = millis() - start;
Serial.println(duration1);
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: humidex_table.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-05
@ -42,9 +41,11 @@ void setup()
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: humidex_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2020-04-05
@ -14,6 +13,7 @@ uint32_t duration1;
volatile float hi;
void setup()
{
Serial.begin(115200);
@ -33,13 +33,14 @@ void setup()
duration1 = millis() - start;
Serial.println(duration1);
Serial.print("Done...");
}
void loop()
{
}
// -- END OF FILE --

View File

@ -15,8 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/Temperature"
},
"version": "0.2.4",
"version": "0.2.5",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
"platforms": "*",
"headers": "temperature.h"
}

View File

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

View File

@ -1,12 +1,14 @@
[![Arduino CI](https://github.com/RobTillaart/Temperature/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/Temperature/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/Temperature/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/Temperature/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/Temperature/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/Temperature/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/Temperature.svg?maxAge=3600)](https://github.com/RobTillaart/Temperature/releases)
# Temperature
Arduino library with dewPoint, humidex, heatIndex and windchill functions.
Arduino library with dewPoint, humidex, heatIndex and wind-chill functions.
## Description
@ -20,43 +22,50 @@ DHT22 or Sensirion, to make a weather station application.
## Interface
TO elaborate
### Conversion
- **float Fahrenheit(celsius)** idem
- **float Celsius(fahrenheit)** idem
- **float Kelvin(celsius)** idem
- **float Fahrenheit(float Celsius)** idem.
- **float Celsius(float Fahrenheit)** idem.
- **float Kelvin(float Celsius)** idem.
### DewPoint, humidex
- **float dewPoint(celsius, humidity)** idem
- **float dewPointFast(celsius, humidity)** idem
- **float humidex(celsius, dewpoint)** idem
- **float dewPoint(float Celsius, float humidity)** idem.
- **float dewPointFast(float Celsius, float humidity)** idem.
- **float humidex(float Celsius, float dewPoint)** idem.
### heatIndex
- **float heatIndex(fahrenheit, humidity)** idem
- **float heatIndexC(celsius, humidity)** idem
- **float heatIndex(float Fahrenheit, float humidity)** idem.
- **float heatIndexC(float Celsius, float humidity)** idem.
### WindChill
Windspeed @ 10 meter, if convert is true => windspeed will be converted to 1.5 meter
else ==> formula assumes windspeed @ 1.5 meter
Wind speed @ 10 meter, if **convert** is true => wind speed will be converted to 1.5 meter
else ==> formula assumes wind speed @ 1.5 meter
- **float WindChill_F_mph(fahrenheit, milesPerHour, convert = true)**
- **float WindChill_C_kmph(celcius, kilometerPerHour, convert = true)**
- **float WindChill_C_mps(celsius, meterPerSecond, convert = true)**
- **float WindChill_F_mph(float Fahrenheit, float milesPerHour, bool convert = true)**
- **float WindChill_C_kmph(float Celsius, float kilometerPerHour, bool convert = true)**
- **float WindChill_C_mps(float Celsius, float meterPerSecond, bool convert = true)**
## Operations
The functions have a limited scope so one cannot use it for all input values possible.
The user should be aware of that. Check the references mentioned in the code and or
wikipedia to confirm the applicability of the values generated.
Wikipedia to confirm the applicability of the values generated.
The functions do not check the inputs.
See examples for typical usage.
# Future
- improve documentation
- expand number of formulas
-

View File

@ -1,8 +1,9 @@
#pragma once
//
// FILE: temperature.h
// VERSION: 0.2.4
// PURPOSE: temperature functions
// VERSION: 0.2.5
// DATE: 2015-03-29
// PURPOSE: collection temperature functions
//
// HISTORY:
// 0.1.0 2015-03-29 initial version
@ -10,13 +11,14 @@
// 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
// 0.2.1 2020-05-26 added wind-chill formulas
// 0.2.2 2020-06-19 fix library.json
// 0.2.3 2020-08-27 fix #5 order of functions, typo, fixed 1 example
// 0.2.4 2021-01-08 Arduino-CI + unit tests
// 0.2.5 2021-12-28 Arduino-CI, library.json, readme.md, license, minor edits
#define TEMPERATURE_VERSION (F("0.2.4"))
#define TEMPERATURE_VERSION (F("0.2.5"))
inline float Fahrenheit(float celsius)
@ -41,10 +43,10 @@ inline float Kelvin(float celsius)
// [1] https://wahiduddin.net/calc/density_algorithms.htm
// [2] https://web.archive.org/web/20100528030817/https://www.colorado.edu/geography/weather_station/Geog_site/about.htm
// dewPoint function based on code of [2]
// calculation of the saturation vapor pressure part is based upon NOAA ESGG(temp)
// calculation of the saturation vapour pressure part is based upon NOAA ESGG(temp)
float dewPoint(float celsius, float humidity)
{
// Calculate saturation vapor pressure
// Calculate saturation vapour pressure
// ratio 100C and actual temp in Kelvin
float A0 = 373.15 / (273.15 + celsius);
// SVP = Saturation Vapor Pressure - based on ESGG() NOAA
@ -54,7 +56,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 vapour 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
@ -63,8 +65,8 @@ 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
// (earlier version mentions ~0.6544 but that testcode is gone :(
// delta mdewPointFastax with dewPoint() - run dewpoint_test.ino ==> ~0.347
// (earlier version mentions ~0.6544 but that test code is gone :(
// http://en.wikipedia.org/wiki/Dew_point
float dewPointFast(float celsius, float humidity)
{
@ -77,9 +79,9 @@ float dewPointFast(float celsius, float humidity)
// https://en.wikipedia.org/wiki/Humidex
float humidex(float celsius, float DewPoint)
float humidex(float celsius, float dewPoint)
{
float e = 19.833625 - 5417.753 /(273.16 + DewPoint);
float e = 19.833625 - 5417.753 /(273.16 + dewPoint);
float h = celsius + 3.3941 * exp(e) - 5.555;
return h;
}
@ -134,9 +136,9 @@ float heatIndexC(float celcius, float humidity)
// 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
// wind speed @ 10 meter,
// if convert is true => wind speed will be converted to 1.5 meter
// else ==> formula assumes wind speed @ 1.5 meter
// US
@ -164,3 +166,4 @@ float WindChill_C_mps(const float celcius, const float meterPerSecond, const boo
// -- END OF FILE --

View File

@ -29,6 +29,7 @@
// assertNAN(arg); // isnan(a)
// assertNotNAN(arg); // !isnan(a)
#include <ArduinoUnitTests.h>
@ -39,8 +40,10 @@
unittest_setup()
{
fprintf(stderr, "TEMPERATURE_VERSION: %s\n", (char *) TEMPERATURE_VERSION);
}
unittest_teardown()
{
}
@ -48,8 +51,6 @@ unittest_teardown()
unittest(test_conversion)
{
fprintf(stderr, "VERSION: %s\n", TEMPERATURE_VERSION);
assertEqualFloat(-40, Fahrenheit(-40), 0.001);
assertEqualFloat(-40, Celsius(-40), 0.001);
assertEqualFloat(273.15, Kelvin(0), 0.001);