User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Install DS3231 Real Time Clock - Latest Info

Sun Aug 13, 2017 11:20 am

I have some good news: Maybe in the future, we only need to add the overlay line in the config.txt to make the RTC working.

The problem which force us to do hack, is because RTC drivers is compiled as kernel modules, so when kernel try to read RTC, it still not load modules yet.

And other programs assume kernel did the right thing, so leave the system clock as it is, such as hwclock.sh or hwclock-set.

So there is a guy submitted a patch to the hwclock-set, trying to make it do a second guess, so computers with no RTC built in would have a second chance to read RTC when driver modules are loaded: https://bugs.debian.org/cgi-bin/bugrepo ... bug=855203

stewart_elmwood
Posts: 9
Joined: Thu Jun 01, 2017 4:23 pm
Location: Toronto
Contact: Website

Re: Install DS3231 Real Time Clock - Latest Info

Sun Aug 13, 2017 2:55 pm

With my commercial hat on, we sell Afterthought's RasClock. Doesn't use a DS3231, but uses a similar temperature-compensated RTC from NXP. Uses a replaceable CR1220 cell, and sits on a tiny 6-pin header for the Raspberry Pi. In Canada, $17.49 from Elmwood Electronics. In the US, $11.99 from Chicago Electronic Distributors.

I've had a DS3231 glowering at me from the workbench for some months now, but since it's not in a particularly Raspberry Pi-friendly form factor it's still lurking there, uninstalled.
I work at Elmwood Electronics — Canadian Source for Raspberry Pi, Adafruit, Arduino, SparkFun and more. Local pickup available in Toronto ­— https://elmwood.to/
  (a.k.a. scruss for non-work things)

alphanumeric
Posts: 1897
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Install DS3231 Real Time Clock - Latest Info

Fri Aug 18, 2017 9:24 pm

Just did a fresh image of stretch, followed the Adafuit tutorial I linked to earlier and it wouldn't work?
viewtopic.php?f=66&t=191120&p=1200023#p1200023
Started all over again this time skipping the disable fake hwclock part and it worked. Might have just been a glitch the first time through though? Not sure at this point why it didn't work the first time through? Anyway, not disabling the fake hwclock doesn't seem to hurt anything.

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

Re: Install DS3231 Real Time Clock - Latest Info

Sat Aug 19, 2017 2:34 am

stewart_elmwood wrote:
Sun Aug 13, 2017 2:55 pm
I've had a DS3231 glowering at me from the workbench for some months now, but since it's not in a particularly Raspberry Pi-friendly form factor it's still lurking there, uninstalled.
Try this on: http://www.mcmelectronics.com/product/83-17980

tbon3
Posts: 1
Joined: Thu Dec 15, 2016 7:45 am

Re: Install DS3231 Real Time Clock - Latest Info

Fri Sep 29, 2017 7:55 pm

doughadfield wrote:
Mon Sep 26, 2016 10:29 pm
I've done this on a couple of different pis now, and the above seems to work consistently. So, all good.
Doug
Doug,
Many thanks for your post.

Followed your guide in a fresh Raspbian Stretch Lite install and everything is working perfectly! Have a Pi set up as a remote data logger for a metstation with no internet access, the lack of a RTC was screwing up the records after a reboot, problem fixed with this super cheap addon and your guide.

heatina
Posts: 2
Joined: Sat Oct 28, 2017 3:18 pm

Re: Install DS3231 Real Time Clock - Latest Info

Sat Oct 28, 2017 3:23 pm

Thanks to DougieLawson with the pin info. (that pin 7 is not used/needed) I am already using pin 7 (1-wire) and wondered how this would affect I2C usage. This info. was what I was missing. I'll order one now and see how we go. Cheers!

ArmandSM
Posts: 4
Joined: Fri Aug 04, 2017 5:19 pm
Location: Barcelona

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 1:03 pm

