dharashah
Posts: 11
Joined: Sat Sep 12, 2015 12:03 pm

Trouble Setting up RTC in Raspberry Pi

Sat Sep 12, 2015 12:22 pm

Hi I am new to raspberry Pi.
I have Raspberry Pi 2 Model B. Have installed Raspbian Wheezy

I need to setup RTC Module in it.

This is what I did.
1. Enabled I2C from raspi-config and set it to load by default
2. Changed /etc/modules and added following lines

Code: Select all

i2c-bcm2708
i2c-dev
3. Then I installed 12c-tools and python-smbus

Code: Select all

sudo apt-get install -y python-smbus i2c-tools
And restarted Pi
4. After that I shutdown Pi , and connected the RTC
VCC->5V, GND->GND, SDA->GPI02 and SCL->GPI03
5. At this point when I run

Code: Select all

sudo i2cdetect -y 1
I see a proper ID #68
6. Then I ran following commands:

Code: Select all

sudo modprobe rtc-ds1307
sudo bash
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
exit
sudo date -s "Sat Sep  12 16:41:00 UTC 2015"
sudo hwclock -w
sudo hwclock –r
At this time, I am getting proper time with the command sudo hwclock -r
7. Then I added rtc-ds1307 to file /etc/modules
And following lines in /etc/rc.local
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s
date

now when I reboot the Pi, the time is not showing from RTC.
Aslo the command sudo i2cdetect -y 1 shows UU instead of #68

I am not sure what I did wrong. I had followed two tutorials
http://www.raspberrypi-spy.co.uk/2014/1 ... pberry-pi/
http://thepihut.com/blogs/raspberry-pi- ... spberry-pi

Thanking you for any support in advance.
I urgently need this

beta-tester
Posts: 1377
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Trouble Setting up RTC in Raspberry Pi

Sun Sep 13, 2015 9:11 am

i don't know, but maybe you have to uninstall the fake-hwclock

Code: Select all

sudo apt-get remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo rm /etc/cron.hourly/fake-hwclock
sudo rm /etc/init.d/fake-hwclock
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

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

Re: Trouble Setting up RTC in Raspberry Pi

Sun Sep 13, 2015 1:09 pm

Greetings.

OP didn't do anything wrong. It's just the Raspbian is upgraded.

Try this one: viewtopic.php?p=775626#p775626

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

Re: Trouble Setting up RTC in Raspberry Pi

Sun Sep 13, 2015 8:55 pm

Both of the tutorials you've used are out of date.

Add

Code: Select all

dtoverlay=i2c-rtc,ds1307
to config.txt, reboot and your RTC device should show as

Code: Select all

root@apollo ~ # 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: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@apollo ~ #
There's no modprobe or echo command needed to get that working.
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.

Return to “General discussion”