I am using a Seeeduino Stalker and Adafruit Fona to collect stream height data from a Maxbotix Maxsonar unit and rainfall data from a rain gauge and upload these to data.sparkfun.com. Once per minute, the RTC on the Stalker sends an interrupt signal to pin 2, and the sketch checks to see if, according to the upload schedule, it’s time to send an upload, and if so, to send it. If the upload fails – and there are a variety of reasons it might – the Fona reboots and attempts it again, up to three times total. Having successfully completed the loop, the Stalker goes to sleep until the next RTC interrupt.
For the most part it works well. What is puzzling me is that when an upload fails – even if the second or third attempt during the same loop is successful – the loop proceeds as one would expect except that after sleeping, the RTC interrupt will not wake the Stalker (though the rain gauge interrupt on pin 3 will). I am not a very experienced programmer, but I cannot see where the upload failure would connect with the RTC wake function.
I apologize that the code is rather long – too long to include in the text of this post, so it’s attached. Any advice appreciated. Many thanks for taking the time to have a look.
hidrosonico.txt (16.2 KB)