Configure Rapberry Pi to take time from Windows PC

1

I have a Raspberry Pi and Windows 10 machine, they will be connect directly via RJ45 and on the same subnet so they can communicate. They will both be completely offline with no access internet access, however it is important that the time on the Raspberry Pi is accurate.

I'm aware the PC will hold the time better than the Raspberry Pi, so I was hoping I could set up a way for the Pi to take its time from the PC. Is this possible?

cryptiblinux

Posted 2018-07-30T14:10:53.393

Reputation: 11

1Welcome to Super User! I see you've tagged your question ntp- have you tried anything to do with this yet? – bertieb – 2018-07-30T14:18:55.707

I'm aware that you can configure the Pi to use a specific address, but how would I set up the Windows PC to handle the requests? – cryptiblinux – 2018-07-30T14:41:34.157

Answers

1

Windows Can Serve Time via Windows Time Service / w32tm

There is an old MSDN blog entry by Ryan Sizemore about running Windows as a time server:

Recently, I had a customer ask if they can use w32time as a time source for other computer & devices on their network. The Windows Time Service is fully capable of acting as a time source for anything that is NTPv3 compliant.

Running a server

  1. Start the w32tm service

    You can start the Windows Time service from the Services area of the control panel.

  2. Verify via elevated command prompt / powershell

    Win + x will give you an option of Command prompt (Admin), where you can enter:

    w32tm /query /configuration
    

    You are looking for a line which reads:

    Enabled: 1 (Local)
    
  3. If not enabled, you can query the registry and add the right key if necessary:

    query: reg query HKLM\system\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer

    add: reg add HKLM\system\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer /v Enabled /t REG_DWORD /d 0x1 /f

    update: w32tm /config /update

Use the Windows PC as a time source for the Pi

You say you are already aware of how to get the Pi to use a particular address, but if you are running a Debian-based Pi distro (eg Raspbian), you can usually use ntpdate, eg

 # ntpdate windowsPCaddr

when elevated (ie either root / sudo); where windowsPCaddr is the address of the Windows PC that you have determined already.

Troubleshooting

I was able to find and start the service on a fresh install of Windows 10. However you might get

The following error occurred: The serveice has note been started. (0x80070426)

in which case you need to start the service from the Services section of the control panel (or it can be found from the Start menu by searching for 'Services'- it is listed as a 'Desktop app').

Others have run into the following error:

w32tm does not exist as an installed service

In this case, the command to use is:

w32tm /register

[this is] the actual way to install it (using a command prompt which was Run as Administrator). Sometimes you need a reboot to put things in order, but I actually just waited a while without rebooting.

With credit to Tomasz Gandor's answer.

bertieb

Posted 2018-07-30T14:10:53.393

Reputation: 6 181

Thanks for this @bertieb. Do you know how likely there is to be time slippage from a Windows 10 PC that is completely offline? – cryptiblinux – 2018-07-30T15:27:52.877

@cryptiblinux that's a separate question - which you could consider asking - which I don't know the answer to. I suspect it would depend on hardware. – bertieb – 2018-08-11T13:56:59.190