Time sync in the woods

586 views
Skip to first unread message

Think Survival

unread,
Apr 29, 2024, 2:38:53 AM4/29/24
to DigiPi
(A long winded preamble, with a question for Craig at the end...)

As we know, for doing digital modes with WSJT-X / JS8Call, a fairly good time sync is needed. If you're at home and have your DigiPi connected to your Wifi network, great, your job is done – DigiPi is happy to get its time sync from a Wifi network.

Away from home it's more of a challenge. I read about the cheap GPS dongle approach, and tested that successfully with a Ublox-7 GPS dongle. It's working OK, but it requires using a USB hub, since the Rpi Zero has only one USB data port. So I'd still like to find a simpler way.

One workaround I found was to have an iPhone act as a "Personal Hotspot", which means the phone can creates its own wifi network to provide a data link through its cellular data. The DigiPi can access this special Wifi network instead of your regular home one (you'll need to edit the file /etc/NetworkManager/system-connections/wlan0.nmconnection to make this change). Then the DigiPi gets assigned an IP address by the iPhone, like 172.20.10.5, and it gets its time sync from that. It can also then upload spots or do whatever other internet network activity it wants, while you're away from your home wifi network. Pretty cool.

However! If you're really off in the woods, and have no cellular service, I don't think that will work (haven't actually tested it yet). But as far as I can tell, the iPhone will only let you host a "Personal Hotspot" if you have a cellular connection. And of course, in the case of not discovering an available Wifi network to join, the DigiPi will create its own hotspot (the 10.0.0.5 one), which you can join on your phone.

So my question to Craig is: I've seen that the DigiPi is able to get time sync when it is a client on a Wifi network (whether that's a home network, or a phone's hotspot). But when it is the host of a Wifi network, is there a way that it can pull a time sync from one of the clients on the network? E.g. a phone that is connecting to its 10.0.0.5 hotspot?

Thank you!

Craig

unread,
Apr 29, 2024, 9:46:49 AM4/29/24
to Think Survival, DigiPi
lol - i like the TLDR; note for craig :) love it!

digipi will use the debian time servers if it can reach them (/etc/cronyd/cronyd.conf iirc).  after that
it will try to get time from a gps device (/etc/default/gpsd).   If it's on 10.0.0.5 hotspot mode there is
no route to the internet, so it's gps or nothing.   It may be possible to do something special and
get time from a router or phone in the future.  I tried getting time from NIST for a while (and failed).

-craig
KM6LYW
--
You received this message because you are subscribed to the Google Groups "DigiPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to digipi+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/digipi/ca014d24-f7e9-45e6-b441-7136d52725acn%40googlegroups.com.

Think Survival

unread,
Apr 29, 2024, 12:04:59 PM4/29/24
to DigiPi
:-)

If it's on 10.0.0.5 hotspot mode there is no route to the internet, so it's gps or nothing

Right, this is the part I was wondering about. Could it query the client (the phone) for the phone's time? Which presumably keeps reasonably accurate time, even when off grid.


I don't know, this might be impossible on an iOS device... but could maybe be done on macOS if chronyd was installed. (Here's an easy GUI option for that: https://www.whatroute.net/chronycontrol.html )

I'm not well versed in Linux or networking stuff, though, which is why I'm directing the question your way. Thank you!

Craig

unread,
Apr 29, 2024, 12:06:49 PM4/29/24
to Think Survival, DigiPi
ya, the phone would need to provide NTPd services for network time.  Might be more effort
than just getting a GPS... or somehow get time from another source?  I mean a phone clock and
running "sudo timedatectl set-time HH:MM:SS" at the right moment works too.

Craig

unread,
Apr 29, 2024, 12:13:59 PM4/29/24
to Chris Hoffman, Think Survival, DigiPi
+1

if you get ntp running on a phone, you can edit /etc/chronyd/chrony.conf and change


# Use Debian vendor zone.
pool 2.debian.pool.ntp.org iburst

