Nordic Thingy 53 time synchronization

We would like to synchronize several Nordic thingys 53. The Approach is to send two timestamps from a central to them (peripheral) via Bluetooth Low Energy with 100 ms delay. Storing the two reference timestamps (t_ref) together with the local timestamps (t_local). Calculating a timeoffset (t_local_2 - t_local_1) - (t_ref_2 - t_ref_1) = time_offset. This offset is added to k_uptime_get() to calculate the current time.

To receive the current time, the thingy have a writeable characteristic accepting 8 bytes of data. Within the thingy a write callback stores the values in variables together with the current local time of the thingy. Normally, I would assume that the delay between the two reference times is bigger than the difference between the local times because of the transmission of both times via Bluetooth. In contrast to that, the differences of the local time (=180 ms) are much smaller than the difference of the reference times (= 800+ ms). The times are transmitted correctly. This has been checked. May that induced by an wrong time calculation/tick rate factor of the thingy?

Parents Reply
  • Finally, I found one of the biggest issues: an error in my calculations. The final calculation is below. Still, there is an error of around 60 ms, i.e., the difference of the reference times are 180 ms but the difference in receiving is only 120 ms. using 7.5 ms connection interval.

    long dif_ref = time_sync.second_time_ref - time_sync.first_time_ref;
    long dif_loc = time_sync.second_time_local - time_sync.first_time_local;
    long trans_time = dif_loc - dif_ref;
    time_sync.time_offset = time_sync.first_time_ref -
    time_sync.first_time_local + trans_time;

Children
No Data
Related