Timestamps in signalK feed

279 views
Skip to first unread message

Johan Barne

unread,
Dec 16, 2015, 6:13:25 AM12/16/15
to Signal K
I have the signalk-server-node running on my raspberry pi with a gps connected.
In the signalk feed, the timestamps coming out are ZULU times. I assume that the conversion from the GPS UTC timestamp to ZULU times are done using the timezone of the server...

Wouldn't it make sense to have the server outputting UTC timestamps, just as a NMEA feed from a GPS would?

Hubert

unread,
Dec 17, 2015, 9:48:01 AM12/17/15
to Signal K
Johan,

UTC and Zulu are the same - or do I miss something from your posting?

From Wikipdia:
"....
The time zone using UTC is sometimes denoted UTC±00:00 or by the letter Z — a reference to the equivalent nautical time zone (GMT), which has been denoted by a Z since about 1950. Time zones were identified by successive letters of the alphabet and the Greenwich time zone was marked by a Z as it was the point of origin. The letter also refers to the "zone description" of zero hours, which has been used since 1920 (see time zone history). Since the NATO phonetic alphabet word for Z is "Zulu", UTC is sometimes known as "Zulu time".
...."

Johan Barne

unread,
Dec 19, 2015, 9:25:33 PM12/19/15
to Signal K
Sorry Hubert!

You are right in that Zulu is same as UTC.

The problem I have is that I have put a signalK server on a raspberry pi. After starting the raspberry pi again after it has been powered down, it does not have the proper time due to the power loss. I though I could use the GPS timestamp from the signalK feed. ...but the timestamp does not come from the GPS available but rather the (incorrect) time from the raspberry pi.

Is there a way around this?

Cheers,

/Johan

Jeremy Boynes

unread,
Dec 20, 2015, 1:40:38 AM12/20/15
to sig...@googlegroups.com
The Pi does not have a hardware real-time clock (RTC) so will lose its notion of time whenever the power is disconnected. It will resync itself on boot using ntp but that will only work if it has access to a ntp server.

In the Java server, setting the config.server.clock.source property in signalk-config.json to "rmc" will cause it to reset the system time from the first NMEA RMC message if there is sufficient skew (which there would be on startup as the clock gets reset to 1970). I don't know if the Node server does anything similar.

--
You received this message because you are subscribed to the Google Groups "Signal K" group.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Teppo Kurki

unread,
Dec 20, 2015, 3:30:08 AM12/20/15
to signalk
Are you looking for the possibility to set your Raspberry's time from GPS or have the GPS time available for some Signal K consuming software?

I don't think Signal K is the way to go about setting your clock. Java server's ability to do so is incidental.


This is the main reason I prefer using gpsd to interface with nmea0183 sources - with gpsd other software has a well known way access to the data and not try to make Signal K software do everything.

Johan Barne

unread,
Dec 28, 2015, 4:56:32 PM12/28/15
to Signal K
Thanks Jeremy for your answer. Such a setting would work for me on the node server. Is there such a setting there, Fabian?

To explain what I am trying to achieve: I have developed a weather station using an Airmar 200WX sensor connected to a Raspberry Pi. The Raspberry Pi has the SignalK Node server and a normal web server serving time plots of wind speed and -direction (using the Smootie Charts JavaScript library) to tablets or mobile phones. These clients connects to the Raspberri Pi through a WLAN USB stick acting as an access point.

However, in order to always get the history in the graphs, I am constantly storing the data in a MySQL database. If the server or client gets offline and then online again, the web page loads the history data and the continues to top up with new data.

All works well but in order to get the historic data right, I need to set the clock manually on the Raspberry Pi after boot (within a couple of seconds). Seems like a waste since the GPS is already there with its time stamp. The problem is that the SignalK server pipes out time stamps but not according to the time on the server and not from the GPS.

rob...@42.co.nz

unread,
Dec 28, 2015, 5:44:50 PM12/28/15
to Signal K
Johan,

The java-server sets time from the GPS (optionally) and its not difficult to setup so I imagine it can be added to the node server too. But from a discussion elsewhere (I forget where) the GPS signal is really only accurate to 1 sec, and only after 20 min. Its initial value can be out by some significant amount. My code currently  sets the time by the first GPS time, it should probably wait, or check/sync as the GPS time stabilises. Worth thinking about if you are saving timestamped data to a db.

Alternatively adding a RTC (real time clock) is pretty cheap, only a few dollars. It could still sync in on GPS time, but would be more reliable/stable across reboots.

Rob

Johan Barne

unread,
Dec 28, 2015, 6:16:29 PM12/28/15
to Signal K
Thanks Teppo and Rob for your thoughts and suggestions.

Teppo: Your solution could work but I guess I just have to make sure that the serial port gets properly released before the SignalK server takes over.

Rob: Good point on GPS accuracy. If I can access it, I'm pretty sure it is good enough for my purposes but in other implementations it could be something to be aware of.

Teppo Kurki

unread,
Dec 29, 2015, 1:58:21 AM12/29/15
to signalk
Teppo: Your solution could work but I guess I just have to make sure that the serial port gets properly released before the SignalK server takes over.

If you use gpsd that is not a problem. Gpsd reads the serial port and node server & the independent time setting script (the solution I linked uses gpspipe) connect to gpsd via socket.

But getting things to happen in the correct order might be a bit of trouble.

What you could do with node server is add an element to the input/provider pipe that takes care of setting the system time and will block input data until the system time is set.

So upon startup of node server it would not pass any nmea0183 data to be processed by the server until it has successfully set  system time.

The place to insert this "time-setting valve" would be 

and you can check
https://github.com/SignalK/signalk-server-node/blob/master/providers/from_json.js
for a minimal example of a pipe element.
Reply all
Reply to author
Forward
0 new messages