Millis() or another time function while in sleep

There was a bugfix for short sleep periodes.
Try upgrading (maybe 0.6.0-rc.1) and see if that bug bit you too.

thanks. any chance to do it OTA?

I can’t find the guide. and i just messed up my usb connector on the elctron.

There you can find the instructions and the binaries to flash

These were the respective issues
https://github.com/spark/firmware/issues/1043
https://github.com/spark/firmware/issues/1075

you saved my butt yet again.

Going to bump this thread just in case something new has come up.

I need to measure a regular interval in milliseconds (~1400ms) and if a pulse is missed then the electron should send a publish. But if time.now only gives me seconds then trying to sleep would be useless? I can no longer measure the pulse interval correctly… Any suggestions?

If you need millisecond resolution, you could use a millis() timer or a software timer, but it would be helpful if you could give us more detail about what you’re trying to do. What have you tried so far, and what are the problems with your current approach?

Thanks for the fast response Rick, but as mentioned in the first post millis() and software timers dont carryover during sleep. At least as far as i know, (I don’t have any electrons to verify right now).

I have a regular interval pulse coming in on the WKP pin roughly every 1400ms but this can vary up to 500ms.

Right now I keep a running average of time between pulses and wait for an out of range event (+1/2 duration average) before triggering an alarm. So everything works as it should right now but I want to reduce power with sleep.

Ok, I think I get what you’re trying to do. Does the Electron need to wake up every 1400 milliseconds, or only when you exceed your missing pulse time? If the latter, I think you might need to use an external watchdog timer (with a timeout period of ~2100 ms), that the pulse would tickle every 1400 milliseconds. If a pulse doesn’t come in within that timeout period, the watchdog would wake your Electron. I assume you want to use deep sleep. Is that the case?

Hello @ScruffR

If i am using a photon microcontroller and i am using the stop mode described here. I have been putting my photon in stop mode for 1 second and found that it does stop and starts again after what appears to be 1 second without bridging the 3V3 to Vbat. Although it appears to be working, is it necessary to bridge 3v3 to Vbat so that i dont encounter any timing errors in the future?

As long your keep the device powered (via USB, Vin or 3v3) you don’t strictly have to.

1 Like