nullstring
Posts: 178
Joined: Sun Oct 02, 2011 3:05 pm

Re: How to add clock backed by battery?

Mon Nov 28, 2011 10:06 pm

For many uses of the RPI for which I can conceive, it's important that in the case of power and internet loss, the RPI will still have the correct time.

So, how exactly do we add one?

The way that I can think of-
Add an RTC with battery backup and then communicate from the RPI via I2C in init.d. It'd be simple but slightly crude.

I feel like this problem has probably already been solved before. In fact, the admins of the site may know the solution since they seemed to have decided against implementing such a thing as a cost saving measure.

1. Do we need a separate RTC? if yes, because of the CPU spec or because of the PCB design?
2. What software is used elsewhere to solve this problem?

tntexplosivesltd
Posts: 72
Joined: Fri Sep 30, 2011 8:08 am
Contact: Website

Re: How to add clock backed by battery?

Mon Nov 28, 2011 10:17 pm

I would use the same I2C RTC but unfortunately I don't think there is a seperate RTC. The SoC might have one (surely it must?)

nullstring
Posts: 178
Joined: Sun Oct 02, 2011 3:05 pm

Re: How to add clock backed by battery?

Mon Nov 28, 2011 10:22 pm

Quote from tntexplosivesltd on November 28, 2011, 22:17
I would use the same I2C RTC but unfortunately I don't think there is a seperate RTC. The SoC might have one (surely it must?)

My fear is that even though it might, we will not be able to interface with it because the ports are not "broken out".

I am not sure what you mean by "I don't think there is a seperate RTC"? Obviously, the seperate RTC would be added by ourselves.

kme
Posts: 448
Joined: Sun Sep 04, 2011 9:37 am

Re: How to add clock backed by battery?

Mon Nov 28, 2011 10:44 pm

For the B model this isn't any concern. You just sync via NTP during boot. Point yourself to <country code>.pool.ntp.org - i.e. uk.pool.ntp.org/de.pool.ntp.org/es.pool.ntp.org etc.

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: How to add clock backed by battery?

Mon Nov 28, 2011 10:55 pm

this should be "if you have Internet access". There will be Bs without Internet, and As with internet ^^

User avatar
Gert van Loo
Posts: 2486
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: How to add clock backed by battery?

Mon Nov 28, 2011 11:11 pm

RTC are expensive as you:
1/ Need the RTC chip
2/ Need a battery
3/ Need the PCB space for those.

tntexplosivesltd
Posts: 72
Joined: Fri Sep 30, 2011 8:08 am
Contact: Website

Re: How to add clock backed by battery?

Tue Nov 29, 2011 12:03 am

I think I will have to have an external I2C RTC with battery, then have a script that grabs the time on boot. DS1307 ftw

kendall15
Posts: 2
Joined: Tue Nov 29, 2011 1:11 am

Re: How to add clock backed by battery?

Tue Nov 29, 2011 1:15 am

If correct time without internet is a complete must, I imagine the PI will have a very low idle power requirements. So it could just be a matter of a rechargeable battery pack that will change when the PI has another power source. Just my quick thoughts.


User avatar
cnxsoft
Posts: 191
Joined: Sat Oct 15, 2011 2:33 pm
Location: Chiang Mai, Thailand
Contact: Website

Re: How to add clock backed by battery?

Tue Nov 29, 2011 4:37 am


nullstring
Posts: 178
Joined: Sun Oct 02, 2011 3:05 pm

Re: How to add clock backed by battery?

Tue Nov 29, 2011 3:39 pm

Either of those would work fine, but this still doesn't break any ground on the following two questions.

1. Is there any existing software that will will interface with an RTC via I2C? As said previously, it would be simple enough to add something to init.d for startup and shutdown... but what about power failures? We need something that will keep the RTC in sync, etc.
2. I'd also like to know if the CPU itself has an option for RTC battery backup. (Even if we can't use it)

EDIT: found the answer to question (1) here: http://elinux.org/BeagleBoard_....._.28RTC.29

It looks like there are plenty of RTC drivers right in the kernel source. :D
$ ls linux-3.2-rc3/drivers/rtc/rtc* | wc -l
99

User avatar
glenn66
Posts: 55
Joined: Fri Nov 25, 2011 4:06 pm
Location: Belfast
Contact: Website

Re: How to add clock backed by battery?

Tue Nov 29, 2011 11:17 pm

I've used the DS1307 with a PIC and it was easy to use and a simple circuit. Writing code in a high-level language to set the time and so on would be great too, because doing it in PIC ASM was a pain!

Nutmeat
Posts: 35
Joined: Tue Oct 18, 2011 2:36 pm

Re: How to add clock backed by battery?

Wed Nov 30, 2011 4:40 am

I'm going to derail here.Quote from cnxsoft on November 29, 2011, 04:37
That one is 7.9 USD.
http://www.futurlec.com/Mini_D.....1307.shtml
That website rocks.
Wow, does the Raspi kick @ss.
You've got to check out some of the ARM boards there.
Are those tremors I'm feeling? Epicenter is Raspi HQ, UK?

User avatar
walney
Posts: 233
Joined: Wed Nov 30, 2011 6:57 pm
Contact: Website

Re: How to add clock backed by battery?

Wed Nov 30, 2011 7:45 pm

More expensive in the UK... I'm thinking laterally: maybe get a bluenext BN-903S (under £20) and hope that gpsd will work. That way you can get the lat and long, together with a timestamp and then work out the timezone. And instead of just a clock chip, get something with a bit more utility (car satnav!)

