kghunt
Posts: 383
Joined: Sun Mar 04, 2012 9:28 am

Re: Real Time Clock using USB gps dongle

Thu Mar 29, 2012 8:03 pm

Heres an idea... A gps dongle can be had for around a tenner these days an the gps signal contains the time. It shouldn"t be that hard to write a script to be called once the gps had grabbed the time to then set the system clock. I know it"s not as reliable as a proper rtc but useful an easy to implement, with the added benefit of have GPS for other uses too.

Lynbarn
Posts: 464
Joined: Wed Jan 04, 2012 11:03 pm
Contact: Website

Re: Real Time Clock using USB gps dongle

Thu Mar 29, 2012 8:36 pm

kghunt said:


Heres an idea… A gps dongle can be had for around a tenner these days an the gps signal contains the time. It shouldn"t be that hard to write a script to be called once the gps had grabbed the time to then set the system clock. I know it"s not as reliable as a proper rtc but useful an easy to implement, with the added benefit of have GPS for other uses too.


That would be a neat solution, providing the dongle can "see" the satellites (i.e. you might need a long USB lead to hang the dongle out of a window during the boot sequence.)

One of the problems of not having an RTC is that time-stamping can get all in a dither – newer files and entries in system logs etc. have earlier dates than older ones, etc.

I don't know how long it would take a GPS dongle to acquire the satellites and update the system time, but it could be several minutes. It would probably be better to wait for that to happen before any files were updated.

A partial soluition to that may be to periodically (say 20 seconds )save the current time to a file. When the system boots, it reads that file, and adds (say) 30 seconds on, to give a unique and incrementing time-stamp, then picks up the GPS time as soon as it is available.

inco
Posts: 3
Joined: Wed Jan 25, 2012 1:25 am

Re: Real Time Clock using USB gps dongle

Thu Mar 29, 2012 9:36 pm

I have used a similar solution for a router without a RTC. In this case the router is connected to a DSLR camera, when the system boots, a script, using gphoto2, asks the camera for the current time and sets the system time using the camera time.

mole125
Posts: 228
Joined: Tue Jan 10, 2012 2:01 pm

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 5:26 am

Lynbarn said:


I don"t know how long it would take a GPS dongle to acquire the satellites and update the system time, but it could be several minutes. It would probably be better to wait for that to happen before any files were updated.


This may not be too much of a problem as we are only trying to get time not position and therefore only need to briefly see a single satellite, not multiple of them at the same point in time.

Signal penetration into buildings (or forests) is still not generally great though and may be a problem, particularly if the receiver is in a box designed to block EM radiation.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23421
Joined: Sat Jul 30, 2011 7:41 pm

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 9:23 am

Lynbarn said:


kghunt said:


Heres an idea… A gps dongle can be had for around a tenner these days an the gps signal contains the time. It shouldn"t be that hard to write a script to be called once the gps had grabbed the time to then set the system clock. I know it"s not as reliable as a proper rtc but useful an easy to implement, with the added benefit of have GPS for other uses too.


That would be a neat solution, providing the dongle can "see" the satellites (i.e. you might need a long USB lead to hang the dongle out of a window during the boot sequence.)

One of the problems of not having an RTC is that time-stamping can get all in a dither – newer files and entries in system logs etc. have earlier dates than older ones, etc.

I don"t know how long it would take a GPS dongle to acquire the satellites and update the system time, but it could be several minutes. It would probably be better to wait for that to happen before any files were updated.

A partial soluition to that may be to periodically (say 20 seconds )save the current time to a file. When the system boots, it reads that file, and adds (say) 30 seconds on, to give a unique and incrementing time-stamp, then picks up the GPS time as soon as it is available.


Latest Debian we are using here at Broadcom does something similar - it reads the last log message and uses the time from that.

GPS dongles do work - got one running on a Raspi this week.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

kghunt
Posts: 383
Joined: Sun Mar 04, 2012 9:28 am

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 10:40 am

I think this will be a fun little thing to try out especially with chines gps dongles are cheap as chips and like mole125 says we only want the time and not a position so it might be more effective than we think. I have locked onto gps in buildings quite a few times and that requires multiple satellites and a strong signal. All we need is one with a strong enough signal to grab the time.

I wonder if there are any FM services that transmit the time or may DVB services.

plugwash
Forum Moderator
Forum Moderator
Posts: 3439
Joined: Wed Dec 28, 2011 11:45 pm

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 10:49 am

Afaict most GPS receivers look like a USB-serial converter and should work fine on arm linux. Just a matter of writing some software to read the messages (they are in a standard format IIRC) and set the time then modifying the boot process to run it.

To me this mostly sounds useful for vehicle mouted or remote applications. Within a serviced building NTP over ethernet or wifi is almost certainly a better bet.

There are also dedicated radio signals used by radio controlled clocks which seem to pick up OK indoors it may be worth checking those out (though finding cheap standalone receivers seemed to be tricky last time I checked)

kghunt
Posts: 383
Joined: Sun Mar 04, 2012 9:28 am

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 11:28 am

Check this page out. It details how to build a device to pick up the 60 Khz signal broadcast in the uk that sets alarm clocks and the like. Then how to use that signal to set the time on a linux computer.

Awesome. The guy quotes a cost of around £30 to make but Im sure using RS rather than Maplins for the parts it could be done for cheaper.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23421
Joined: Sat Jul 30, 2011 7:41 pm

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 11:38 am

http://www.ebay.co.uk/itm/MSF-.....411wt_1396

Not USB, but probably easy to connect to the GPIO's.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."


mole125
Posts: 228
Joined: Tue Jan 10, 2012 2:01 pm

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 11:43 am

You can probably also just buy a radio controlled clock from argos (http://www.argos.co.uk/Product.....er=2552790 or http://www.argos.co.uk/Product.....er=2555591) and then take it apart for the components - looks like James' ebay link is cheaper but you may get lucky and find something cheaper still.

Would need a bit of work figuring out how to hook up with it though - don't know how standard and isolated the modules in them are (though in my experience the radio recieving seems to break independently from the clock functionality).


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

Re: Real Time Clock using USB gps dongle

Fri Mar 30, 2012 11:56 am

kghunt said:


I wonder if there are any FM services that transmit the time or may DVB services.



BBC radio does (well, radio one anyway). With the RDS unit in my car I can just poke two of the buttons on the display and it will reset the clock.

Return to “Other projects”