Page 1 of 1

PI display and ds1307 rtc

Posted: Sat Nov 05, 2016 6:11 pm
by gordon77
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 ?

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 10:48 am
by gordon77
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

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 10:55 am
by DougieLawson
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

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 11:54 am
by gordon77
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

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 12:06 pm
by DougieLawson
Then it looks like everything is good to go.

What do you get from
sudo hwclock --systohc
sudo hwclock -r

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 1:06 pm
by 6by9
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.

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 2:23 pm
by gordon77
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

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 2:47 pm
by DougieLawson
The display on an A+, B+, 2B or 3B does NOT need anything other than the ribbon cable and power.

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 3:05 pm
by gordon77
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

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 4:31 pm
by DougieLawson
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.

Re: PI display and ds1307 rtc

Posted: Sun Nov 06, 2016 6:20 pm
by gordon77
Thanks Dougie, working now :D