URGENT, please help.
Hey, I recently bought one of these RTC modules (the one that plugs into the pins without any cables or soldering). I did the steps mentioned in the first post and everything worked fine. I even did the 10minute test mentioned, and the result was succesful. I then decided to leave the raspberry working for a full day just in case the module needed to be charged or something. After that, I basically left the Raspberry disconnected from energy for a few days (I'd say 3 or 4). After that time, I decided to test my DS3231 and, surprisingly enough, the time wasn't correct. The module was working, but the time was 40 seconds off, approximately. I connected the raspberry to the internet, updated it with ntp and did the 10 minute test with, yet again, no issues.
My guess is that every day it fastens about 9-10 seconds, something not noticeable when testing for just 10 minutes. I really need an exact output of less than one second of error. Do you know if this could be fixed, and how? Maybe it's something that happens to everyone?

I'd gladly appreciate any help.

alphanumeric
Posts: 1897
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 4:00 pm

Some are better (more accurate) than others. Make and model (link to) the one your using would help.

User avatar
rpdom
Posts: 14688
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 5:07 pm

Gaining ten seconds a day is pretty poor accuracy for any RTC module. A DS3231 should be a lot better than that. It's accuracy is stated as +/- 2 minutes per year, which is about 0.32 seconds per day worst case.

That assumes that your module is the DS3231 and not the alternative DS1307 which depends on an external timing crystal and can vary with temperature and can be susceptible to electrical noise.

ArmandSM
Posts: 4
Joined: Fri Aug 04, 2017 5:19 pm
Location: Barcelona

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 6:42 pm

alphanumeric wrote:
Sat Nov 04, 2017 4:00 pm
Some are better (more accurate) than others. Make and model (link to) the one your using would help.
The one I bought is from Amazon and is labelled as a DS3231 module. Here's the link https://www.amazon.es/DS3231-Módulo-pre ... B01F6MJZGQ

alphanumeric
Posts: 1897
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 7:10 pm

I wonder if that's a battery or one of those ultra capacitors? Yeah, 10 seconds a day is really really bad.
Timing accuracy is maintained at +/-5ppm (± 0.432 sec / day) in the temperature range of -40C to +85C.
If this is the same one, https://www.amazon.ca/XCSOURCE-Precisio ... 24c32+iic

ArmandSM
Posts: 4
Joined: Fri Aug 04, 2017 5:19 pm
Location: Barcelona

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 8:36 pm

alphanumeric wrote:
Sat Nov 04, 2017 7:10 pm
I wonder if that's a battery or one of those ultra capacitors? Yeah, 10 seconds a day is really really bad.
Timing accuracy is maintained at +/-5ppm (± 0.432 sec / day) in the temperature range of -40C to +85C.
If this is the same one, https://www.amazon.ca/XCSOURCE-Precisio ... 24c32+iic
It does look like the same product, except I only have one single module. Would you recommend asking for a refund? Do you think there's a way to fix this?

alphanumeric
Posts: 1897
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 04, 2017 8:49 pm

You could try starting all over from scratch with a clean image of Raspbian. To be honest I think you got a defective unit. If you think you can get a refund go for it.

plettpc
Posts: 1
Joined: Tue Nov 07, 2017 12:37 pm

Re: Install DS3231 Real Time Clock - Latest Info

Tue Nov 07, 2017 12:41 pm

heatina wrote:
Sat Oct 28, 2017 3:23 pm
Thanks to DougieLawson with the pin info. (that pin 7 is not used/needed) I am already using pin 7 (1-wire) and wondered how this would affect I2C usage. This info. was what I was missing. I'll order one now and see how we go. Cheers!
Add this line to your config file to use other gpio as 1-wire.

e.g. dtoverlay=w1-gpio,gpiopin=5

Neukam
Posts: 1
Joined: Sat Nov 25, 2017 4:00 am

Re: Install DS3231 Real Time Clock - Latest Info

Sat Nov 25, 2017 4:02 am

After setting up the RTC you should run

Code: Select all

sudo update-rc.d hwclock.sh enable
This will allow the pi to update the RTC from the NTP service

Edit- This seems to work properly on Jessie but I'm having issues getting it to work on Sketch

riwid
Posts: 2
Joined: Thu Jul 19, 2018 1:28 pm

Re: Install DS3231 Real Time Clock - Latest Info

Thu Jul 19, 2018 1:39 pm

Hi

I followed the instruction in the beginning of this thread with a DS3231 on an raspberry pi 3 with the latest Raspbian stretch lite (June 2018, kernel 4.14). But I get:

Code: Select all

[email protected]:~ $ sudo hwclock -r
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

Code: Select all

[email protected]:~ $ sudo hwclock --debug
hwclock from util-linux 2.29.2
hwclock: cannot open /dev/rtc: No such file or directory
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.
Any help is appreciated!

DirkS
Posts: 9871
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Install DS3231 Real Time Clock - Latest Info

Thu Jul 19, 2018 2:38 pm

riwid wrote:
Thu Jul 19, 2018 1:39 pm
Hi

I followed the instruction in the beginning of this thread with a DS3231 on an raspberry pi 3 with the latest Raspbian stretch lite (June 2018, kernel 4.14). But I get:

Code: Select all

[email protected]:~ $ sudo hwclock -r
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.
Did you enable i2c?
Do you see the rtc device

Code: Select all

ls /dev/rtc
:
Is the dtparam line for rtc correct? (triple checked?)
Post your /boot/config.txt.
Did you check the log for lines with 'rtc'?

riwid
Posts: 2
Joined: Thu Jul 19, 2018 1:28 pm

Re: Install DS3231 Real Time Clock - Latest Info

Fri Jul 20, 2018 11:07 am

Thanks

I went back to the hardware store and changed to a new module. And now it works! So the module itself was faulty.

adaca
Posts: 1
Joined: Tue Jul 31, 2018 8:06 pm

Re: Install DS3231 Real Time Clock - Latest Info

Tue Jul 31, 2018 8:12 pm

Hi,
thank you very much for this very useful info.

However, on my rpi0w with Raspbian Jessie, the file:

Code: Select all

/lib/udev/hwclock-set
get constantly overwritten at boot, so the initial lines always remain the same:

Code: Select all

if [ -e /run/systemd/system ] ; then
    exit 0
fi
even if I delete them out!
As a result, /dev/rtc is not defined, so hwclock can't find the RTC!

Please help!
Thank you

Killertechno
Posts: 175
Joined: Wed Jan 02, 2013 8:28 am

Re: Install DS3231 Real Time Clock - Latest Info

Fri Aug 10, 2018 1:46 pm

Neukam wrote:
Sat Nov 25, 2017 4:02 am
After setting up the RTC you should run

Code: Select all

sudo update-rc.d hwclock.sh enable
This will allow the pi to update the RTC from the NTP service

Edit- This seems to work properly on Jessie but I'm having issues getting it to work on Sketch

Hi to all, I have some doubts about RTC on Raspberry....
It's said fake-hwclock is read at boot, then written at shutdown. Ok, it's clear: I need to read (supposed) time at boot, then save current time before power off.
Now, about RTC (such SD3231), when is it read/wrote?
I can understand at boot and before power off (such fake-hwclock), and when user want read/write it through command line.
But about Raspberry OS?
Is it periodically updated through some ntp daemon, or ntpdate, or something else?
Thanks.

Return to “General discussion”