RTC refuses to set

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Posts: 165
Joined: Tue Nov 07, 2017 11:45 pm

RTC refuses to set

Post by rhubarbdog » Fri Sep 07, 2018 11:15 am

I've been playing with the real time clock RTC.
i had this working earlier now setting the RTC with `pyb.RTC().datetime((a-tuple))` just hangs for a few seconds and fails to reset the clock.

This is my program

Code: Select all

import pyb

clock = pyb.RTC()

print("Enter date as revesed tuple (Y,M,D,0,H,M,S,0)")
get_date=input("Enter the 0's and ()'s :")


while True:
    print(clock.datetime(), end="   \r")

i believe from experimentation the date is entered as a tuple Year, Month, Day, <don't know>, Hours, Minutes, Seconds, <milliseconds??>
I currently enter

it hangs for a second or two and prints
(2000, 1, 1, 1, 0, 0, 0, 0)

Posts: 252
Joined: Sun Apr 17, 2016 1:55 pm

Re: RTC refuses to set

Post by shaoziyang » Fri Sep 07, 2018 12:29 pm

Sometimes RTC may not initial correctly after power on, then RTC not running. You may try clock.init() to re-initial RTC.

User avatar
Posts: 3421
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: RTC refuses to set

Post by pythoncoder » Sat Sep 08, 2018 5:31 pm

The tuple looks good - it's documented here.

I have seen exactly that symptom and agree with @shaoziyang that it usually implies that the RTC crystal oscillator is stopped. This can occur for various reasons: the circuitry around the 32KHz crystal is quite sensitive and handling the board while powered up (or with the RTC running off a backup cell) can stop it. Check for anything untoward electrically.
Peter Hinch

Post Reply