-
As always, check you wiring. Loose wire can lead to communication errors. And the DHT22 uses a single wire bit-banged protocol, that's not as robust as for example I2C or SPI.
The DHT22 module does retry up to 10 times by default if can't communicate with the DHT22 or there is a CRC error. With 500ms delay between each retry, worst case that's over your 5000ms interval.
If you have a logic analyzer (even a <10USD one), you can check the communication for retries.
Or if not, you can log the time between the start and end:setInterval(function() { var t0 = new Date this.dht.read((response) => { var t1 = new Date() console.log(response) console.log(process.memory()) console.log('start:', t0, 'end:', t1, 'elapsed:', t1-t0) console.log('_____') }); }, 5000);
And if my theory is right, you will see some corelation in over 5 second communication and memory leak. Then you can either increase the interval to ~10 seconds, or you can pass in a lower retry count.
Hi. I'm use esp32-wroom-32 and DHT22 sensor with DHT22.js script.
I call the read function every 5 seconds and every time I get less and less memory, the log below as it was at the beginning of work was 1917, and after a while it was already 1887 and so on until there is an error.
What my problem?
My code:
My logs: