Sleep time is not actual sleep time

  • Hello,

    I use Sleep on one of my nodes and then wake up to report to GW.
    It is set to sleep 3600000 which should equivalent to 1 hour (10006060).
    However, I can see that this is not the case.
    My node wakes up, but about every 1hour 9 minutes instead to report.
    I'm using a arduino pro mini (chinese) so obviously this could be the culprit.
    Just wondering if anyone else has seen this 🙂

  • Mod

    @Nicklas-Starkel yes that is very common. The Arduino doesn't really know anything about time. It just knows how much time a clock cycle usually takes. But that varies with temperature, voltage and maybe some other factors.

    If exact sleeping time is important, add a rtc module. See for an example.

  • Mod

    @Nicklas-Starkel The sleep() function will use the watchdog timer to wake the ATmega from deep sleep again, not the regular oscillator.
    This watchdog timer, contrary to the oscillator, can be off by +/- 10% (which is an ATmega limitation; it has nothing to do with Chinese origin), which roughly matches the time you measured.
    The actual deviation depends on a number of factors, as @mfalkvidd already indicated.

    If however it is quite constant in your situation, you could simply corrrect for this offset by lowering the sleep time for your node.
    E.g. try 60/69 * 3 600 000 = 3 130 435 and see if it now wakes up close to 1 hour.

  • @Yveaux and @mfalkvidd thanks!
    It's not important for me, just curious to know why 🙂

Log in to reply

Suggested Topics

  • 3
  • 15
  • 22
  • 5
  • 1
  • 8