At this point, my home temperature sensing network ticks along pretty reliably. The major cause of missing data is when the batteries run out on one of the sensor modules. Each individual module can run for quite some time, but with several modules running off batteries at once, it seems like one or another of them is running out every week or two. Ideally, I'd like to get a warning a day or two before the batteries are going to go dead so that I can change them out with only a minimal blip in the data. It would also be nice if I didn't drain the batteries completely - I use rechargeables and it's better to leave a bit of juice still in them. As it is, 2 out of 4 AA batteries typically get drained so low that the fancy charger I prefer to use won't even register that they're there.
Having seen this nifty bit of code, I was hoping to be able to do this without adding any additional hardware. This code is monitoring the VCC voltage that enters the Atmega328, so what it sees is AFTER the voltage regulator has stepped things down to 3.3V. That could still be useful, because the modules can keep broadcasting for a while as the voltage drops. I didn't know how fast that would be, so I wanted to test it.
I added a Voltage data type to the data logger rails app. It uses the same parsing and reporting machinery as FahrenheitTemp, the lines just have a V instead of a T designator. I then updated the dallas_temp_sensor Arduino sketch to take a voltage measurement each time it does a temperature measurement and report it back over the Xbee link.
A quick check showed the voltages table picking up data steadily, with all the readings over 3.3V. All I needed to do was wait for one of the sensors to run out of juice and I could see what happens.
Eventually, one of them ran down. Here's about 24 hours of voltage data, ending when the module couldn't report it any longer:
You can see that the voltage dropped from ~3.3V to 3.2V almost 24 hours before going off the air. Then it held steady until about 5 hours before going off the air, when it began to drop precipitously, finally going silent at around 2.7V.
Unfortunately, that drop to 3.246V isn't reliable enough to make a good monitoring trigger. The different sensor modules aren't quite consistent enough to let me just hard code the same level across the board. It's bad enough that I have to change the source name and recompile for each module. I'm not going to measure and tweak voltage parameters for each one. I need something more dramatic to allow for an alarm without false positives.
So... next up I'm going to see what I can come up with for monitoring the raw input voltage as it comes from the batteries. Perhaps a voltage divider to protect against higher input voltages and modifying the code to measure a different input against the internal voltage reference.