to 10.0.0.whatever your phone is.


That file also has
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA


which says to read your gps too


-craig

On 4/29/24 09:06, Chris Hoffman wrote:
I think Craig mentioned in one of his videos that you need the gps dongle connected only at startup to set the system clock on the pi.  

Once the clock is set, you can disconnect the usb dongle and connect the radio. The clock should hold the correct time while running.  I’m not sure what the drift is on the system clock, but it is probably good enough for running ft8 for a few hours. 
  

What changes do you need to make to  /etc/NetworkManager/system-connections/wlan0.nmconnection to make it work with the iPhone as a hotspot?  

Chris
Wa2sem

Think Survival

unread,
Apr 29, 2024, 2:19:52 PM4/29/24
to DigiPi
> I mean a phone clock and running "sudo timedatectl set-time HH:MM:SS" at the right moment works too.

Yah, I've tried the manual approach to time syncing as well. I found the timing hard to get right.

And also as soon you run timedatectl set-time, you get booted from the shell session. That makes it time consuming to figure out the time lag by trial and error, since you need to reopen the shell and log back in after each attempt. In practice I found it to be not a fun way to spend time in the field.

In JS8Call at least there are some time sync options within the app – including a button to tap at the top of the minute. It doesn't adjust system time for you, but will apply the necessary offset within the app.

Jon Adams

unread,
Apr 29, 2024, 3:52:41 PM4/29/24
to Think Survival, DigiPi
Hi TS - 

Does the PiZero have an available serial port? If so, it’s an easy thing to configure gpsd and chrony for a serial GPS, which is supported but a lot of gps modules. And, if you want full stratum 1, use the pos signal from the GPS!

Sent from my iPhone

On Apr 29, 2024, at 11:19, Think Survival <think2...@gmail.com> wrote:

> I mean a phone clock and running "sudo timedatectl set-time HH:MM:SS" at the right moment works too.

Think Survival

unread,
Apr 30, 2024, 12:13:27 AM4/30/24
to DigiPi
> Does the PiZero have an available serial port? If so, it’s an easy thing to configure gpsd and chrony for a serial GPS

I haven't done much hardware hacking on RPi's but my understanding is that their 40-pin header includes a couple GPIO pins that are specifically for serial i/o. Looks like GPIO 14 and GPIO 15, according to these docs. Is that what you mean?

The GPS dongle I have now looks like a little USB thumb drive, so that's intended to just plug in (well, with a USB A to USB micro B adapter of some kind).

Doug Reed, N0NAS.

unread,
Apr 30, 2024, 10:26:03 AM4/30/24
to DigiPi
Another option could be to wire in a RTC (Real Time Clock) Arduino module based on the DS3231 RTC chip. It is spec'ed as accurate to +-1 minute per year and includes registers to optimize the calibration even better. It uses the I2C bus for control and modules usually include a coin cell holder on the module. I haven't used one, but RasPi drivers are readily available. It isn't as accurate as GPS and the module cost is about the same as the cheap USB GPS dongle, so there is no significant cost advantage, but it is an alternative to GPS for many of the situations already discussed. The SynchroTime app can calibrate the RTC against GPS or Internet if you want to improve long-term accuracy. The RTC module could be a permanent alternative to the GPS if you occasionally calibrate it when connected to the Internet as the primary reference.
73, Doug Reed, N0NAS.

Think Survival

unread,
Apr 30, 2024, 11:32:10 AM4/30/24
to DigiPi
Nice, a Real Time Clock module could be a solid solution. While I've gotten the Ublox GPS module to work while experimenting with it, in practice it can be a bit slow to find a signal and start providing an accurate timestamp. I'll look into the RTC option.

Jon Adams

unread,
Apr 30, 2024, 6:42:37 PM4/30/24
to DigiPi
Like Doug suggests, RTC modules are an easy way to keep probably good-enough time for your purposes. These modules are really sweet and take up only the first 5 odd-numbered pins on an RPi.
Screenshot 2024-04-30 152843.png
Google RTC clock for raspberry pi and there's a number of install guides available.

