You need to find out which bit is failing - Add a flashing led to your sketch and see if that keeps running .
Swap the sensor out for a button , see if that keeps it running ...
The sketch has a pulsing LED (every 10 sec) and all of it seems to work well. Battery is full of charge. It is a simple test set up: There is a second LED that goes on for a few sec when the PIR is sensed as HIGH on a digital pin.
It works perfect indoors and out doors down to freezing, then has false positives and false negatives in a seemingly random order. Once warms up is just fine.
In other words the situation is directly repeatable and only occurs below a certain temp, above that temp the set up words just fine. All along the first LED flashes every 10 sec just as the sketch says to, so even at -10 degrees the Uno, LED, battery, etc are all working correctly.
Unlike trail cams, the HC-SR501 sensor, at least the one advertised on Amazon is clearly not designed to be used out of doors.
The temperature is very unlikely to be the problem. Any condensation or moisture on the board will cause it to malfunction, or destroy it quickly, and you need an excellent enclosure to avoid that.
Thanks. Does anyone know of a HCSR501 type unit that is automotive rated then? I realize it will cost more than $5 or so on Amazon but would like to find it anyway.
Um, yes but I was hoping for a simple replacement for the HCSR501 to solve my problem or a hack / process to make it reliable to -20 degrees F. I am aware of the big box home improvement devices (some as low as $10 each) but my project will require many PIRs so looking for a better solution.
Even if rated to 0 deg C, a part won't suddenly stop working below that temperature. It's guaranteed to work at 0-85C, which means it's almost certain to work a bit out of that range, and quite certainly a bit further out. No surprise if such a part still works at -20 C, even if not rated for that temperature.
The military/automotive grades are again guaranteed to work at those extended temperature ranges, but won't suddenly stop working the moment that limit is crossed.
Your part failing at 0 C is indeed a strong indication that water is the culprit.