Of course, that's probably all just wishful thinking on my part :'(

User avatar
crundy
Posts: 310
Joined: Fri Aug 12, 2011 7:47 am

Re: How to add clock backed by battery?

Wed Dec 14, 2011 10:53 am

Sorry to dig this up again, but I did find this:
http://www.hobbytronics.co.uk/.....time-clock
About ten quid with free delivery.

Edit: Looking at the connectors on that board, I see an "SQW" connection which I don't see on the R-Pi pinouts. Does it need to be connected to the board?

User avatar
crundy
Posts: 310
Joined: Fri Aug 12, 2011 7:47 am

Re: How to add clock backed by battery?

Wed Dec 14, 2011 11:09 am

Nvm about the edit, just saw that you do leave it out:
http://wiring.org.co/learning/.....clock.html

DaveB
Posts: 29
Joined: Wed Sep 14, 2011 8:40 pm

Re: How to add clock backed by battery?

Wed Dec 14, 2011 11:12 pm

Quote from crundy on December 14, 2011, 11:09
Nvm about the edit, just saw that you do leave it out:
http://wiring.org.co/learning/.....clock.html

I think that you might also need a level converter, as this module runs at 5V and the PI runs at 3.3V (for the I2C interface). Something like this: http://www.hobbytronics.co.uk/.....word=level

RichC
Posts: 20
Joined: Thu Jul 28, 2011 9:20 am

Re: How to add clock backed by battery?

Thu Dec 15, 2011 12:00 am

You don't have to use a battery; for shorter backup times you could use a relatively cheap 0.1 Farad capacitor. Q = It = 0.5CV^2 so if you have 1V difference between normal supply and minimum standby, 0.1 farad and 1 microamp gives 13 hours backup.

RTC 32.768kHz watch crystals used to be cheap and nasty, so be aware of inaccurate time and if you're making a board follow the RTC manufacturer's recommended PCB layout.

User avatar
crundy
Posts: 310
Joined: Fri Aug 12, 2011 7:47 am

Re: How to add clock backed by battery?

Thu Dec 15, 2011 11:06 am

Quote from DaveB on December 14, 2011, 23:12
Quote from crundy on December 14, 2011, 11:09
Nvm about the edit, just saw that you do leave it out:
http://wiring.org.co/learning/.....clock.html

I think that you might also need a level converter, as this module runs at 5V and the PI runs at 3.3V (for the I2C interface). Something like this: http://www.hobbytronics.co.uk/.....word=level

The page about pinouts does say there is a 5v connector (5V0):
http://www.raspberrypi.org/archives/384
Am I getting confused?

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to add clock backed by battery?

Thu Dec 15, 2011 3:00 pm

You are, and are not :P

You are correct, the R-pi uses a 5V input which comes into the board, and powers a 5v rail (USB. HDMI, and two GPIO pins repurposed to be 5v sink/source pins) before running off to a 5v to 3v3 regulator... we think ;) A lot of this is speculation, but it's very intelligent speculation. So what's going on here is dave is assuming the clock will be attached after this voltage step down and you're assuming you'll connect to the existing 5v rail. Either will technically work, but if it's just a matter of providing power to the board you linked (which I haven't really looked at too closely, but that appears to be all at first glance) then you would be just fine using those two GPIO pins I mentioned to wire this board to and get 5v power.
Dear forum: Play nice ;-)

DaveB
Posts: 29
Joined: Wed Sep 14, 2011 8:40 pm

Re: How to add clock backed by battery?

Thu Dec 15, 2011 6:11 pm

I was looking at this http://elinux.org/RaspberryPiB.....PI.2C_UART which suggests that the I2C interface pins (SDA0 and SCL0) will run at 3.3V. Is that not the case?

Edit: To clarify: I think you will need to supply 3.3V to the Pi side of the level converter and 5V to the clock side of the level converter and the clock itself.

arm2
Posts: 253
Joined: Thu Dec 15, 2011 3:46 pm

Re: How to add clock backed by battery?

Thu Dec 15, 2011 8:42 pm

I’ve got a prototype Reat Time Clock Module here, that I hope to send in the next few days to one of the developers who is going to get a Beta board, so they can test it!
The RTC module will be available commercially. We are considering offering the bare PCB but as the DS1338 is only available in surface mount and not that readily available we're not sure how practical that would be.
n.b. We ruled out the DS1307 because of the problems mention and are using the DS1338


DaveB
Posts: 29
Joined: Wed Sep 14, 2011 8:40 pm

Re: How to add clock backed by battery?

Thu Dec 15, 2011 10:38 pm

Quote from crundy on December 15, 2011, 22:10
Hmm, would this work then?

http://www.ebay.co.uk/itm/3-3V.....0762577188

It looks like it should do: I2C interface, runs at 3.3V and supported by Linux.

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: How to add clock backed by battery?

Thu Dec 15, 2011 11:16 pm

Quote from arm2 on December 15, 2011, 20:42
I’ve got a prototype Reat Time Clock Module here, that I hope to send in the next few days to one of the developers who is going to get a Beta board, so they can test it!
The RTC module will be available commercially. We are considering offering the bare PCB but as the DS1338 is only available in surface mount and not that readily available we're not sure how practical that would be.
n.b. We ruled out the DS1307 because of the problems mention and are using the DS1338


As long as it's the SOIC package with 50 mil (1.27mm) spacing on the pins soldering isn't hard.

Return to “Other projects”