macstr1k3r
Posts: 2
Joined: Sun Oct 21, 2012 3:48 pm

Wierd RTC(ds1307) problem

Sun Oct 21, 2012 4:00 pm

For the pas week or so I have been trying to hook up a ds1307 with my r-pi. I have not been able to find anyone on google with a similar problem so I decided to post my problem here.

LSMOD:

Code: Select all

[email protected]:~# lsmod
Module                  Size  Used by
rtc_ds1307              6710  0 
i2c_bcm2708             3542  0 
i2c_dev                 5587  0 
snd_bcm2835            19889  0 
snd_pcm                74834  1 snd_bcm2835
snd_seq                52536  0 
snd_timer              19698  2 snd_seq,snd_pcm
snd_seq_device          6300  1 snd_seq
snd                    52489  5 snd_seq_device,snd_timer,snd_seq,snd_pcm,snd_bcm2835
snd_page_alloc          4951  1 snd_pcm
evdev                   8682  2 
I am able to detect the rtc on the i2c bus

Code: Select all

[email protected]:/home/pi# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
It is clear from the following shippet that the chip is successfully "registered"

Code: Select all

[email protected]:/home/pi# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
[email protected]:/home/pi# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
Once I run hwclock -r or hwclock -s I get:

Code: Select all

[email protected]:/home/pi# hwclock -r
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
Any help or guidance would be apriciated. Thanks in advance

M33P
Posts: 199
Joined: Sun Sep 02, 2012 1:14 pm

Re: Wierd RTC(ds1307) problem

Sun Oct 21, 2012 7:20 pm

Try
echo 7 > /proc/sys/kernel/printk
to enable debug messages in the kernel log.

Then can you post the output of dmesg after you perform those steps (again) to register the DS1307?

And also

i2cdump -y 0 0x68 b

ravidborse
Posts: 2
Joined: Sun Mar 24, 2013 4:00 am

Re: Wierd RTC(ds1307) problem

Wed Jun 05, 2013 5:34 pm

Hi
I also used to get the error

Code: Select all

RTC Problem RTC_RD_TIME: Invalid argument ioctl() to /dev/rtc0 to read the time failed.
My Problem Solved Using Following Link:
Run Command Mentioned In Link:

Code: Select all

# sudo hwclock --systohc -D --noadjfile --utc
# sudo hwclock --set --date "06/05/13 23:00:00"
# sudo hwclock --show
Wed 05 Jun 2013 23:00:13 UTC  -0.369063 seconds
# sudo shutdown now
Remove all power supply wiring for 5 Mins.
After 5 Mins Wire Complete Set Up Again and Login the Raspberry PI

Code: Select all

# sudo hwclock --show
Wed 05 Jun 2013 23:05:05 UTC  -0.761500 seconds
http://www.mail-archive.com/smartphones ... 02020.html

rgkrishnas
Posts: 1
Joined: Tue Oct 03, 2017 7:09 am

Re: Wierd RTC(ds1307) problem

Tue Oct 03, 2017 7:14 am

Pi Zero W Needs the below config changes to work RTC 1307 module
sudo nano /boot/config.txt
## Add the below line
dtoverlay=i2c-rtc,ds1307

edit the below line
sudo nano /lib/udev/hwclock-set
## Comment the below 3 lines
e.g.
#if [ -e /run/systemd/system ]; then
#exit 0
#fi

sudo reboot

sduo hwclock -r


Regards
Gopal

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

Re: Wierd RTC(ds1307) problem

Tue Oct 03, 2017 12:21 pm

I have a DS1307, and two DS3231's running fine, following this tutorial. https://learn.adafruit.com/adding-a-rea ... pberry-pi

brubbel
Posts: 2
Joined: Wed Mar 28, 2018 11:55 am

Re: Wierd RTC(ds1307) problem

Wed Mar 28, 2018 12:12 pm

FWIW, same issue with pcf8523. Only happens at first use, when the RTC is not (yet) initialized.

Issue is repeatable by removing the battery of the RTC for a minute, then replugging the module on the RPI.
dtoverlay and rtc_pcf8523 module load correctly, but 'timedatectl' and 'hwclock --show' produce the error 'Invalid argument'.

Running sudo hwclock --show twice seems to solve the problem, or running 'hwclock --systohc'.

Return to “Troubleshooting”