How to Synchronize Raspberry Pi Time with rdate

Introduction

Raspberry pi is popular IOT device that power up many project from hobbies project to time sensitive sensor network and automation industry. It is a small footprint device run under operating system your choice - raspbian linux or windows core IOT. However, Raspberry pi lack of hardware real time clock. Due to the fact Raspberry pi offer many advantage of small and powerful device, many developer look for a solution to synchronize device time with reference computer. We will talking about how to synchronize Raspberry pi with windows desktop using rdate.

Installation

We need a Raspberry pi run on Raspbian operating system.

Above diagram show cluster of Raspberry pi run on rdate, synchronize time with windows pc run on rdate as well.

First step. Update the Raspberry Pi system.

  • sudo apt-get update

Install Rdate on Raspberry Pi

  • sudo apt-get install rdate

Create time synch script.

  • sudo nano synch.sh

Insert these line. xxx.xxx.xxx.xxx is an ip address of windows machine.

  • sudo rdate -s xxx.xxx.xxx.xxx > /dev/null
  • hwclock – systohc > /dev/null

Setup cron job to syncrhonized time every minute.

  • * * * * * . /path/to/script/synch.sh

Install Rdate on Windows

Windows computer serve as a server for number of Raspberry pi client. This machine use as time server, synchronized itself with cloud time server. We need to install Rdate service and refer all raspberry pi device to this machine. Next step, download small utility from this website.

Copy rfc868time.exe file to specific directory and install

  • rfc868time -install

Start the service.

Refer windows ip address on “sudo rdate -s xxx.xxx.xxx.xxx” above.  

Test date

You should able to change date on windows machine and check on every raspberry pi date.

Run date command on terminal.

  • $date

Change date on windows machine, wait for a while until raspberry pi date synchronized (this is base on cron job interval).

Run “date” command again to find out.

Conclusion

On above example we went through steps to synchronize number on Raspberry pi device with windows machine.