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.
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
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.