# nRF24L01 - Measuring distance using time elapsed

For school usage, my team and I are working on a wristband that will alert the user if they are too close to another wristband (for social distancing). The problem is measuring distance using radio waves. Since I cannot use signal strength, I'm thinking about calculating distance from time taken to transfer some data and velocity (which will be around the speed of light). I discarded the idea of using ultrasound because it is too easily interfered with by other obstacles.

My plan is along the lines of this:

• Sensor 1 and 2 are synchronised to a clock.
• Both will run a "stopwatch", and the time values should be exactly the same at the same time.
• Sensor 1 sends out a message to Sensor 2. The message contains the time at which the transmission started.
• Sensor 2 receives the message, immediately records the time of reception, and calculates the time taken for data to travel
• d = v/t
• Vice-versa

If the distance is smaller than the radius, a warning is triggered in the form of a vibration motor.

Limitations include clock speed; I intend on using a Seeeduino XIAO, an Arduino-compatible board. The clock speed is max. 48MHz, meaning that the smallest increments it can measure is 20.82 nanoseconds. I also calculated that it would take 13.33 nanoseconds to travel two metres (the former distance to keep in public). Hence, with the clock speed available to me, I can only measure 3m and beyond.

Assuming I was happy with this distance, would I be able to do this using one single Arduino sketch? I know that Arduino programs can only run one at a time. Would a constant background clock/stopwatch be too complex? Could you give me any other pointers?

• You'd want an atomic clock strapped to each user's back for those kinds of timing accuracies... Jul 6, 2020 at 16:58
• @Majenko Timing accuracies aside, would it be possible for that kind of code to be run simultaneously? Run a counting clock whilst constantly sending radio pulses? Subroutines? Jul 6, 2020 at 17:01
• If you write it properly you can make it like two things are running at the same time, but that won't get you around the basic physical barriers that make it impractical. Jul 6, 2020 at 17:09
• the ultrasound idea may actually work ..,some type of a ping exchange .... perhaps a unique sequence of pulses could be transmitted ... when the sequence is received, a response would be sent .... the originator of the exchange would listen for the response and, when received, calculate the round trip .... a radio link could be used for administrative functions, such as system synchronization Jul 6, 2020 at 19:07
• @jsotola Ultrasound sensors have a narrow detection angle and area - typically about 30 degrees. If I used it on a wristband, I might pick up false positives from objects around me such as tables and chairs, not to mention the fact that I could be standing right in front of someone and not pick them up. Ultrasound cannot penetrate objects... they are useful because they bounce off them. Jul 6, 2020 at 19:11