GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Time keeping on Ras-pi

Wed Oct 14, 2020 12:16 pm

Anyone know what happens to the internal clock on a raspberry pi during a power outage?

I have a Raspberry Pi OW, and it occurred to me that it’s internal clock might have to be reset every time it loses power.

It’s hard for me to test because I have it in headless mode, and connect to it via ssh. Which means by the time I am able to check, it’s already been connected to the internet
Last edited by GarraTheWinnie on Wed Oct 14, 2020 12:35 pm, edited 1 time in total.

GlowInTheDark
Posts: 1238
Joined: Sat Nov 09, 2019 12:14 pm

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 12:21 pm

There is no "internal clock" on a Raspberry Pi.

Thus, your assumptions about what happens are all correct.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 12:38 pm

If I install a time server on my Raspberry Pi, will it keep the time after being unplugged?

I read an article that suggest it might, but without a battery of some sort, I can’t imagine it would

User avatar
DougieLawson
Posts: 40523
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 12:58 pm

GarraTheWinnie wrote:
Wed Oct 14, 2020 12:16 pm
Anyone know what happens to the internal clock on a raspberry pi during a power outage?
There are no time-of-day clocks on a RPi without adding additional external hardware.

On restart the system clock is reset to 17 minutes past the last hour it was up. So it the time was 21:45 when the power failed it will come back up with the clock set to 21:17. That's due to the somewhat insane behaviour of fake-hwclock. Once the internet is connected then systemd's timesyncd process should reset the clock to the time from an internet time server.
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 1:03 pm

Ah ok.

I’m looking at RTCs online, and as with most things raspberry pi, they aren’t expensive until the shipping comes in.

Does raspi have a low power mode?

If I wanted to program it to power everything except the ‘internal clock’ during a power outage, is that possible?

User avatar
DougieLawson
Posts: 40523
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 1:13 pm

GarraTheWinnie wrote:
Wed Oct 14, 2020 1:03 pm

Does raspi have a low power mode?
There is no such thing.

It runs at low power normally unless you're beating the CPU to death. It costs less than £5 a year to run for 24/365.

You need a battery backed RTC.
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 1:20 pm

Fair enough.

Thanks!

User avatar
jahboater
Posts: 6513
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 1:30 pm

GarraTheWinnie wrote:
Wed Oct 14, 2020 1:03 pm
Does raspi have a low power mode?
As Dougie says, no.

But, you can down clock it and reduce the voltage to some minimal values to reduce the power consumption.
It might go as low as 200MHz (arm_freq=200) and perhaps over_voltage=-4
You would have to experiment (edit /boot/config.txt)

Turn off the HDMI if you are not using it with "/usr/bin/tvservice -o" in /etc/rc.local
Last edited by jahboater on Wed Oct 14, 2020 1:31 pm, edited 1 time in total.
Pi4 8GB and Pi4 4GB running Raspberry Pi OS 64-bit

User avatar
RaTTuS
Posts: 10700
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 1:30 pm

https://www.aliexpress.com/item/4001304848879.html
I've not used it, others are available YMMV
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 2:57 pm

I ended up buying this

I’m not sure why it has two spaces for VCC, ground, Sda, and SCL. Am I safe to assume it’s for connecting other devices in line?

There isn’t much information about the 32k and the Pwm pin. I assumed one was to power a buzzer, but I am having doubts about it

W. H. Heydt
Posts: 13971
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 2:59 pm

RaTTuS wrote:
Wed Oct 14, 2020 1:30 pm
https://www.aliexpress.com/item/4001304848879.html
I've not used it, others are available YMMV
Those are okay. At present, I'm using this one: https://chicagodist.com/products/rasclo ... spberry-pi It has the advantage of a replaceable battery, which that site also sells, for considerably less than local (to me) retail.

hippy
Posts: 8889
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 3:35 pm

GarraTheWinnie wrote:
Wed Oct 14, 2020 2:57 pm
I ended up buying this

I’m not sure why it has two spaces for VCC, ground, Sda, and SCL. Am I safe to assume it’s for connecting other devices in line?
Probably. Or as an alternative means of connecting if not wanting to use the 6-way connector at the other end.
GarraTheWinnie wrote:
Wed Oct 14, 2020 2:57 pm
There isn’t much information about the 32k and the Pwm pin. I assumed one was to power a buzzer, but I am having doubts about it
The "32K" output is simply a 32kHz open-drain output, possibly with pull-up on-board, taking the internal DS3231 clock out to other things which may find that useful. Most things wouldn't.

