What is the best way to get the distance between two arduinos? The first thing that comes to mind is using some kind of radio attachment and using the time delay between sending a ping and receiving a response to estimate distance. End goal is basically mapping a network of them with relative distances as lines between them on a blank canvas. Any suggestions? Someone suggested using computer vision and fiduciaries to do it but this isn’t great for my use case
What is the best way
Define what you mean by best?
What distances do you need?
What is the resolution you have in mind?
Note EM waves are very fast so measuring time becomes a bit difficult
- Bluetooth or Wifi or and use the RSSI
- sound pulses and use the speed of sound
- use GPS positions and us the haversine formula.
- sure there are more
And of course how you do this measurement depends on the environment as in where the Arduinos are and whats between them.
Tape measure maybe ?
may be the work on UWB tags by @jremington might be of interest?
Like this one? ESP32 UWB(Ultra Wideband) | Makerfabs
Please post a link to an example of how to measure distance with those LoRa modules.
Thanks. Has the Arduino IDE code been published anywhere?
Thanks again. I'm looking at this collection: SX12XX-LoRa/examples/SX128x_examples/Ranging at master · StuartsProjects/SX12XX-LoRa · GitHub
What does this plot for the 100 m distance measurements represent?
What does a conventional histogram of the distance measurements look like? What is the standard deviation from the mean value of the measurements?
Just above that image, the readme says;
"I stood with the master hand-held, away from my body, at 100m distance. The calibration and adjustment values were determined as mentioned above, so the master ought to be recoding a distance of 100m. The results of around 140 ranging measurements are below;"
Each bar a measurement, no other mathematical analysis published.
My understanding is that it’s the ~140 measures sorted by the error in distance, ie if you are at 0 it means the device correctly found 100m and at the maximum under estimate was -38m (or so) saying the device measured 62m instead of 100m and at the far right it seems like +26 or +27m meaning the device reported 126m instead of 100
So quite a variance and from the look of the shape, keeping only 50% of the values in the center and averaging those could possibly be close to the 0 error (or actually overshoot a bit)
Is it correct to state that the list of measurements was sorted, from negative to positive error, then simply plotted as a bar graph?
If so, it looks like there is a substantial offset, and the mean value of the measurements is not 100m.
If the list is still around somewhere, I would be happy to conduct further analysis.
Indeed.
The distance variance is due the the variance in the internal processing time of the ranging packets. This internal processing time ideally is a fixed value. It needs to be known and incorporated as a calibration value.
Circa 40m represents an internal processing time variance of circa 130nS.
Not tried it myself but there are SX1280s available with TCXO oscillators which reduces the variance.
That’s my understanding
For others interested in this topic, it is worth noting that the Makerfabs UWB modules come in standard and high power versions, with maximum ranging distances of about 60 and 200 m, respectively. So they seem to complement the SX128x modules discussed in the last few posts.
For the standard UWB modules, the rms distance error after antenna delay calibration is around 10 cm.
For calibration and measurement examples see UWB-Indoor-Localization_Arduino/README.md at main · jremington/UWB-Indoor-Localization_Arduino · GitHub
I asked the latest chatGPT4-o to interpret the data in the .jpg image of the bar chart in post #11, and after a little back and forth, it produced the following list of "original distance measurements" assuming that 100 meters was subtracted from each measurement.
63,65,67,69,71,72,74,76,78,80,82,84,85,87,89,90,92,94,96,97,99,101,102,104,106,108,110,112,114,116,118,119,121,123,124,126,128,130,131,133,135,136,138,140,142,144,146,148,149,151,153,155,157
It then calculated the mean and standard deviation of the derived measurements to be 110 +/- 27 meters and produced this histogram, using 10 m bins.
(I verified the mean and SD using Excel).
Impressive performance for chatGPT, not so great for the accuracy of the LoRa radio distance measurements. But we knew that already.
Of interest of course is what the average distance would be for say 10 measurements at the same distance. It looks like it could be within say 5m of 100m, but not tried that myself.
And if the variance were only 5m, then a variance of 5m over 1km or further would be quite reasonable.
That is why I conducted the analysis above. The average of the reconstructed measurements is 110 meters, with a standard deviation of +/- 27 m. Assuming, of course that my and hence, chatGPT's interpretation of the original bar graph posted on Github is correct.
I would appreciate if if you could take another look at posts #11 and #14, and verify that assumption. If not, please explain what the bar graph means.