As far as serial GPS, that's pretty much all I use on RPis. Here's one that works fine, there are many others.
Screenshot 2024-04-30 153200.png
This requires 4 wires between the GPS module and the RPi's serial port. If you want real accuracy, also wire up the PPS signal for sub-microsecond accuracy. 

I have both of these in my weewx RPi, which also serves as NTP server for the home network, so I don't need to connect to distant ntpd servers. There are some nice writeups on how to implement all this. Here's the one that I used last week.


You can see that this one uses the even pins 4 thru 12, which are directly across from where the RTC lands, so it's really compact. I'd share a pic of my install but am too lazy to pull the cover off the RPi case. %^) The amazing thing is that my cast Al case with its built in heatsink has just enough headroom by the pins to allow the RTC to fit in without issue. The GPS is outside the case, with the wires fished through the side slot.

Cheers and 73 - Jon N7UV

Think Survival

unread,
Apr 30, 2024, 11:39:20 PM4/30/24
to DigiPi
Great leads on those parts, thanks!

For a clock module, I also found this one at Adafruit, same idea as the HiLetGo one you posted: https://www.adafruit.com/product/4282

There may be a conflict though with also including the TFT screen I have on my DigiPi (this one). I'm pretty sure it sits over the same area of the pins... it may or may not actually need the same exact pins, so there could be a way to wire them both.

Chris Hoffman

unread,
May 1, 2024, 9:11:59 AM5/1/24
to Think Survival, DigiPi, Craig
I think Craig mentioned in one of his videos that you need the gps dongle connected only at startup to set the system clock on the pi.  

Once the clock is set, you can disconnect the usb dongle and connect the radio. The clock should hold the correct time while running.  I’m not sure what the drift is on the system clock, but it is probably good enough for running ft8 for a few hours. 
  

What changes do you need to make to  /etc/NetworkManager/system-connections/wlan0.nmconnection to make it work with the iPhone as a hotspot?  

Chris
Wa2sem
On Apr 29, 2024 at 9:46 AM -0400, Craig <km6...@gmail.com>, wrote:

Think Survival

