DHT22 + Pietttetech library + Photon = 😢


I went into class today, extolling the virtues of the DHT22, only to have it fail spectacularly when I started demoing it.

It was connected to a Photon, with the DHT_simple.ino example (from the Piettetech_DHT library). It hangs at DHT.acquireAndWait(1000), and then reboots after making the RGB led flash red repeatedly. For the record, the temperature/humidity in the room was within the limits of the DHT22 :smirk:

I’m running deviceOS@1.2.1, and, at least in Visual Studio Code, Serial.available() doesn’t seem to work (pressing a key doesn’t get me out of the while() loop in setup().

Any ideas? Should I try a library other than PietteTech_DHT? Thanks in advance for any help…


Check your pull-up (1k to 3v3) on the data pin.


That is a known issue caused by some “enhanced” memory leak prevention introduced in one of the more recent device OS updates

Currently the only workarounds are to either downgrad the device OS to 1.2.0 or apply this patch to the library


Thanks, ScruffR, this fixed my problem. I was using 1.4.0; still had the problem with 1.2.0-rc1; but it did work with 1.1.1. I’d recommend they mention this in the comment that pops up when you search for this in Particle Workbench, or a note in the README.md.


I tried the modified library files from rgiese but still got the SOS. Anyone else have luck with that patch? In the meantime I’ve downgraded to 1.1.1 and DHT is working as expected.

Was also considering switching to the Adafruit library, assuming it doesn’t cause this problem. Is the only benefit of PietteTech that it uses interrupts? Sorry if I’m misunderstanding some details. If I don’t have a timing-critical situation, just polling the DHT every few mins among some other sensor reads, is Adafruit as good as PT?



Which version of the PietteTech_DHT library have you tried?
Try 0.0.11


Last week I flashed library version 0.0.12 with firmware 1.4.3 and got no errors or SOS. It’s been running for several days polling the sensor every minute, so I’d say it’s fixed.


Can you post a link to the 0.0.12 library?


It’s exactly there where all the previous versions were :wink:

And there you can also find a link to the GitHub repo