Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8026

Beginners • Re: timer rollover resets program

$
0
0
MicroPython on the Pico W doesn't (or shouldn't) reset every 24 hours. Maybe your code is causing the reset?

All of the time.ticks* functions roll over. If you use them for any time sums, be aware you need to use the special ticks_add() and ticks_diff() functions.

If you're needing timestamps for a log and you're connected to a network, the ntptime module will set the Raspberry Pi Pico W's RTC.

You can install ntptime using:

Code:

mpremote a1 mip install ntptime
Then use it something like this:

Code:

import machineimport ntptimer=machine.RTC()print(r.datetime())  # before clock is setntptime.settime()print(r.datetime())  # after clock is set
This will print something like:

Code:

(2021, 1, 1, 4, 0, 7, 28, 0)(2025, 4, 15, 1, 18, 41, 2, 0)
RTC.datetime()'s return value is an 8 item list, (year, month, day, weekday, hours, minutes, seconds, subseconds). That might work better for you.

Statistics: Posted by scruss — Tue Apr 15, 2025 6:56 pm



Viewing all articles
Browse latest Browse all 8026

Trending Articles