Skip to content

What happens when millis overflows? #13

@rmetcalf9

Description

@rmetcalf9

According to https://www.arduino.cc/reference/en/language/functions/time/millis/ the value returned by millis will overflow after about 50 days.

On this page:
https://playground.arduino.cc/Code/SimpleTimer
you state your algroythm is:

lastMillis = 0
forever do:
    if (millis() - lastMillis > n)
        call the particular piece of code
        lastMillis = millis()
    end
end

Which means that after millis overflows, millis() - lastMillis can never be greater than n since millis is now 0. This means that after 50 days any timers will simply stop running.

In my application I want a timer to run every 2 hours. Reading all the docs about this code it is not clear to me if this is true.
Can you edit your docs to either state that this library will not work after 50 days, or state that the library has code that will enable a regular timer to continue working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions