Synchronizing Time Clocks

Hi everyone. I'm looking for some general guidance or advice on using an arduino to synchronize the internal time clocks on multiple sensors / devices so that all of my sensor outputs are referencing the same time point (e.g., each of my sensors will use their synchronized internal clock to stamp the measurements it takes).

Here is more information on what I know the sensors require (from their user manuals):

Device 1: Can synchronize it's internal clock based on a 1 Hz rising edge input and a serial input (string containing a timestamp for the rising edge).
Device 2: Similar to Device 1, except the string is specified slightly differently.
Device 3: Similar to Device 1, but is 10 Hz instead of 1.
Device 4: My computer - I was planning on using chrony (not sure what configuration yet).

I'm new to arduino, but I do know that generating a rising edge and writing to serial are both straight forward. My main questions now are:

  • How do I do this with as much precision as possible? i.e., How do I make sure that my signals are being sent exactly every 1 second, and how do I make sure the timestamp (using the arduino clock) for the edge trigger is as precise as possible.
  • Is there a specific model of arduino that would be best suited for this? I have access to a zero, an uno, and a teensy, and could probably get a different one if needed.

Thanks for any advice :slight_smile:

Will Your 4 sensors send time as a part of the data package?
If not, why not let the receiving controller keep the time and stamp the received data when they are received?

research w8bh clock. it is not as precise as he claims, but having DST and local time zone sorted out is good
research the Time library. set master time with the w8bh clock, then sync the other clocks to themaster by setting time_t now() on the slaves to the master

or, synch to the internet with chronyc, and sync the slaves to the computer that gets NTP

Or more to the point, post a useful question.

  • What is the purpose of your system?
  • What degree of accuracy is required and why?
  • What are the sensors? Cite the specification sheets.

Only then is it possible to advise. If you don't wish to provide the necessary details, you are on your own. :roll_eyes:

You might find it useful to study how time propagates through this simple wireless network (radios need not be involved).

The drawback is that it uses String objects, which lead to memory problems and crashes. If interested, I’ve attached a cleaned up version using reliable C-strings.

Note: the Instructable above is one of a microscopic few worth recommending.

APC220Mesh_JR5.ino (12.1 KB)

Instead of Strings consider a uint32 (4 bytes). Resolution will be to the second. Higher resolution will likely require a larger data type.