I need to measure with accuracy the simultaneity of two physical events. In order to do this I need 2 arduinos (MKR wifi 1010) to be able to make measurements at 1kHz and to timestamp the samples precisely (to the millisecond). The 2 arduinos cannot be connected directly, only a wireless link is possible.
The measurement takes about 5 seconds, then each arduino sends its data by wifi to a collecting system.
So I need my 2 arduinos clocks to be synchronized (no more than 5ms out of sync). I think that NTP synchronization will give me an acceptable accuracy.
Now I would like to use the RTC of the samd21 to give me the time to the millisecond, and here is my problem.
According to the datasheet, the RTC can either behave like a clock/calendar (which is accurate only to the second, not to the millisecond), or like a counter whose frequency is a sub-multiple of 32,768 Hz! So for example I can have a counter that increments to 1024Hz (with the correct prescaler setting), but how do I make a clock with that? Is there a simple trick?
PS: I've told you the whole story to avoid XY problems. If you have any other ideas on how to precisely synchronize 2 arduinos I'm also interested!
PS2 : English is not my mother tongue, please forgive my mistakes.