from Hacker News

Ask HN: Measuring Distance with Smartphones?

by delbronski on 9/22/23, 7:18 AM with 19 comments

Hi HN. I built a monitoring system that allows users to make observations in the field (mostly forests) using a mobile app, and then upload those observations to a db.

A recent need that has popped up is to know how far a user is from a marker in the field, and alert the user if they have walked too far away from that marker. For example, there could be 10 points of interest a user might want to observe. Those are marked in a map with a radius of 10m each. In each marker radius a user makes 10 observations. Accuracy needs to be at sub meter level.

I’m looking for a way that the smartphone can keep track of its distance from a given marker. We’ve tried GNSS receivers like the Trimble before, but they are either very expensive or not very practical (they disconnect frequently, battery issues, multiple devices to carry in the field, etc). Our users prefer using a simple old rope over these GNSS receivers, and I don’t blame them. I’ve tried a few times and they don’t always work well in the field.

Do any of you have any ideas on how else I could go about this? Any new technology or research that you’ve come across that can help with this?

Thanks in advance!

  • by danielvf on 9/22/23, 11:25 AM

    UWB is exactly what you are looking for, and support for it is built into Apple phones. It's designed to measure distance and approximate direction. Range of about 40 meters and an accuracy of 10cm. Standard off the shelf chips.

    This is the same tech that is in AirTags, but if you made your own beacon, you could have much control over power output.

    Apple documentation: https://developer.apple.com/nearby-interaction/

    Here's one chip - there are others though: https://www.qorvo.com/products/p/DWM1000

    Forum discussion on ranging: https://forum.qorvo.com/t/dwm3000evb-max-range/11906/5

  • by defrost on 9/22/23, 7:56 AM

    This sounds a lot like biological sampling and it's kind of quite important to make the sample grids (or circles) uniform for apples to apples biodensity observations across geographic locations (or across season times, before | after fires etc).

    Away from a city, out in a forest, phones have access to GPS sats and that's about it - no additional location data from nearby "hot spot" routers, etc.

    And GPS by itself (with no base station differential o post processing or other tricks) isn't that great down at the couple of metres range.

    I myself would be looking more towards a cheap builders laser distance ruler or a piece of string with a loop about a middle stake hammered in the sample circle.

    Back when I did this for a bit we were interested in insect and small things counting and used a section cut from a 44 gallon drum .. just drop that down and count everthing inside, then stand up, take X steps forward, drop and repeat.

    KISS (Keep It Simple S...) works pretty well.

    (As an aside, outside of a forest in a controlled environment there are photgrammetry tricks you can use if you can clamp the camera parameters and mount reference boards so that triangulation can be done from a snapped photo ... but it's over complicating things in a forest I suspect)

  • by Someone on 9/22/23, 8:58 AM

    https://blog.estimote.com/post/676268055242883072/apple-open... (February 2022):

    “another wireless communication technology called ultra-wideband, or UWB — specifically Apple’s UWB solution with the Nearby Interaction framework and Apple U1 chip-enabled devices, including AirTags. UWB provides precise location and distance ranging, much like the older iBeacon technology but more predictably and accurately. In fact, UWB RF ranging can detect distances as close as a few centimeters!”

    I don’t know what range it provides, but it apparently can be used for fining your phone, so 10m seems not out of reach.

  • by solardev on 9/22/23, 7:39 AM

    Can you measure a wifi signal between two phones? https://www.makeuseof.com/wifinanscan-measure-distance-phone...

    Or if you can limit it to newer iphones, I think their special UWB antenna lets them accurately sense direction and distance to an Airtag. Some newer Androids have this too but the ecosystem is immature compared to Apple's.

    Edit: I think the pet industry also makes radio frequency pet trackers that don't operate off GPS or cell, just a tracking collar and a handset that tells you range and direction. Maybe they can wear one of those along with your app? It's probably easier / more accurate with the right hardware than trying to shoehorn it into an average phone...

  • by mikewarot on 9/22/23, 8:39 AM

    At the distances involved, I'd stick with the rope. Involving orbiting atomic clocks entail a number of sources of error[1] that add up to about 15 meters.

    It's possible that an electronic based system could be built, but it would require two transceivers that can measure phase differences of nanoseconds between transmitted and received signals. I'm not aware of any cheap off the shelf systems like that.

    [1] https://en.wikipedia.org/wiki/Error_analysis_for_the_Global_...

  • by bradknowles on 9/24/23, 6:54 AM

    With RTK extensions, and depending on exactly how you augment them, GNSS systems can get you to sub-meter levels of accuracy without too much work. But they're expensive. One of the least expensive devices in this space that I know of is the SparkFun RTK Express Kit.

    There may be better solutions out there, but you should also make sure that you know what the possibilities are with the old tried-and-true systems. Then you've got a baseline that you can use for comparison, and see how you can better that with other options.

  • by v7n on 9/22/23, 8:22 AM

    If the users have a way to verify they are in the center of a marker (visual cues?) you might be able to use dead reckoning by utilizing other sensors in the phone: compass, pedometer (step count lib), accelerometer...
  • by hiAndrewQuinn on 9/22/23, 7:27 AM

    Do you always have direct line of sight between the marker and where you're walking? Probably not, given the forest background, but it never hurts to ask. If so you make the problem quite a bit simpler.
  • by chrisa on 9/22/23, 11:20 AM

    https://estimote.com/ has UWB beacons and a mobile SDK which should work - sounds like a perfect use case!
  • by quickthrower2 on 9/22/23, 7:41 AM

    How accurate? I think a Tile (tile.com) and signal strength (maybe it is hackable to get more than a single word that the app says for example “strong”) might give a rough guide. As a bonus you can make the marker ring if you lose it ;-)