Agent is Running, but agent's imp.wakeup stops being called

I have an imp that reads my sump pump water level, and reports that information using agent.send every 5 min to the agent. The agent will then process this data and send it grovestream to be recorded. The agent also runs a function using imp.wakeup every 10 minutes that collects rain data for my area from weather underground and also sends it to grovestream. (Then I can see a nice overlay of how the rain affects my sump pump level. )

This will work great for weeks at a time, but on occasion, I will see an issue where it rains and I see no rain data. When I check on the device, I see the agent is otherwise happily getting data from the device and still sending it to grovestream, but the agent imp.wake up function is no longer running. Hitting the “build and run” button will restart everything, and then it will work again for a few weeks.

I was thinking every so often the agent.send runs at exactly the same time as imp.wakeup causing the wakeup to be interrupted somehow, but that should not happen assuming that everything is running in the 5-10 min intervals. That also assumes that the imp and the agents time don’t drift slightly.

Is there a possibility that, under rare circumstances, you might not be calling imp.wakeup again in your handler? Is the imp.wakeup delay a fixed value or calculated?If calculated, are you using a value derived from hardware.millis() to calculate your delay? The 25day rollover could cause problems.

There was a problem with imp.wakeup in previous releases of the agent, but it’s been very stable for me for the past few months. There have been quite a few unsolicited restarts of the agents in the past few weeks. In some situations, there can be some delay between the agent and the device being operational. Best thing to do there is to log every time the agent or the device resets so you can rule that out as an influence.

imp.wakeup is a fixed value, but that is a good thought.

That is also interesting to know there have been unsolicited restarts. I will have to look into that.

Last good rain data I saw was Oct 25, but then none of the rain from the 26-29 was recorded, so it looks like it has been down for at least 5 days before I noticed.

Since the agent imp.wakeup function is also pulling info from a webpage, I just threw in some debug code incase somehow the http request is causing a problem with the function.

I think I figured out my problem. I didn’t realize that if a json field does not exist, the code dies if there is no “try… catch” to go along with it. It seems on occasion when it pulls in my web data, the json is broken or incomplete. I also had too many things being posted to the device log so by the time I noticed, the error was pushed off the end.