Full featured DHT lib: dewpoint, heat-index etc. - need testers :)

Hi guys and girls,

Based on various libs around the web and some ideas of my own, I've put together yet-another-DHT-lib featuring:

  1. Autodetection of sensor type
  2. Read humidity and temperature in one function call.
  3. Determine heat index in *C or *F
  4. Determine dewpoint with various algorithms(speed vs accuracy)
  5. Determine thermal comfort
  • Empiric comfort function based on comfort profiles
  • (TODO) Multiple comfort profiles. Default based on http://epb.apogee.net/res/refcomf.asp
  • Determine if it's too cold, hot, humid, dry, based on current comfort profile
  1. Optimized for sensor read speed(~5ms for DHT22), stack and code size.

The lib is here GitHub - ADiea/libDHT: Arduino compatible DHT11/22 lib with heatindex, dewpoint and confort algorithms

In the docs folder you can see that I've done some testing but the only hardware I have is a non-Arduino ESP8266 board.

So if you like it and have some spare time and Arduino hardware please help test it.

Comments, rants and wish-lists are welcome :slight_smile:

Cheers!

Did not test it, just a quick look at the code and looks good to me.

A number of remarks:

  • One call I do not know and that is pullup() ? Is this ESP specific?

  • Missing example codes (incl the one that generated the data for your test)

  • You have all kind of functions that calculate e.g. dewpoint. imho these are not DHT related and could be used with another sensor(s) as well. From design point of view I would keep them as separate static functions OR integrate them in such a way that I do not need to provide the parameters. Just use the actual or last read() ones. Would reduce the size of code quite a bit.

  • Similar remark to have both C and F interfaces, The sensor is C so the user of the lib could convert it if needed. This results in semi-duplicate code.

  • I like the Comfort concept.

  • Did you keep the interface compatible with ADAfruit's one?

so far,

Hi Rob,

Thanks for the input:

  • seems that pullup was ESP specific. I replaced it with a PULLUP macro depending on the Ardino version it either does pinMode(INPUT_PULLUP) or pinMode(INPUT);digitalWrite(HIGH);

-I have included an example sketch in the /example folder - unfortunately I do not have an arduino setup&hardware to compile & run it :frowning:

-A very good point. For now, I have defaulted the parameters so if you call it with no params it will attempt to read() and work with the internal cache - the read() can be excluded with a compile switch

-Regarding F and C. There is now a way to either always output Celsius via compile swith which results in smallest code size, always output F slightly higher code size and also the option to decide on runtime via function params which is most flexible and also does not break compatibility with Adafruit's lib.

-Thanks, I have now separated things a bit and defined the comfort profile. In the end the user should be able to apply learned profiles etc.

-Yes the interface is compatible with Ada's there is a separate function for readH readT(with farenheit option via param)

Let me know if you decide to give it a spin:)
Best,
Andrei

robtillaart:

  • You have all kind of functions that calculate e.g. dewpoint. imho these are not DHT related and could be used with another sensor(s) as well. From design point of view I would keep them as separate static functions OR integrate them in such a way that I do not need to provide the parameters. Just use the actual or last read() ones. Would reduce the size of code quite a bit.

Rob, I'll take your advice and begin working on a thermodynamics library with all sorts of algorithms that will use pressure, temp and rel. humidity.

I would like to primarily base it on:

  1. Algorithms - Schlatter and Baker
  2. your work here Arduino/libraries/Temperature at master · RobTillaart/Arduino · GitHub

Was wondering if this is ok with you and what license should I consider for your work?

Have a nice day,
Andrei

OK with me,

for me the least restrictive license - creative commons I think, everyone can share but give credit and reference to source or so. Most algorithms are just a rewrite in C++ from Fortran.

Think the "core" codes should all work with Celsius as most sensors return Celsius temperatures.
Do you agree?

Yes just my thinking, I'll maybe add a #define to switch it all to Fahrenheit for convenience..
I'll also integrate the various comfort and comfort-profiles so the DHT lib will be less cluttered :slight_smile:

hi - did anyone test this? was it good for dewpoint calcs?

The dewpoint function is translated from FORTRAN from NOAA,
I expect they know what they are doing ...

see - Arduino/temperature.h at master · RobTillaart/Arduino · GitHub