unread,
May 1, 2024, 11:32:21 AM5/1/24
to DigiPi
Yeah, that could work, but as a long term solution I'd rather avoid swapping around the USB connections in the field. I guess it could be a backup option though, for cases when I can't get cellular service on my phone (and therefore can't have the phone host a personal hotspot).

The other nice thing about using the phone as a hotspot for the DigiPi is that it also leaves the phone connected to the internet for other uses, which isn't the case if your phone connects to the DigiPi's 10.0.0.5 hotspot.


> What changes do you need to make to  /etc/NetworkManager/system-connections/wlan0.nmconnection to make it work with the iPhone as a hotspot?  

Sorry if that was sounding overly complicated – you just need to update the wifi login credentials, and that's the file where they are stored. It should also work to change the wifi login through the DigiPi's web interface (the "Wifi" link at the bottom takes you to a form to fill that in).There you'll enter the wi-fi password from the iPhone's Settings > Personal Hotspot page.

The name of the wifi network will be the same as whatever you named your phone. That name is shown in small type on the Personal Hotspot page, and can be edited in Settings > General > About > Name.

 (These settings paths are taken from a phone running iOS 16, so they may have changed slightly in iOS 17, I don't know.)

Jon Adams

unread,
May 1, 2024, 6:32:42 PM5/1/24
to DigiPi
That's a fine module, the biggest issue for my particular situation is that it uses a double-row header to stack on the RPi, occupying the pins that are used for serial GPS. Secondarily, while the replaceable battery holder is super nice, it adds height to the module and doesn't quite fit into my case.
Screenshot 2024-05-01 153103.png
This case is pretty sweet and it's got cast Al pillars that rest firmly against the hot components.
Good luck on the project!

73 - Jon N7UV

Think Survival

unread,
Jun 1, 2024, 12:56:45 PM6/1/24
to DigiPi
After looking into real time clock (RTC) modules further, I think I found a connectivity solution for a DigiPi. But I need a sanity check and help finding the right cable.

My DigiPi is running on a Pi Zero 2W, and has the 1.3" TFT screen from Adafruit mounted on its row of pins. At first I thought the RTC would be incompatible with this setup, since it also needs to use some of those same pins. However, it looks like an RTC could instead be connected via the TFT board's I2C connector, since it just needs 3.3v, gnd, SDA, and SCL. Am I understanding that right?

If so, could I just take a STEMMA QT / Qwiic cable like this one, chop it on one end to get bare wires, and solder those wires to the RTC?


Then the RTC would plug into the TFT's I2C jack, and I wouldn't have to worry about competing space on the GPIO pins?

Think Survival

unread,
Jun 1, 2024, 1:03:25 PM6/1/24
to DigiPi
Actually, looking further at Adafruit, they offer a DS3231 module that already has STEMMA QT connectors, so that would simplify the wiring even further. No soldering, just plug and play with a TFT board.

Jon Adams

unread,
Jun 2, 2024, 9:50:12 AM6/2/24
to Think Survival, DigiPi
That looks like a pretty sweet widget!

Sent from my iPhone

On Jun 1, 2024, at 13:03, Think Survival <think2...@gmail.com> wrote:

Actually, looking further at Adafruit, they offer a DS3231 module that already has STEMMA QT connectors, so that would simplify the wiring even further. No soldering, just plug and play with a TFT board.
--
You received this message because you are subscribed to the Google Groups "DigiPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to digipi+un...@googlegroups.com.

William Holtman

unread,
Jun 3, 2024, 1:50:53 PM6/3/24
to DigiPi
I am using my android phone with an app (NMEA Over Network) to feed the gpsd on the DigiPi. It is quiet simple and as long as there are satellites orbiting, I have a good reference for time. I can post the instructions, if anyone is interested.

William
KG5RPO

Chris Hoffman

unread,
Jun 3, 2024, 2:09:56 PM6/3/24
to DigiPi, William Holtman
How are you connecting your phone to the Raspberry Pi?  Cable or wireless?

Chris Hoffman

William Holtman

unread,
Jun 3, 2024, 10:12:23 PM6/3/24
to DigiPi
I am connecting via WiFi, with the same network used to remote into the Digipi. The IP address referenced in both the phone app and the gpsd file is the IP address of the Digipi.

Phone setup: Download "NMEA Over Network" app. The only configuration within the app is to add the IP address of the Digipi and assign a port. If setting up to use when the Digipi is in hotspot mode, then you would add 10.0.0.5:30304. The port number at the end could be any available port, but I know that 30304 has not interfered with anything else, so far. You can add multiple addresses for your different network addresses (i.e. your digipi address when at your home network or the digipi's hotspot address).

Digipi setup: We will need to open a terminal window from the main screen by clicking on "Shell". Once you have the window open, we will issue the commands listed below and edit the gpsd file located in /etc/default:

sudo remount (Craig has explained the need for this many times before)
sudo systemctl stop gpsd
sudo systemctl stop gpsd.socket
cd /etc/default
sudo nano gpsd

Now we are in the gpsd file. Below is what the file looked like when I first opened it:
 
Screenshot_2024-06-03_21-04-11 GPSD initial.png

Then I added the following lines at the bottom (I made no other changes):

Screenshot_2024-06-03_21-06-45 gpsd added.png

As a note, I believe you can only reference one address at a time in gpsd. So, if your goal is to utilize this for remote operations, you would use "udp://10.0.0.5:30304", the digipi hotspot address and a port of your choosing (30304 works for me). Testing on you home network may be the easiest to start with. Make sure both your phone and digipi are on the same wifi network.

Once you have modified the file, we will restart the services and check that the data is flowing. Run these commands:

sudo systemctl start gpsd
sudo systemctl start gpsd.socket

The gps services are started, now type "cgps" at the command prompt to check the connection from the phone. At this point, please ensure you have the NMEA app open and visible on your phone's screen. If all went well, the shell window should produce an output similar to the screenshot below:

Screenshot_2024-06-03_20-51-53.png

Craig stated that the digipi will look toward the gps for time, if time servers are not available. This method will give you the ability to update your system time, periodically, as needed.

Lastly, credit goes to KM4ACK for digging the basic procedures out for BAP! Thanks, Jason.

Have fun playing radio in the woods!

William,

KG5RPO

Doug Reed, N0NAS.

unread,
Jun 3, 2024, 10:29:01 PM6/3/24
to DigiPi
Hi William.
It sounds like a good app to have on a phone. As long as you have a WiFi connection to the RasPi and even if the phone has no cell connection, it sounds like the app will be able to send NMEA location and time data to the RasPi. So if you have a cell phone or tablet that includes a GPS RX, you would not need a separate GPS module but it should(?) still need gpsd on the RasPi. I did a quick install of the software and it was cute to watch the info screen pop out the NMEA strings. I will note the map screen does give a 6-digit lat-lon and map data. I'd be even happier if it would display the 6 or 8 character Maidenhead Grid Square too. (I usually use a different app for that.)
Yes, please write up your directions, just in case....
73, Doug Reed, N0NAS.

On Monday, June 3, 2024 at 1:09:56 PM UTC-5 chris.h...@gmail.com wrote:
Message has been deleted

William Holtman

unread,
Jun 4, 2024, 12:43:03 PM6/4/24
to DigiPi
Hello, Doug. I posted the details a few minutes before you replied. So, you may have missed it before you posted. The app itself does not provide the Maidenhead Grid Square on the phone's screen. However, if you run "cgps" at a command prompt on the Digipi, you will see the output from the phone's gps, including a full 8 character grid square.

Thanks,

William

Think Survival

unread,
Jul 28, 2024, 12:09:45 PM7/28/24
to DigiPi
Ah, that sounds smart! I'm on iOS, and I bet there are some apps that would work for that on that platform as well. If anyone finds a good one, please post here!

Think Survival

unread,
Jul 28, 2024, 12:20:26 PM7/28/24
to DigiPi
As a followup to what I had posted above about using the Adafruit DS3231 Precision RTC, I got that working last week with an Rpi Zero 2W, and it seems great so far.

The physical connection was dead simple – I used a short 4-pin cable to connect the RTC board to the STEMMA QT connector on the 1.3" TFT display. That's it for the hookup.

Then to configure it, I just followed the instructions here – it requires editing a couple files and running a few commands:

I actually skipped their suggestion to install i2c-tools, which means I did not run the i2cdetect commands. Thankfully it all worked fine and I didn't need to that additional diagnostic info.


Parts list

Think Survival

unread,
Aug 4, 2024, 12:48:39 PM8/4/24
to DigiPi
The Adafruit DS3231 Precision RTC tested great in the field last week with FT8 and JS8Call. I had to do multiple reboots (due to radio issues – the DigiPi itself was rock solid), and with the RTC module, the DigiPi comes up instantly with perfect time sync, every time. That's what I want in the field, no more waiting for a GPS lock or (ugh) having to do timesync manually with shell commands.

Noah Bergevin

unread,
Nov 3, 2025, 1:26:56 PM (4 days ago) Nov 3
to DigiPi
I've setup several networking devices that require you to set the time, and many of them have a "Sync time from Client PC" option that sets the device's time based on the client (PC / smartphone / etc).

Maybe something simple like a web service interface that passes the client time from Javascript and posts it to a webpage that calls the "timedatectl" command on the DigiPi to set the date/time? 

I'm thinking a link at the bottom of the main page?

digipi set time link.jpg

Reply all
Reply to author
Forward
0 new messages