Subscribe to Make Magazine Today!

Ask MAKE is a weekly column where we answer reader questions, like yours. Write them in to
or drop us a line on
Twitter. We can’t wait to tackle your conundrums!

Aaron writes in with a question about short-range sensors:

My question is really more of a search for direction. I have exhausted
several approaches and could use advice. The goal is to create several
simple, cheap sensors that have only the ability to sense that there
is another one of them next to eachother. I need a range around 5
feet. It would need to have an id. For instance sensor 1 could see
sensor 2 and 3 within 5 feet but no other and sensor 2 could see
sensor 1 and 4, and so on.

I have considered rfid most intensly, but I find noise and cost go up
at this range and I have had issues with consistancy. Laser requires
line of site not be interrupted, blue tooth has too great a range, and
so on.

Interesting question! I’ve actually been thinking about this for a project as well. There are three types of signal that I can imagine using for this application: RF, audio, and optical. Because you mention that maintaining line-of-sight is an issue, let’s stick to a radio based solution. To make things simple, lets assume that each node is identical. Then, we need a protocol for each node to take turns transmitting their IDs to the other nodes. We also need to figure out how far away the transmitting node is, which we can estimate using the received signal strength if we make each node transmit at the same power. This is possible because radio waves follow the inverse square law.

Now, there are many different ways to build a radio system to do this, however a nice off-the-shelf part that will work is the xBee. Each node would then consist of a microcontroller (whichever you fancy) and an xBee radio. Program them so that they transmit their own ID at random intervals, and spend the rest of the time listening for other radio’s IDs. Measure the signal strength of the received ID using the RSSI indicator, and if it is above a certain value (determine experimentally), then add the ID and time of reception to a list. If the same ID is received again, update that entry with the latest time a signal was received. Then, go through the list periodically, and remove any ID that hasn’t been heard from in a while (longer than the longest time between random transmissions). This way, you will always have a list of devices that are nearby. By having them transmit their IDs at random intervals, you will minimize the chance that two transmit at the same time without having to deal with synchronization issues.

That’s the easiest way I can think of to do this, however it is still pretty complex. Have a better solution? Sound off in the comments!

  • Justin

    While ZigBee is a decent solution, it is not cheap at all. Unfortunately I cannot think of a better method either.

  • hex4def6

    I don’t understand why you have a requirement that sensor 1 can’t see sensors beyond 5 feet. To what tolerance? If I’m 5.1 feet away, would seeing me be a deal breaker? What about not being able to see me at 4.5 feet?

    What I’m not line-of-sight and the obstacle adds 3dB of attenuation? What if the temperature reaches 30 degrees C and the antenna is slightly detuned and therefore has a different range? What about variances in transmit power? In WiFi for instance, it wouldn’t be unheard of to have a 1-2dB difference between two identical units.

    You need to strongly consider the environment you’re operating in, and the importance of your <5 foot requirement.

    Not having the guarantee that you’re not line-of-sight basically makes this impossible, given the information you’ve provided.

    • Matt Mets

      My take on the 5 foot requirement was that it was somewhat arbitrary, and a little inaccuracy in sensor distance would be tolerable. Your points about signal attenuation do present an issue, though. I think Odin84gk’s solution of using phase shift of a signal at an appropriate wavelength is probably the most robust.

  • hex4def6

    …that should be “..Not having the guarantee that you *are* line-of-sight…”

    Few other thoughts:
    What are you trying to achieve? Knowledge of distance between sensors? Distance & direction & sensor_ID & …?

    If you just wanted distance, you could try some sort of ultrasonic chirp / response, and base it on time of arrival. Eg, sensor 1 would send a chirp, then start listening. Sensor 2, upon hearing the chirp, would then also chirp. Sensor 1 would hear this, and knowing the speed of sound in air (340 m/s?), and the time it took, could calculate the distance. You could get fancy and have some sort of chirp data format to broadcast the sensor ID.

    If you do go with some sort of RF thing, RSSI is not going to a reliable way of determining distance to the distances you’re talking; whatever you choose, be it WiFI / XBee / whatever is going to have receiver / antenna / transmitter variances, as well as directionality, etc.

    • Amanda

      I’m trying to figure out how to do this for a game we want to play… a spy v spy thing… have you actually figured out how to do it?


  • Will

    If the sensors (in this case, radio transmitter/receivers) can be connected centrally, you could have a central controller send each sensor a signal to broadcast, maybe in the format of a header, like 0101010, followed by the sensor id, followed by 0111. Then each sensor would listen for the signals broadcast by any sensors in the area, and send that information to the central controller which would do the filtering and math to determine the time delay between the sending of sensor a’s signal and the reception of the signal by each other sensor in the array.

    The speed of radio waves, the length of the connecting wires, and the speed/synchronization of the sensors and controllers might be too big of an issue, however. I’m not an electrical engineer. But, this is the only way I can think of doing it that doesn’t involve echolocation, RSSI, or line of sight.

    If the sensors can’t be connected, then do some research into how gps works. You might be able to use highly accurate clocks to measure the trip time without any connection between sensors. Or, you might be able to use a round-trip-time like the tcp/ip ping, though this may introduce retransmission delay and collisions, which may not be consistant.

  • Odin84gk

    This is a digital communications kind of problem. Lets say the father is trying to find a daughter within 5 feet.

    Generate a 100MHz pulse from the father. (minimum of 100MHz, since 100MHz ~ 9.84 feet.
    The daughter will contain a phase lock loop and emit the same frequency at the same phase.
    The father will look at the phase shift between his emitted signal and the phase shift of the received signal. This is the same way speed guns and radars work.

    If you want even more accuracy, get two emitters: One at 100MHz, one at 13MHz (75 feet). This will allow you to get a rough distance using 13MHz and one for 10 foot measurements. I say this because the 100 MHz radio will give you 10 foot measurements, then reset. (For example, it will count to 10, then count backwards to 1, then back up to 10, ect).

    Add in some coding (as in some form of PAM for identification), and you will have a very, very robust system. (Note: This sounds complicated, but it is an elementary problem for digital communication engineers)

    • Matt Mets

      Hmm, this does sound better than using signal attenuation to estimate distance. If it got too complicated, you could throw the identification coding on a side channel to keep the receivers simple. Know of any well documented projects that use it? I know that some 805.15.4 baseband manufacturers were considering adding distance location features into their parts, but am not sure what came of it.

  • Apis

    The simplest and cheapest I can think of is using light-flashes and sensors, and look at light intensity.

    The idea about sound chirps above is better because sound moves through and around some materials, but a bit more expensive.

    The phase locked loop idea sounds really cool :) (but also difficult? and I wonder what PLLs would cost?)
    It’s also worth remembering that radio waves are the radiation as light and will suffer from a lot of the same problems. At radio frequencies some materials are more transparent. The long wavelength will make the em-radiation strongly affected by material and antenna geometry though (kind of like sound).

    It would be nice to know more about the project. :)

Related Supplies at Maker Shed