Titanium and Estimotes :: Proximity

In this session, we will be looking at the proximity functionality of our estimotes.  Proximity functionality is the current big sell for ibeacons because it grants relevancy to the situation.

So, proximity and relevancy.  If you tell a child in the backseat of a car that McDonalds is 5 miles away, that probably doesn’t mean much to them.  But if you say, its at the next exit, or, watch one more Barney video, that gives them something they can relate to.

If you announce to a shopper ‘you are 75 meters from the ice cream stand’,  you think that will get them all excited? For geeks, the rssi value is cool, its not perfect, but its a number. For a marketer (all offense intended) we need to water it down a bit, make it easy on them.  So estimotes have 4 proximity zones [immediate, near, far, road trip]. Ok, I made the last one up.  Its really an out of range zone. Some ibeacon vendors have a 5th zone between far and out of range as a buffer against interference.

Currently, the proximity uuid of estimotes are locked to B9407F30-F5F8-466E-AFF9-25556B57FE6D. Because of this, to identify the ones we are working with (and to not pick up our neighbor’s units) we need to be sure that we have matched our estimotes to their major and minor numbers (as mentioned in the last session).  Estimotes has indicated that they will be unlocking the uuids in the near future.

The code for this article is available on github (github.com/tidev/ti-estimotes-proximity) to save on excessive cutting and pasting and to allow you to follow along within a working project.

In the index.js, match your estimote major and minor numbers with the appropriate colors [mint, blueberry, marshmellow]

function toggleRanging() {

    if ($.rangingSwitch.value) {

            uuid : "B9407F30-F5F8-466E-AFF9-25556B57FE6D",
            identifier : "mint",
            major: 32398,
            minor: 18351

            uuid : "B9407F30-F5F8-466E-AFF9-25556B57FE6D",
            identifier : "blueberry",
            major: 36493,
            minor: 17925

            uuid : "B9407F30-F5F8-466E-AFF9-25556B57FE6D",
            identifier : "marshmellow",
            major: 8702,
            minor: 11168

    } else {

In the demo app we used last time, proximity was simply thrown on the screen in an alert.  Let’s do something a bit more visual with it than that. So, we throw in our event listener and have it call our function (updateInformation) each time it hears something.

TiBeacons.addEventListener("beaconProximity", updateInformation);

Our function is going to do 2 things.  Each time it is called, it will update 2 pieces of information about the beacon that it heard from.  It will update the proximity and the RSSI value.  This will allow you to get a feel for the relationship between the radio strength and proximity.  Second, if a beacon is reported as being in the ‘near’ zone, we will update an image view near the bottom of our screen. Near was chosen for the demo because the immediate zone almost puts you on top of a beacon.

function updateInformation(event){
    if (event.identifier === "mint"){
        $.mintProximity.text = event.proximity;
        $.mintRSSI.text = event.rssi;
        if (event.proximity === 'near'){
            $.adspace.image = 'http://image.shutterstock.com/display_pic_with_logo/430459/105011834/stock-photo-mojito-lime-drink-cocktail-105011834.jpg';

    } else if (event.identifier === "blueberry"){
        $.blueberryProximity.text = event.proximity;
        $.blueberryRSSI.text = event.rssi;
        if (event.proximity === 'near'){
            $.adspace.image = 'http://image.shutterstock.com/display_pic_with_logo/965987/108450557/stock-photo-freshly-picked-blueberries-108450557.jpg';

    } else if (event.identifier === "marshmellow"){
        $.marshmellowProximity.text = event.proximity;
        $.marshmellowRSSI.text = event.rssi;
        if (event.proximity === 'near'){
            $.adspace.image = 'http://image.shutterstock.com/display_pic_with_logo/963767/142706050/stock-photo-marshmallows-142706050.jpg';


With your major and minor numbers in place and correctly associated with the right colors, lets fire this app up, and see what we get:

So as we move around our estimotes, the reported proximity values change, we can see the reported rssi value from each, and we get our ‘ad’ at the bottom.
(Ranging was turned off for the screenshot)

Stephen Feather a founding partner of Feather Direct, a mobile design firm in the Atlanta, GA area. He worked directly with communications companies such as Netscape, Microsoft, and Oracle in the early days of the Internet. In 1996 he authored JavaScript by Example, one of the first publications on the then-new scripting language. He volunteers time to assist and train a new generation of app developers through online forums and local user groups.


  • Francisco Tirado

    Hello Stephen, do you know if the app will be notified when entering a region if it is in background or not launched?

  • Stephen Feather Post author

    In this example, the background service was not enabled. Take a look at https://github.com/jbeuckm/TiBeacons-Example-App/blob/master/app/lib/bgService.js for an example of backgrounding.

  • Francisco Tirado

    perfect! thanks a lot :)

  • Vladimir

    Hello Stephen. Thanks for the beacon-related articles. Got a question here: a number of sources indicate RSSI readings can be used to estimate distances from iBeacons based on RSSI within 1 meter from the beacon. Relative proximity tests seem to work fine event indoors, however even during my outdoor tests RSSI deviation is quite serious between a number of readings from the same beacon (+ RSSI is only reported as integer values). In short can RSSI be practically used for estimating distance from beacons?

  • Francisco Tirado

    Hello again Stephen, I seem to have set up my app for background ranging but I never receive any type of notification. Im doing something wrong :(

    Do you think its too much to ask for a blog post on the background service? I think the most interesting part of iBeacons is precisely that.

  • Francisco Tirado

    Finally got it working, I had not noticed how many versions jbeuckm had contributed :) I was just using an old module.

  • levi

    I’m trying to get this example to work, but the app won’t show any numbers or anything.. Just the 3 boxes with color and RSSI in them.
    I’ve just downloaded the full example, I’ve placed the module (org.beuckman.tibeacons) in the Library (of my computer), and I’ve changed the major and minor values to the one of my Estimote beacons.

    Help would be really helpful, thanks in advance!

  • Hoyeon

    Hi Stephen Feather.

    Your source code will not run on the iPhone 6.
    Is my mistake?


  • ebookies


    Can we done some accurate indoor location (like GPS) with this?