12

If you have a device connected to a network, the answer is obvious - use NTP.

If you don't have a network connection, I can think of 3 ways to get the current date and time:

  • Radio signal, i.e. WWV or WWVH in the US.
  • GPS.
  • Cell phone signal.

I don't know any of the pros and cons of each method, i.e. the availability and cost of chipsets or if you need a cell phone subscription to eavesdrop on a cell tower transmission.

Mark Ransom
  • 359
  • 1
  • 7
  • I wonder if RDS (Radio Data System) is a viable option. Many radio receivers can set the clock using the date and time received from a FM station. – lhballoti Jun 14 '12 at 14:45
  • @lhballoti, how would you know which FM station to tune? – Mark Ransom Jun 14 '12 at 14:49
  • Well, I wouldn't. The device would have to seek for a radio station in a preset frequency range until the RDS data could be decoded. If no time data is available, it would then look for another station. I realize all this is easier said than done, which is why I posted a comment instead of an answer. ;) – lhballoti Jun 14 '12 at 15:39
  • 3
    A possible problem with RDS is that you get the time of the radio station's time zone. With my previous car, when I tuned to a UK radio station (I'm in Belgium) my clock would offset by an hour, and there was no to adjust it. – stevenvh Jun 14 '12 at 16:37
  • I just wanted to mention that the GPS time and UTC very slowly drift apart (about 15 seconds difference over 32 years): http://en.wikipedia.org/wiki/GPS_time#Timekeeping – 0x6d64 Jun 15 '12 at 09:18
  • This is more a question than an answer but i'm wondering how feasible it would be to "sniff" time data from random cell tower transmissions, is that data encrypted? – pault Jun 15 '12 at 01:11
  • With RDS (and the equivalent service that might be present on TV stations) you are trusting that some broadcast engineer has remembered that the station does that and keeps the necessary equipment maintained. I've read anecdotes about VCRs (yes, that old) getting reset by 10 minutes or so because two stations in the market broadcast different times of day. Adding insult to injury, both were wrong.... The situation *may* have improved. – RBerteig May 15 '14 at 00:40

3 Answers3

11

I would use WWVB (actually DCF77, since I'm in Europe). You can buy compact low power receivers for 10 to 15 dollar. This one is GBP 7.95 (USD 12.50).

enter image description here

It works at 3 V to 5 V, and has an enable input to switch down from a few mA to less than a \$\mu\$A. Thanks to its small size it can easily be built in into your product.

GPS may not have reception inside.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
6

Those are the three usual suspects, so here it goes:

Radio signal

These are usually generated by NIST or some other Government agency who is very concerned about timing, so I expect them to be very accurate, however, from what I remember the resolution was the problem. They broadcast updates like every minute. So you can sync to an accurate time reference, but you're responsible for any drift in-between those updates. If your system can handle that, then great. One advantage of these signals are that they are much lower frequency than the other two methods, so if you're system is going to be inside of building most of the time or in some really remote area, you'll get much better reception than you would with GPS/Cellular, who both require either a semi-clear view of the sky or a cell tower in relatively close proximity, respectively. Also, these modules might be harder to find as these standards are not the hot new features that are a must have for every new Android/iPhone, so you might want to think about supply/lead-time concerns for your project.

GPS

Very accurate timing. Definitely your best bet if you need a continuous accurate timing reference. Modules are easy to get, fairly inexpensive and a 1 time hit in cost. I would do this if you think you'll always have a reliable view of the sky and I would choose this over cellular as they're both probably just as easy to implement (probably just a UART talking to the peripheral) but you won't have to worry about paying for service. Additionally most modules give you an accurate frequency reference (1PPS and 10 MHz) which you could use to clock your processor with for increased accuracy (which you won't get with either of the other two options).

Cellular

Interestingly enough these tend to have extremely high accuracy (most need to as they operate on a TDM scheme). The biggest drawback I see here is that I BELIEVE you'll have to pay for service. Someone might know differently as you may not need service to get timing since (by some law...possibly FCC mandate) cell carriers are required to let 911 call through. Which means you may be able to associate with a tower and possibly get timing, just no calls. It would be worth buying an eval kit and testing this. A pro here might be communication down the road. If you feel like paying the service fee, then if you ever have a unit break it could always message you back and let you know something suspicious happened. There may also be cheap, text/data only plans available through carriers as many OEM manufacturers (think Amazon Kindle for example) want data connectivity without audio. So you might do some research and find out that the pricing isn't all that bad and fits within your budget.

Ricardo
  • 6,134
  • 19
  • 52
  • 85
Joel B
  • 3,477
  • 2
  • 29
  • 37
  • Not all GPS give solid time reference. Often the easiest way to find one is to look for one that says it can PPS. On top of that you need to ensure that their accuracy is high enough. I have seen a GPS that had an error of 200mS which was useless in our application. – Kortuk Jun 15 '12 at 19:51
  • 2
    You don't need an account for cellular time. In fact, you don't even need a transceiver just listening to the cell towers broadcast will get you the time. – longneck Jun 20 '12 at 19:46
  • You don't synchronize to the second with WWVB, you sync to the 50khz carrier wave. It is very stable over the short and long term. – John Meacham Jul 07 '14 at 17:46
4

Radio signal is probably going to be the cheapest to implement. And it works indoors. But it's very subject to atmospheric conditions. I have a digital weather station that contacts WWV and it occasionally complains that it can't get the time. However I have a weak signal even on the best of days. I'm on the east coast and it's trying to contact Colorado.

GPS is going to be more reliable as long as you're outdoors. Indoors would be hit or miss depending on the chipset and antenna you use. It has the added benefit of giving you location data.

Cell phone signal, I'm 90% certain you need a subscription to voice data to receive the time. Here is an SO comment to that effect: https://stackoverflow.com/questions/6430169/get-local-time-from-the-cell-phone-carrier-cell-tower-gprs-on-a-windows-mobile That would make cell signal the most expensive to implement. It's also dependent on cell tower coverage so it wouldn't be as reliable over as wide a range of locations as GPS but would be comparable to radio.

embedded.kyle
  • 8,411
  • 2
  • 26
  • 44
  • 3
    This brings up a good point - if you need local time, WWV won't help and GPS will require a complex location to zone mapping, while cell phone gives it to you automatically. – Mark Ransom Jun 14 '12 at 14:53
  • @MarkRansom: What do cell modems do if the two closest towers are in different time zones? – supercat Jun 15 '12 at 01:22
  • @supercat, if it were a phone you wouldn't talk to both towers, you'd be assigned to one or the other. I don't know there are any time zones that straddle a populated areas so maybe it's a rare problem. – Mark Ransom Jun 15 '12 at 02:36
  • @supercat It is a rare problem as Mark has suggested but it does exist and I'm not sure of the solution. The most complicated place in time is Indiana. It straddles two time zones and some counties observer daylight savings time and some don't. Though I think recently they've all gotten on the same page as far as daylight savings time. If you're interested in how it's handled, Indiana is the place to study. – embedded.kyle Jun 15 '12 at 13:52