NTPQ, NTP, and GPS Issue


I am having an issue where, periodically and unpredictably, I am unable to check the NTP to see where timing is coming from/how the timing is going (and also the timing is not updating). The most common error I get is:

myshake@rs:/opt $ ntpq -p
ntpq: read: Connection refused

This also happens if I precede the command with sudo.

I (am trying to) use GPS timing in offline mode. Below are the main “non-default” settings of the shake. Otherwise, I am using a gps antenna purchased from raspberry shake. When this happens, I can usually fix it via instructions here, namely:

$ sudo systemctl stop ntp
$ sudo systemctl restart ntpd
$ sudo systemctl start ntp

However, this is quite annoying in field situations when I would just hope/expect the timing to work with everything connected correctly. I have not been able to figure out why it does not work (there does not seem to be a consistent reason). I suppose sometimes this may happen when I have not had the shake on in a few days, but I do not think that is the only/consistent reason.

Non-default “settings”:

1 Like

Hello rbalik, and thank you for the very detailed explanation you have provided. That’s a great installation, especially with the high microSD card capacity!

I think that what is causing the issue you are seeing is related to the fact that there is another USB device connected to the Pi alongside the GPS module. As you can read here (GPS Antenna) it is not recommended to do so for the reason pasted below:

To clarify (also for other readers) how the boot-up sequence is with a GPS module connected to the Shake:

  1. GPS module detected
  2. gpsd daemon started
  3. Timing is not “started” until gpsd reports that a lock has been achieved
  4. Only then is ntpd started

Usually, if the GPS has a good view of the sky, this happens quite fast, and the Shake continues its standard booting and then working processes.

To address your problem, could I please ask you to disconnect the WiFi dongle, turn on the Shake again with only the GPS module attached, and see if the error persists?

Could you also send two sets of log files, one with both USB devices connected, and one with only the GPS?

Thank you!

Ah, thank you for this explanation, this is very helpful. Your explanation clarified things. I had seen that warning, but I have not experienced any issues with timing with the wifi dongle outside of the ntpd not starting, so I had assumed that it as an issue with the ntpd. This makes sense, though, that it is not detecting it.

I unplugged the dongle and reset everything and I have not had a problem with GPS timing/ntpd thus far. I will try to send log files. I had some other customizations, so there may be some weird stuff in the log files. I will try to send that next week regardless.

I am going to play around with some things. If you have any advice for how to get wifi (from a dongle since internal adds noise to the data) while using GPS (there will always be GPS, so I could start gpsd automatically at boot?), this would make data acquisition much easier than connecting with the ethernet at each site to do a graceful shutdown…let me know! I am going to paly around with some things in the meantime. I


Hello rbalik,

It’s great to hear that the GPS time data returns to full working status by unplugging the WiFi dongle. That common buffer was behind the timing issue, as (now we know) the signal was lost when the buffer switched between the GPS module/WiFi dongle.

At this point, if you want to keep the WiFi solution for your Shake, I think you are restrained to:

  • Visit the unit
  • Connect the wifi
  • Copy the data off the unit to your laptop
  • Reboot the unit / remove the wifi dongle

But, at this point, I feel it would be way easier to quick connect an Ethernet cable, copy all the data, and disconnect it.

If you find anything WiFi-side, please let us know!

Thank you. I suppose I will use the ethernet for now.

I think what I may end up doing is using a switch and an OR gate (or something like that) into one of the open GPIO pins. To make a “smart” off switch that first does a graceful shutdown, then turns off the power. We’ll see how that goes.