DHT22 Freezing after some time

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);

@rbbahia, you need to be using the PIETTETECH_DHT library on the IDE or from his repo. The original idDHT22 library was prone to stalling. :smile:

1 Like

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

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

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

1 Like

Hi peekay,

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?