[Submission] Updated Non-blocking Interrupt Driven DHT Sensor Library

@mntscott, I have had a dual DHT22 (no pull-ups) running for 145,775 samples (several days) without any problems. :smile:

@wgbartley, @peekay123, that is great news, I really appreciate additional testing in a different environment.

@peekay123, do you mean no external pull-ups? I assume you are using the builtin internal pull-up? According to the core specs it is 40K.

@wgbartley, @peekay123 are you using this library with the timing debug memory or without it?

@mtnscott, I run the code as-is and I am not sure if the gpio works without specifying the pin mode as INPUT_PULLUP. With or without an external pull-up resistor, it works.

I ran the code with and without the debug timing library. The latest firmware was compiled with DHT_DEBUG_TIMING undefined so no debug memory.

@mtnscott, @peekay123 - I ran the example code for both the blocking and non-blocking. No debug timing stuff on either. I wound up adapting the non-blocking version into the firmware I’ve been working on. I do have a 1K external pull-up resistor.

It’s helped get me back into Spark hacking (Sparking?), and I’m close on rolling out 3 new libraries that I started this weekend! :wink:

@wgbartley, that’s great! @mtnscott did a great job tuning and fixing the non-blocking library. Can you give me a hint as to which libraries you will be rolling out? :stuck_out_tongue:

Some handy (for me) utilities for publishing metrics using Spark.pubish() and/or StatsD. I don't want to go into too much detail and thread-jack @mtnscott's amazing work!

@peekay123, @wgbartley

On the spirit of libraries, I will be publishing a set a libraries based on the Adafruit Unified Base Class. I know @peekay123 you did an initial port and added a bunch of sensor support, My goal was to make it easy to just create a bunch of sensor drivers, wrap them in this unified class and then throw them all into an array and iterate thru that array for the data values. It works like a champ but I had to break sensors like DHT, BMP into two objects, one for the Temperature and another for the Humidity, Pressure. They share the same sensor ID so its easy to associate them. This also makes it screaming easy to dump to a remote database. Adding a new sensor - just create it and throw it into the array!

If @peekay123, or anyone else is also working on something similar, or wants to help let me know as we could coordinate our efforts and all use the same architecture.

@mtnscott, I am not working on anything like that but I like the idea of using the Adafruit approach. I’ll try and help as much as I can :smile:

I suppose I’m stuck. I’ve tried the non blocking library, switched to adafruit library listed on the IDE. I’m not sure what works as I continue to get errors on the readings for temp. I was getting negative 5 billion degree readings until I placed a 10k resistor on my dht22 now I get 0 degrees. Which is better but still not right. Any clues on which library is better and what command should I use to acquire temp.such as WHILE (!ACQUIRING())
{temp = DHT.Fahrenheit;
delay (3000);}

@Wileyan, use the library posted at the top of this topic. It is listed as PIETTECH_DHT in the IDE libraries. A 1K ohm pull-up (to 3.3V) resistor is recommended. The library includes some examples you can try out. :smile:

idDHT22 library would lock up after a couple of reads, maybe 10, sometimes a couple hundred. I’ve run the PietteTech_DHT examples (unmolested other than adding liquidcrystal library for output) with 40,000 samples and running, have done power off resets three times to get to 40k+, never locked up. Thanks so much, @mtnscott, reliable temp/humidity sensing is a pretty basic need for Spark!!!

@mtnscott I made a minor modification to your code which makes it easy to disable the DHT22. I have found it useful for hardware testing because if I unplug the DHT22 it will hang on my acquire loop.

Hi all,
I was wondering if someone could help me adapt this program so i can use it with Blynk. I already did it with one DHT22, but i would like to use 2 DHT22 (and later more DS18b22 to monitor temperatures on my 3d printers)
Thanks a lot

I tried to use the library to get reading from the Temperature a Humidity sensor on the ā€œGrove Starter Kit for Particle Meshā€ with an Argon and keep getting ā€œError Response time out errorā€. Notice that I have changed the DHTTYPE to DHT11. I have also noticed that once or twice I have got back some values that seem correct but for the majority of times, I get the timeout error. Any help will be appreciated.

With one of the recent ā€œenhancmentsā€ on the device OS side some issues have been introduced with the PietteTech_DHT library which aren’t fully understood yet, but here is the respective issue report

Thanks for the quick response. That might explain my issue. My devices are on rc 27