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

PI display and ds1307 rtc

Sat Nov 05, 2016 6:11 pm

I can get them to work seperately so they both work but not together. Display fine but rtc reports invalid argument to sudo hwclock - r

any thoughts ?

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 10:48 am

I added the rtc in my usual way...
add dtoverlay=i2c-rtc,ds1307 to /boot/config.txt
comment out the following lines in /lib/udev/hwclock-set
#if [-e /run/systemd/system ]: then
#' exit 0
#fi
and the 2 other lines containing --systz
this appears to work OK with Jessie and the clock will work OK without the screen attached.

If I use i2cdetect -y 1 I get:

Code: Select all

      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:   --  --  --  --  --  --  --  --    
If I connect the rtc and Display I get:

Code: Select all

      0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f
00:               --  --  --  --  --  --  -- --  -- --  --  --  --
10:   --  --  --  --  --  --  --  --  --  -- --  -- --  --  --  --
20:   --  --  --  --  --  --  --  --  --  -- --  -- --  --  --  -- 
30:   --  --  --  --  --  --  --  --  38  -- --  -- --  --  --  -- 
40:   --  --  --  --  --  45  --  --  --  -- --  -- --  --  --  --
50:   --  --  --  --  --  --  --  --  --  -- --  -- --  --  --  -- 
60:   --  --  --  --  --  --  --  --  UU  -- --  -- --  --  --  -- 
70:   --  --  --  --  --  --  --  --    
but the rtc won't work.

I thought it maybe PSU related as I was getting the screen warning flash but now tried a larger PSU but still no clock.

with sudo hwclock -w I get

hwclock: ioct(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument.

Any advice would be useful.

Thanks

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 10:55 am

Your RTC looks like it is working, "UU" means it has been captured by a kernel module.

Do you have a /dev/rtc or /dev/rtc0? What's in /sys/dev/char/254:0?

Try
cat /sys/dev/char/254\:0/date
cat /sys/dev/char/254\:0/time
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 11:54 am

DougieLawson wrote:Your RTC looks like it is working, "UU" means it has been captured by a kernel module.

Do you have a /dev/rtc or /dev/rtc0? What's in /sys/dev/char/254:0?

Try
cat /sys/dev/char/254\:0/date
cat /sys/dev/char/254\:0/time
yes I have dev/rtc and dev/rtc0
/sys/dev/char/254:0 contains several subdirectories including rtc which has date and time in

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 12:06 pm

Then it looks like everything is good to go.

What do you get from
sudo hwclock --systohc
sudo hwclock -r
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 1:06 pm

Are you on a Model A or B (not A+ or B+)? If not then you shouldn't be connecting anything beyond the ribbon cable, 5V, and GND.
You shouldn't be seeing addresses 0x45 & 0x38 on i2c-1 except on an A or B - they should be on i2c-0 with the GPU talking to them. I suspect you've added the two extra wires to SDA and SCL, effectively connecting i2c-0 and i2c-1 together. So the messages that the GPU is sending to the display are colliding with your RTC messages, and everything then starts failing.

I'm afraid that if you are on a Model A or B then there is no way to attach the display and retain an i2c bus available to Linux.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 2:23 pm

I am using a Pi2 Model B v1.1, I have connected the wires to SCL and SDA !!

How do i connect the rtc to i2c-1 ?

Aren't pins 3 and 5 i2c-1 ? They are already used by the Pi display which I thought used i2c-0 which confuses me.

Thanks

Gordon

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 2:47 pm

The display on an A+, B+, 2B or 3B does NOT need anything other than the ribbon cable and power.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 3:05 pm

DougieLawson wrote:The display on an A+, B+, 2B or 3B does NOT need anything other than the ribbon cable and power.
Thanks Dougie, but what about the white and grey i2c wires here ?...

https://thepihut.com/blogs/raspberry-pi ... mbly-guide

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 4:31 pm

gordon77 wrote:
DougieLawson wrote:The display on an A+, B+, 2B or 3B does NOT need anything other than the ribbon cable and power.
Thanks Dougie, but what about the white and grey i2c wires here ?...

https://thepihut.com/blogs/raspberry-pi ... mbly-guide
Pull them off and store them in your "bits and bobs" spares drawer.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

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

Re: PI display and ds1307 rtc

Sun Nov 06, 2016 6:20 pm

Thanks Dougie, working now :D

Return to “Official Foundation Display”