Sleep time and external interrrupts
-
I have a sensor to count events (rain sensor). This sensor uses sleeps mode to save power. Any event triggers an external interrupt to wake up the sensor and increment the counter. After an certain time the sensor should send the counter value to the controller.
I useint8_t sleep(int interrupt, int mode, unsigned long ms=0);to wake up either from external IRQ or timer. But if many events occure, the timer never triggers (and the sensor does not send values to controller).
Is it possible to get the elapsed sleep time, when external IRQ triggers? Then I can calculate/estimate when it's time to send values to controller. -
No, I have something like this https://www.mysensors.org/build/rain, but try to get it battery powered.
It generates a pulse after a certain amount of rain. -
I have a sensor to count events (rain sensor). This sensor uses sleeps mode to save power. Any event triggers an external interrupt to wake up the sensor and increment the counter. After an certain time the sensor should send the counter value to the controller.
I useint8_t sleep(int interrupt, int mode, unsigned long ms=0);to wake up either from external IRQ or timer. But if many events occure, the timer never triggers (and the sensor does not send values to controller).
Is it possible to get the elapsed sleep time, when external IRQ triggers? Then I can calculate/estimate when it's time to send values to controller.@karlheinz2000 if you want to know the time elapsed while sleeping you either need a rtc or you need to ask another node (or the controller) about time. See "Fetching time from controller" at https://www.mysensors.org/download/sensor_api_20#requesting-data
No timers are active during sleep.
-
Is it possible to read
msfromvoid hwInternalSleep(unsigned long ms) { // Let serial prints finish (debug, log etc) #ifndef MY_DISABLED_SERIAL MY_SERIALDEVICE.flush(); #endif while (!interruptWakeUp() && ms >= 8000) { hwPowerDown(SLEEP_8S); ms -= 8000;?
mySleepTime - ms, should be the elapsed sleep time?! -
Is it possible to read
msfromvoid hwInternalSleep(unsigned long ms) { // Let serial prints finish (debug, log etc) #ifndef MY_DISABLED_SERIAL MY_SERIALDEVICE.flush(); #endif while (!interruptWakeUp() && ms >= 8000) { hwPowerDown(SLEEP_8S); ms -= 8000;?
mySleepTime - ms, should be the elapsed sleep time?!Unfortunately there is no support for getting ms from hwInternalSleep but I guess the function could be modified. I like the idea. It wouldn't be able to account for time spent when woken up by interrupt, but that error would be max 8 seconds (on atmega328) which would be good enough for many applications.
-
@mfalkvidd any idea for a (quick and dirty:sunglasses: ) workaround? Just copy
msinhwInternalSleepin some global variable? Or will this not work? I'm more in hardware than software... -
@mfalkvidd any idea for a (quick and dirty:sunglasses: ) workaround? Just copy
msinhwInternalSleepin some global variable? Or will this not work? I'm more in hardware than software...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login