Freezer alarm - sporadic failures

Hi. I have written a small sketch that lights a red LED and sounds a buzzer when the temperature in a chest freezer goes above a certain temperature. The alarm works fine, except it fails at irregular intervals. It might work for 2 hours or 2 weeks before failing. When it fails, the buzzer sounds even though the DHT’s temperature is still below the threshold setting. I have replaced every component, including the Nano, the DHT and the power supply, to no avail. Any suggestions as to what I can try next would be welcome. Sketch attached. Thanks.

FreezerAlarm20_nocomments.ino (1.05 KB)

I can't see anything wrong with it. You don't need the Adafruit library and displayTempHumid is never called, but I wouldn't expect those to cause issues. Only thing I can think of is that one of your libraries has a memory leak. Grab a copy of the freemem function and check.

Why is AdafruitGFX.h in there? Are you usually running a graphics display? Is it possible that what's causing the issue is the display code overwriting something that we can't see here?

-jim lee

In a previous version, I had a 0.96" OLED display but I removed it, thinking it might be the cause of the failure (but it wasn't). I will try those suggestions. Thanks.