On 02-11-19 16:14, R.Wieser wrote:
> Hello all,
>
> Just today I connected a DS3231 Real Time Clock module to my Pi - to use
> when it cannot connect to the internet to get its current time from an NTP
> server..
>
> I'm using python to retrieve the date and time from the RTC module and
> display it. But now I'm stuck at the point where I need to set Raspberry
> Pi's clock with it. I've been googeling for at least half an hour, but
> can't seem to find how to *set* the current time.
>
> De closest I have been is to execute
> "datetime.datetime(2019,11,02,16,06,0) - which gets ignored without any kind
> of error or warning message ...
>
> Added problem: The Pi might (ofcourse) have problems with "a mere user"
> trying to change the system clock, and might need some kind of "sudo". How
> do I do that from within "Thonny" (in the "shell" window) ?
You don't. Yes you need sudo. I'd use the command line: "sudo hwclock
-s" (see: man hwclock). Only works if your rtc is recognised. Check with
"timedatectl status".
Not sure how automatic the sync from rtc to system clock is. I mean, if
an rtc is present, does the system time updater automatically use it
after every reboot? Or does it just keep pinging ntp servers, even if
they can't be reached? So, look into that. Alternatively, remove all
ntp/fakehwclock services then add to /etc/rc.local: "hwclock -s". When
the rtc has lost its time, first set the system clock, then: "hwclock
-w" to copy to the rtc.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|