By PWM pin I presume you mean the SQW output. That's another open-drain output, possibly with pull-up on-board, which can be used to flash a LED on and off to show it's working, or provide a slow clock rate to something else, or provide a signal for when an alarm condition has been met.

The DS3231 datasheet will contains the details for both. Neither are probably used nor that useful when used by the Pi as a time-keeping RTC, but you might be able to leverage use for user applications.

GlowInTheDark
Posts: 1238
Joined: Sat Nov 09, 2019 12:14 pm

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 3:42 pm

I'm trying to figure out why you care. From your OP, it is clear that your Pi *IS* Internet connected and it gets and correctly sets its time from the Internet, so why are you fussing with RTCs?
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 5:03 pm

hippy wrote:
Wed Oct 14, 2020 3:35 pm
By PWM pin I presume you mean the SQW output. That's another open-drain output, possibly with pull-up on-board, which can be used to flash a LED on and off to show it's working, or provide a slow clock rate to something else, or provide a signal for when an alarm condition has been met.

The DS3231 datasheet will contains the details for both. Neither are probably used nor that useful when used by the Pi as a time-keeping RTC, but you might be able to leverage use for user applications.
I did mean SQW, my bad. Good to know! The Datasheet I looked up explained what they were, but not what they were for. I couldn’t find an example online of what they were used for. So now I know

Thanks for the help!
GlowInTheDark wrote: I'm trying to figure out why you care. From your OP, it is clear that your Pi *IS* Internet connected and it gets and correctly sets its time from the Internet, so why are you fussing with RTCs?
my project is connected to the wifi while
I work on it. I’m undecided if it will stay that way. Even if it does, my area gets power outages a lot, and my internet isn’t the greatest. My project doesn’t need the internet, so it would nice to not have to relay on it. Besides 90% of Pi projects are ‘because I can’, isn’t that a good enough reason?

GlowInTheDark
Posts: 1238
Joined: Sat Nov 09, 2019 12:14 pm

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 7:07 pm

Besides 90% of Pi projects are ‘because I can’, isn’t that a good enough reason?
Absolutely. I was just trying to get a feel for what your actual situation was.

BTW, it is also true that my one experience with putting an RTC on a Pi was, to say the least, less than satisfying, so I'm a little skeptical of the whole general idea.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

GarraTheWinnie
Posts: 152
Joined: Tue Jul 28, 2020 10:34 am

Re: Time keeping on Ras-pi

Wed Oct 14, 2020 9:02 pm

I’m making a reef-Pi system to automate numerous things on my fish tank.

In all honesty, my power company sucks. It’s too important to relay on everything turning on properly.

So I figured I’d see how this works out

gordon77
Posts: 5379
Joined: Sun Aug 05, 2012 3:12 pm

Re: Time keeping on Ras-pi

Thu Oct 15, 2020 6:22 am

GarraTheWinnie wrote:
Wed Oct 14, 2020 9:02 pm
I’m making a reef-Pi system to automate numerous things on my fish tank.

In all honesty, my power company sucks. It’s too important to relay on everything turning on properly.

So I figured I’d see how this works out
Would a ups be better in that case ?

hippy
Posts: 8889
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Time keeping on Ras-pi

Thu Oct 15, 2020 12:05 pm

gordon77 wrote:
Thu Oct 15, 2020 6:22 am
Would a ups be better in that case ?
That's always a tough one to determine. It usually boils down to how long any outages will be and how detrimental not doing something at the time it should be done is, whether things can be successfully mitigated by playing catch-up later.

It's not unusual that the first thought to enter people's head when the mains goes off is the risk to food in their freezers. That's likely the least of their worries.

gordon77
Posts: 5379
Joined: Sun Aug 05, 2012 3:12 pm

Re: Time keeping on Ras-pi

Thu Oct 15, 2020 12:49 pm

hippy wrote:
Thu Oct 15, 2020 12:05 pm
gordon77 wrote:
Thu Oct 15, 2020 6:22 am
Would a ups be better in that case ?
That's always a tough one to determine. It usually boils down to how long any outages will be and how detrimental not doing something at the time it should be done is, whether things can be successfully mitigated by playing catch-up later.

It's not unusual that the first thought to enter people's head when the mains goes off is the risk to food in their freezers. That's likely the least of their worries.
It may depend how much the fish are worth.

Return to “Beginners”