Distance between two units

Hey guys, first post, and I thought this would be a great place to get some guidance. I am a software developer by trade so I am excited about the opportunity to try something new.

My question is this: What would be the easiest way to create an alarm based on distance. For example: A stationary object that tracks distance from a smaller object (or vice versa). When the two units are a set distance apart (say 15 feet or more), an alarm goes off. Sorry if this has been posed before but I searched and didnt come up with much.

Any guidance would be appreciated. and if this is completely impossible, telling me that would be appreciated too :slight_smile:

Thanks a ton guys!

EDIT: Oh and these two items will most likely not have line of sight. The more i think outside the box, could you do something like bluetooth and watch for a disconnect?

If the distance at which the alarm goes off doesn't need to be fixed to a specific value but is more like a baggage thief alarm where everything below 3 meters is OK but more than 10 meters must generate an alarm, a bluetooth based solution might be right here. Any other radio signal is possible too and might be cheaper than a bluetooth solution but bluetooth has the advantage that on of the devices might be a smartphone.

Sonars are usually used for distance measurements. Maxbotic EZ1, Parallax
Ping, SFR04 from somebody.