# DHT22 Freezing after some time

**URL:** <https://community.particle.io/t/dht22-freezing-after-some-time/11625>\
**Category:** Firmware\
**Created:** [May 5, 2015, 1:25pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625 "2015-05-05T13:25:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbbahia](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@rbbahia](https://community.particle.io/u/rbbahia)\
**Post date:** [May 5, 2015, 1:25pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625/1 "2015-05-05T13:25:23Z")

</div>

Hello, I am using the following code to read temperature and humidity sensors DHT22 two after about a 100 readings, the Spark starts flashing green and after a minute he hangs up. I think it’s a memory problem in the code but do not know how to solve, some friends can give me a hand?

```
// This #include statement was automatically added by the Spark IDE.
#include "idDHT22/idDHT22.h"

// declaration for DHT11 handler
int idDHT22pin = D4; //Digital pin for comunications
int idDHT22pin1 = D1; //Digital pin for comunications

void dht22_wrapper(); // must be declared before the lib initialization
void dht222_wrapper(); // must be declared before the lib initialization

// DHT instantiate
idDHT22 DHT22(idDHT22pin, dht22_wrapper);
idDHT22 DHT222(idDHT22pin1, dht222_wrapper);
```

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 5, 2015, 1:39pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625/2 "2015-05-05T13:39:40Z")

</div>

@rbbahia, you need to be using the PIETTETECH\_DHT library on the IDE or from his [repo](https://github.com/piettetech/piettetech_dht). The original idDHT22 library was prone to stalling. 😄

---

<div class="post-metadata">

**Author:** ![rbbahia](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@rbbahia](https://community.particle.io/u/rbbahia)\
**Post date:** [May 5, 2015, 3:00pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625/3 "2015-05-05T15:00:39Z")

</div>

thanks for answer. When I try compile the sample, receive this message:

“Could not compile please review your code” and don’t show where is the error

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 5, 2015, 3:36pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625/4 "2015-05-05T15:36:12Z")

</div>

@rbbahia, I just compiled the PIETTETECH\_DHT examples on the web IDE without errors. Which example are you trying to compile?

---

<div class="post-metadata">

**Author:** ![rbbahia](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@rbbahia](https://community.particle.io/u/rbbahia)\
**Post date:** [May 5, 2015, 3:49pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625/5 "2015-05-05T15:49:58Z")

</div>

Was giving compilation error but is now running, I’m testing it. thank you again

---

<div class="post-metadata">

**Author:** ![rbbahia](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@rbbahia](https://community.particle.io/u/rbbahia)\
**Post date:** [May 5, 2015, 7:33pm UTC](https://community.particle.io/t/dht22-freezing-after-some-time/11625/6 "2015-05-05T19:33:11Z")

</div>

Hi peekay,  
 ![](https://sea2.discourse-cdn.com/flex026/uploads/particle/5286/6923c487df08ebde.jpg)  
After several tests I see that the code shows the temperature at first, then takes 60 seconds to appear the second temperature, then the core is blinking cyan, after 80 seconds so the core begins to flash green and from there I can see in screen every 5 seconds the temperature is correct it blinks green?

Another issue, as I put the temperature within a variable? for example  
variable1 = sensor1temp  
variable2 = sensor2temp

where I can get the values?
