adafruit / adafruit/DHT-sensor-library
Adding a simple Dew Point function to Adafruit DHT library
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hi. I am an astronomer/astrophotographer. I am currently building a control board for my Celestron telescope and one of the metrics I want to collect is the Dew Point. I will use this in deciding the power level I will supply to my Dew Heater on the telescope. I have found a simple Dew Point calculation, which would be great to be able to reference from a DHT sensor. The calculation can be found at https://iridl.ldeo.columbia.edu/dochelp/QA/Basic/dewpoint.html.
Would this be something that you would consider adding to the current library? I have provided my code below for your reference. This was tested on the following:
- Arduino board: **ARDUINO/UNO R3*
- Arduino IDE version (found in Arduino -> About Arduino menu): **1.8.19**
- Adafruit DHT11 and DHT22 sensors
DHT.h
float computeDewPointSimple(float temperature, float percentHumidity,
bool isFahrenheit = true);
DHT.cpp
/*!
* @brief Compute Dew Point - Simple Method
* Using formula was proposed in a 2005 article by Mark G. Lawrence in the Bulletin of the American Meteorological Society:
* (https://iridl.ldeo.columbia.edu/dochelp/QA/Basic/dewpoint.html)
* @param temperature
* temperature in selected scale
* @param percentHumidity
* humidity in percent
* @param isFahrenheit
* true if fahrenheit, false if celcius
* @return float dew point
*/
float DHT::computeDewPointSimple(float temperature, float percentHumidity,
bool isFahrenheit) {
float hi;
if (!isFahrenheit)
temperature = convertCtoF(temperature);
hi = temperature-((100 - percentHumidity) / 5);
return isFahrenheit ? hi : convertFtoC(hi);
}
There is a more complex function that gives greater accuracy, which is detailed on the web page provided above, but I have yet compiled that function.
Kind regards
Teddy
Contributor guide
Research direction
Start with the proposed declarations and implementation in DHT.h and DHT.cpp. Review the linked dew-point formula and the supplied Fahrenheit/Celsius behavior, then validate the result on the stated Arduino UNO R3 with DHT11 and DHT22 sensors; done means the library exposes a consistent dew-point calculation for those inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100