To enable support for the RTC in Raspbian Wheezy' (2012-10-28 or later),
the following lines need to be added to /etc/rc.local above the exit0 line:
modprobe i2c-bcm2708
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
modprobe rtc-ds1307
hwclock -s
These instructions should work with any DS1307 or DS1338 Real Time Clocks, it has been tested with CJE Micro's/4D RTC http://www.cjemicros.co.uk/micros/indiv ... eClock-RTC
If anyone has any problems or suggestions re this please post here.
Chris Evans (CJE Micros's & 4D)
Re: Instructions to Configure DS1307 or DS1338 RTC
It's important to note that if you are using a Rev2 RasPi then you need to replace i2c-0 with i2c-1.arm2 wrote:To enable support for the RTC in Raspbian Wheezy' (2012-10-28 or later),
the following lines need to be added to /etc/rc.local above the exit0 line:
modprobe i2c-bcm2708
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
modprobe rtc-ds1307
hwclock -s
Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/
http://www.sheepwalkelectronics.co.uk/
Re: Instructions to Configure DS1307 or DS1338 RTC
Thanks for that info:
Not elegant but would
modprobe i2c-bcm2708
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
modprobe rtc-ds1307
hwclock -s
work?
I'm used to RISC OS where you could have a utility that sets a system variable and then you can have conditional execution in the boot script like:
modprobe i2c-bcm2708
IF Rev$Pi=0 THEN echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
IF Rev$Pi>0 THEN echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
modprobe rtc-ds1307
hwclock -s
Not elegant but would
modprobe i2c-bcm2708
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
modprobe rtc-ds1307
hwclock -s
work?
I'm used to RISC OS where you could have a utility that sets a system variable and then you can have conditional execution in the boot script like:
modprobe i2c-bcm2708
IF Rev$Pi=0 THEN echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
IF Rev$Pi>0 THEN echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
modprobe rtc-ds1307
hwclock -s
Re: Instructions to Configure DS1307 or DS1338 RTC
On Fedora ARM on Pi...
# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
-bash: echo: write error: Invalid argument
Does not seem to work on my Model 2. However, I am still able to set and query the RTC clock. So new_device is set somehow.
# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
-bash: echo: write error: Invalid argument
Does not seem to work on my Model 2. However, I am still able to set and query the RTC clock. So new_device is set somehow.
Re: Instructions to Configure DS1307 or DS1338 RTC
Thinking more about this... I pulled my older Model 2 with only 256 MB out of obsolete drawer... and tried the same steps, making sure the Fedora ARM image was pristine... since my work bench Model 2 Fedora image has I2C, SPI, and more goodies support already loaded. Long story short the steps as document work, I don't get the invalid write error.
# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
# echo $?
0
# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
# echo $?
0
Re: Instructions to Configure DS1307 or DS1338 RTC
Just an update... Fedora 18 ARM... support ds1307 has been dropped. This is a real disappointment, because I have i2c ds1307 add-on boards for a few of my Pi devices, and now it appears I have to remain on Fedora 17, or change distributions. Best I can determine, Fedora ARM team decided that since ds1307 based RTCs are not a consistent feature of ARM devices, there was no need to continue support because it establishes what they called an inconsistent platform? Whatever that means.
Reference...
https://lists.fedoraproject.org/pipermail/arm/2013-January/005066.html
Reference...
https://lists.fedoraproject.org/pipermail/arm/2013-January/005066.html
Re: Instructions to Configure DS1307 or DS1338 RTC
Is anyone aware of any updates to this issue relating to DS1307 support in Fedora 18 (Pidora)?
It appears only the command:
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_devices
is failing, but that other commands are working okay, such as:
hwclock -r ... to "read" contents of RTC
hwclock -s ... to "set" time/date from contents of RTC
hwclock -w ... to "write" current date into RTC
This presumes performing a "modprobe rtc-ds1307".
Is the "echo ds1307 0x68" command needed for anything?
It appears only the command:
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_devices
is failing, but that other commands are working okay, such as:
hwclock -r ... to "read" contents of RTC
hwclock -s ... to "set" time/date from contents of RTC
hwclock -w ... to "write" current date into RTC
This presumes performing a "modprobe rtc-ds1307".
Is the "echo ds1307 0x68" command needed for anything?
-
- Posts: 11
- Joined: Sun Jun 22, 2014 9:03 am
Re: Instructions to Configure DS1307 or DS1338 RTC
I cannot run inside bash script because it gives me error:
Code: Select all
echo "ds1307 0x68" > /sys/class/i2c-adapter/i2c-1/new_device
. Why?!line 3: echo: write error: Invalid argument
Re: Instructions to Configure DS1307 or DS1338 RTC
What model pi do you have?MarkoSiroki wrote:I cannot runinside bash script because it gives me error:Code: Select all
echo "ds1307 0x68" > /sys/class/i2c-adapter/i2c-1/new_device
. Why?!line 3: echo: write error: Invalid argument
Which OS and OS version?
Which kernel version?
Re: Instructions to Configure DS1307 or DS1338 RTC
Try
Code: Select all
echo "ds1307 0x68" | sudo tee /sys/class/i2c-adapter/i2c-1/new_device
Re: Instructions to Configure DS1307 or DS1338 RTC
I'm having the same problem.
Details:
Raspberry Pi Model B
Linux raspberrypi 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l GNU/Linux
Thank in advance!
Julia
Details:
Raspberry Pi Model B
Linux raspberrypi 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l GNU/Linux
Thank in advance!
Julia
- DougieLawson
- Posts: 42214
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Instructions to Configure DS1307 or DS1338 RTC
Take a look at /boot/overlays/README if dtoverlay=i2c-rtc is documented in there then you've got kernel support.
If it's not there run sudo rpi-update (to get to 3.18.12).
Addto /boot/config.txt then reboot and your RTC will be running with nothing needed. No strange echo commands are needed.
If it's not there run sudo rpi-update (to get to 3.18.12).
Add
Code: Select all
dtoverlay=i2c-rtc,ds1307
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Instructions to Configure DS1307 or DS1338 RTC
Thank you,
I do indeed have the following in the /boot/overlays/README
File: ds1307-rtc-overlay.dtb
Info: Configures the DS1307 Real Time Clock
Load: dtoverlay=ds1307-rtc
Params: <none>
I am able to query and set the hwclock. However, for some reason the hwclock is being set by the system clock on bootup (instead of the other way around).
It's behaviour is the following:
I set the system time to ‘Fri May 1 2015, 7:10AM’.
I set the hwclock time to ‘Fri May 1 2015, 7:10AM’.
I wait five minutes.
Times have moved forward 5 minutes appropriately (‘Fri May 1 2015, 7:15AM’).
I shut the RPi down, wait 5 minutes.
Boot up, and both are set to ‘Fri May 1 2015, 7:15AM’.
Ideally, both would show ‘Fri May 1 2015, 7:20AM’.
Do you have any idea what startup script could be causing this?
Thank you,
Julia
I do indeed have the following in the /boot/overlays/README
File: ds1307-rtc-overlay.dtb
Info: Configures the DS1307 Real Time Clock
Load: dtoverlay=ds1307-rtc
Params: <none>
I am able to query and set the hwclock. However, for some reason the hwclock is being set by the system clock on bootup (instead of the other way around).
It's behaviour is the following:
I set the system time to ‘Fri May 1 2015, 7:10AM’.
I set the hwclock time to ‘Fri May 1 2015, 7:10AM’.
I wait five minutes.
Times have moved forward 5 minutes appropriately (‘Fri May 1 2015, 7:15AM’).
I shut the RPi down, wait 5 minutes.
Boot up, and both are set to ‘Fri May 1 2015, 7:15AM’.
Ideally, both would show ‘Fri May 1 2015, 7:20AM’.
Do you have any idea what startup script could be causing this?
Thank you,
Julia
- DougieLawson
- Posts: 42214
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Instructions to Configure DS1307 or DS1338 RTC
You need to get rid of fake-hwclock and ensure that hwclock gets run at shutdown and again at restart.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Instructions to Configure DS1307 or DS1338 RTC
I am having the same problem.
When I do it shows my DS3231 as 68 . But when I do the command I get the "permission denied" message.
I have a model B+
I am quite new here, so please answer in laymen terms
When I do
Code: Select all
sudo i2cdetect -y 1
Code: Select all
pi@raspberrypi ~ $ sudo i2cdetect -y 1
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: -- -- -- -- -- -- -- --
Code: Select all
oech ds1307 0x68 >> /sys/class/i2c-adapter/i2c-1/new_device
Code: Select all
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
bash: /sys/class/i2c-adapter/i2c-1/new_device: Permission denied
I am quite new here, so please answer in laymen terms
Re: Instructions to Configure DS1307 or DS1338 RTC
Thanks for this. I addedDougieLawson wrote:Take a look at /boot/overlays/README if dtoverlay=i2c-rtc is documented in there then you've got kernel support.
If it's not there run sudo rpi-update (to get to 3.18.12).
Addto /boot/config.txt then reboot and your RTC will be running with nothing needed. No strange echo commands are needed.Code: Select all
dtoverlay=i2c-rtc,ds1307
Code: Select all
dtoverlay=i2c-rtc,ds1307
Code: Select all
sudo hwclock -r