I have a couple of impAccelerator Battery Powered Sensor Nodes. The first one I got has been running great and runs the example code without issue. Because this one worked well, I ordered a couple more and when I received them, it appeared to be a newer design which did not have a power switch. I was able to blink up the new ones and I pushed the same code to them and they were working for a little bit, but now that they’ve been running for about a week, half of them have stopped waking up when they were supposed to (every 30 mins) and only wake up when I re-seat the batteries in the battery holder. At this point, they report one data point and then never wake up again until I repeat the process. Has anyone else had a similar problem? How did you get around this?
This is likely a corner case in your code which is resulting in either the device not sleeping (and hence draining the batteries) or going to sleep with incorrect wakeup parameters.
The fact that removing/replacing batteries causes the device to report once then go away again is a pretty clear indication that there’s an issue with your code, almost certainly that you are not explicitly connecting on a shallow wake and are in RETURN_ON_ERROR mode - on a cold boot, the network is up (as impOS is checking you are running the latest VM code) and so your code works, but when it sleeps and wakes with wifi off, you’re doing an agent.send() when unconnected and just getting an error returned.
Can you post your code? You can PM it if you’d like to keep it private.
Hi Hugo, thanks for the response. I realized I made a slight mistake in my original post. After re-seating the batteries on the sensor yesterday after making the post, it continued to wakeup and sleep every 30 minutes as intended, so it doesn’t seem as cut and dry as only waking up once after a power cycle as I had initially reported.
I had initially thought this was a hardware issue, but after reading your response, a software issue seems more likely. The code I used was mostly the same as the example code line I posted above, but I had modified these two variables to be the same, which I think may have introduced a race condition into my code, which produced the symptoms I was seeing. I went ahead and re-wrote the code to collect exactly one data point before reporting to the server, and it seems to be working better now. I will report back here if I start seeing the same behavior again.
Thanks for the help!
From a quick browse of the code, I don’t believe setting those to the same value should have caused an issue, but things are certainly subtle.
I would recommend that you use an FTDI cable to assist debug of offline behavior - see https://electricimp.com/docs/resources/disconnecteddebugging/ - there is a spare UART available on the RJ11 connector.
Good to know, thanks for the link!