DHT22 - which library is favored?

I’ve built a couple of devices that utilize the DHT22 (from Adafruit) to sense temperature and humidity. I originally used the Adafruit library that seems quite popular. However, I was randomly (every several hours) getting erroneous (very high) temperature readings. So, I just switched to the Piettetech library and I’m just wondering if anyone has a recommendation. Both seem to work fine. I simply don’t know what is causing the reading anomalies. The error checking in the Piettetech might be a bit more thorough. My leads are very short – a few inches and I do have a 10K pull-up. Thanks!

@ctmorrison, the Piettetech library has proven to be extremely reliable on the Particle platform (Core, Photon and most likely Electron as well). I would recommend using it over the Adafruit library since some members reported lock-ups using it.

Thanks!

1 Like

I can confirm that it works well on the Electron. Been running it for a few weeks now. :slight_smile:

1 Like
  • 1 on the Piettetech library , I’m getting about 5 error per 1000 which is not too bad.
    A just do a little error checking of my own and only take the reading if you have passed o.k

@peter_a, I’m a bit curious as to the nature of the errors you getting (“5 error per 1000”). I’m seeing temperatures that are high by 50 to 80 degrees with the Adafruit library. Can you please offer a bit of detail about what error checking you’re performing? I’ve just switched to the Pietetech library to see if it happens there, too.

First I’m using the PietteTech_DHT library if it’s not stated anywhere .

The example goes :

int result = DHT.acquireAndWait();

switch (result) {
    case DHTLIB_OK: 

Which prints out all the different types if errors, but still uses the faulty result

My error check is :

result = DHT.acquireAndWait();
if ( result == DHTLIB_OK ) <------ this says no error , a good result
{
dht_humiB = DHT.getHumidity();
dht_tempB = DHT.getCelsius();
dht_dew = DHT.getDewPoint();
}

Now if there is a error it doesn`t get used.

p.s , My project uses 2 DHT22’s and cutting down the length of my cables I’ve got the errors rate down to about 1 per 1000 , which isn`t that bad.

Thanks for the clarification. I already had similar code in my application, but it’s nice to know that’s all that’s required. I haven’t seen any bogus logged data since switching to the PietteTech library.