You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a program to let Arduino UNO blink for 2 secs, display millis() on an OLED screen, sleep for 5 sec, and then loop it again and again.
However I noticed that except idleMode, in other modes the displayed time difference of 1st loop is about 7 seconds, but in later loops it is about 2 seconds. It seems that millis() didn't count the past time during later sleep periods.
In idleMode, the difference is always about 7 seconds.
I expected it to display same difference since the UNO had only entered the same sleep mode, which should have the same result.
Perhaps the external oscillator is disabled in later sleep times than the 1st time?
Note that I don't have that much knowledge about sleep modes...Just happened to get to know it to save some power for my battery driven device.
The text was updated successfully, but these errors were encountered:
Hi fishBone000, sorry for the slow response. I don't recall all of the details right now (its been awhile since I have worked with sleep mode on the arduino). However I do know some of the sleep modes disable the timer that millis() depends on. The Sleep_n0m1 library uses the watchdog timer to wake itself up, but the millis function uses a different timer which disabled in some sleep modes so it won't count correctly. The idleMode is different because that one doesn't disable timers and so doesn't save much power. Also the first loop is always 7 seconds because the way the library works is it uses the first loop to calibrate the sleep times. So it only does idleMode sleep on the first cycle (and every 100th cycle) while calibrating regardless of what mode you set it in. After its finished calibrating in the first cycle it will switch to the sleep mode you set. I think if you use a stop watch on your phone or something you will see that it should be keeping a 7 second time cycle for all loops with any sleep mode. Just the millis display is wrong. I hope that helps!
I wrote a program to let Arduino UNO blink for 2 secs, display millis() on an OLED screen, sleep for 5 sec, and then loop it again and again.
However I noticed that except idleMode, in other modes the displayed time difference of 1st loop is about 7 seconds, but in later loops it is about 2 seconds. It seems that millis() didn't count the past time during later sleep periods.
In idleMode, the difference is always about 7 seconds.
I expected it to display same difference since the UNO had only entered the same sleep mode, which should have the same result.
Perhaps the external oscillator is disabled in later sleep times than the 1st time?
Note that I don't have that much knowledge about sleep modes...Just happened to get to know it to save some power for my battery driven device.
The text was updated successfully, but these errors were encountered: