My co-developer and I each have a Spark Core programmed to receive and log sensor trips to a RAM based circular buffer. We have both experienced random resets of the Core when the Core is apparently doing nothing (other than running the loop code of the firmware). The Cores are in different locations with different power and different WiFi connections to the Internet.
The interval between resets is several hours to a day or more, and they appear to occur randomly. The firmware running on my Core synchronizes time with the cloud once per day and publishes sensor trip events to the cloud when they are received, albeit the resets do not appear to happen on either of these actions. My co-developer has more Spark.publish() events and seems to get the reset more frequently, albeit not coincident with any particular event.
Although the resets are infrequent and seemingly random, we have each actually observed it happening once. Here is what happens:
- the Core is breathing Cyan, normally.
- suddenly, the Core starts flashing cyan or white (hard to tell) rapidly.
- after a second or two of this, the Core starts flashing red. The red flashes appear to be the SOS message followed by some flashes. It is hard to count the flashes accurately and this only happens once, but it is possible that the number of flashes is 8 (code for out of heap space).
- after one sequence of red flashes, the Core seems to reset. It flashes green (WiFi connection) and that fast purple or white and then it is back up breathing cyan again and running the firmware just fine, albeit after having run setup() and reset everything (thus losing our sensor log information).
When I observed this on my Core, I can guarantee that there were no sensor trips or anything that might be more than the regular loop() activity, which had been running this way for over 23 hours previously with no problem at all. I had my Core powered via a USB port on a laptop with power saving turned off, in order to guarantee that the resets are not caused by a power supply problem or AC glitch.
It would appear that the Core is frequently communicating over the cloud (at least opening or restoring a cloud connection) and that occasionally there is some communication delay or something that crashes the cloud communication code which in turn resets the Core. Why the Core would suddenly run out of heap space (if that is what the problem really is) is totally unexplained.
Anyone have any idea what is happening here? An unplanned reset even once per day, and even automatically recovering, is unacceptable as we lose our sensor data. Yes, the data could be logged to some external non-volatile storage, but we believe that these resets should not be happening. Since our firmware does not seem to be causing them, we don’t know how to solve this problem.
Any help would be appreciated. Even just an understanding of what the Core i doing in the “background” vs a vs cloud communication might be helpful.