Bluetooth Device Tracking with Tile
Tile is the leading maker of Bluetooth trackers that help you track your belongings such as keys, backpacks, teddy bears or, more generally, any object you want to be able to locate easily when needed. The Tile hardware device that you attach to the item to track and the Tile mobile application that you can use to locate the Tile are the two basic building blocks. Now, with the introduction of Find with Tile, Tile technology can be embedded into any product quickly and easily.
For a generic introduction to the Tile, see the “how-it-works” section on the Tile company website:
Find with Tile hardware (i.e., devices with Tile technology embedded) is typically physically small and needs to consume minimal energy so that it can be battery powered. The required range of operation is in the order of tens of meters and therefore it is a perfect match for Bluetooth Low Energy that has been designed for use cases like this.
The Tile embedded application (i.e., the code that runs on the Tile itself) can be run on Silicon Labs EFR32-based SoCs and modules. It can be used with any Blue Gecko part. For easy demonstration, this article includes a project that runs on the Thunderboard Sense 2.
Thunderboard Sense 2 is small, low cost and it can be powered off a CR2032 coin cell battery so it’s a good platform for prototyping Tile functionality. The Tile embedded code is available as a C code library that can be ported also on other Silicon Labs Bluetooth development kits.
At the end of this document you will find pre-built binaries that you can program to your Thunderboard Sense 2. Using the pre-built demo is the easiest way to get started. The entire demo project is also available if you want to have a closer look on how it’s done.
The pre-built binaries for Tile demo on Thunderboard Sense 2 are provided at the end of this article as attachments. It consists of two files:
- Gecko bootloader for Thunderboard Sense 2 (gecko_bootloader_TBS2-combined.s37)
- The Tile demo application (Tile_on_TBS2.hex)
You can flash the binaries to your TBS2 using Simplicity Commander, which is a utility that comes with the Simplicity Studio.
The following steps are needed to program the demo:
- Launch Simplicity Studio and connect your TBS2 to your PC with the USB cable.
- Make sure the board is detected by Simplicity Studio as shown below:
- Launch Simplicity Commander from the Tools menu:
Commander launches in a separate window. The following figure shows the required steps to flash binaries to the target.
Press the Connect button to connect to the embedded J-Link debugger on the TBS2.
Press Connect (next to the Target label) to connect to the EFR32MG12 device on the TBS2.
Open the Flash tab from the left side menu.
Use the Browse… button to locate the binary files on your computer.
Press the Flash button to program the file to the target.
First, program the bootloader file (gecko_bootloader_TBS2-combined.s37). Then, repeat the same procedure for the application image (Tile_on_TBS2.hex).
After programming the two binaries, you can either keep running the Tile so that it is powered from the USB cable. Alternatively, you can unplug the cable and insert a CR2032 coin cell to power the device.
Using the Provided Bootloader and Application Image
After you have programmed the Thunderboard Sense 2 with the provided bootloader and application image, the device starts to advertise using the name “Tile”. You can observe it with any Bluetooth LE test utility, but to take advantage of the Tile features you need to use the Tile mobile app that is available for Android and iOS. Install the app on your mobile device from Android Play Store or Apple App Store.
The first step in using a new Tile is registering it with the mobile app. The procedure is the same as with “real” Tiles, as explained in the Tile website. However, note that with this demo you do not need to press any button on the Thunderboard Sense 2 to activate it. The device starts to advertise as soon as the board is powered up (either through USB cable or a CR2032 coin cell).
After registering the Tile with the mobile app, the UI should look something like this:
You can give the tile any name you want. In the above figure, it is named “Tbsense 2”.
Whenever the Tile is in the range of the phone, the app will make a connection to it. The green Find button in the UI indicates that the connection is established. You can press the Find button to make the tile “Ring”. The Thunderboard Sense 2 does not include a speaker, so the Ring feature is indicated by flashing the RGB leds on each corner of the PCB. The flashing continues until you press “Done” on the mobile app.
The mobile app keeps a connection open with the Tile as long as it is within range. Maintaining a Bluetooth connection is very power-efficient because the protocol has been optimized for battery-operated devices. An estimated current consumption (averaged) for different modes is summarized below. Note that the current consumption is not optimized to the last detail. These figures give a rough estimate about the current consumption.
- Beaconing (not connected to the mobile app): 50 uA
- Connected to the mobile app: 310 uA
- Ring function active (red LEDs flashing): 7.3 mA
Note that the bright RGB LEDs draw a lot of current and therefore the current consumption while device is ringing is high. Do not leave the Ring on for long duration to avoid draining the coin cell battery.
Building the Project from Source
The demo project is also provided as an archived Simplicity Studio project (*.sls file). You can import it in Simplicity Studio via the Project -> Import -> MCU Project… menu.
Note: the project is only for the application and does not contain the bootloader. You can use the pre-built bootloader image or alternatively create a Gecko bootloader project for Thunderboard Sense 2 in Simplicity Studio and build the bootloader yourself.
The archived project is created using Bluetooth SDK 2.10.1 and GCC toolchain 7.2.1. You need to have these installed in Simplicity Studio to be able to use the project.
Here are some tips on how to navigate the project contents:
- The Tile library (provided by Tile, Inc.) and other files are found in subdirectories Tile_Common, Tile_Include, Tile_Lib.
- main.c contains some basic initializations, but the application main loop is found in application.c.
- application.c is implemented using the same event driven approach as all of Silicon Labs Bluetooth example apps. For more details, see UG136: Silicon Labs Bluetooth ® C Application Developer's Guide.
The application main loop includes handlers for basic events such as connection opened/closed, and so on. You can add any custom functionality into the application, as you wish. The Tile application is integrated to the project so that at the end of the event loop (your own code), the same Bluetooth stack event is forwarded to the Tile event handler by calling tile_on_ble_evt().
The Tile app requires a valid Tile ID and a key pair. These can be obtained from the Tile website by filling out a form at: https://www.thetileapp.com/en-us/platform-business-solutions.
The credentials you receive from Tile must be inserted into the file Tile_Common\tile_storage.c. Replace the dummy values in variables interim_tile_id, interim_tile_key with the actual credentials that you have received from Tile, Inc. The registration of the Tile will not work unless you replace the dummy values with valid credentials.
The example uses custom advertising packet format and the advertising payload is set in function setup_custom_advertising() (in application.c). You can modify the payload if you wish, as long as the Tile service UUID is included.
The name that is advertised is set in function setup_custom_advertising() and the default name is “Tile”.
In addition to passing BLE stack events to the Tile handler, the demo application needs to have some hook to start and stop the Ring function that is triggered when you press the Find button on the mobile app. The callback functions to start and stop ringing are found in file Tile_Common/tile_service.c. The functions are play_ring_song() / stop_ring_song().
In this demo implementation, the above callbacks will call function gecko_external_signal() that triggers an event in the Bluetooth stack. The event is then handled in the application main loop. The mechanism is similar to what is used typically to detect button presses or other interrupts in a Bluetooth application. More details are found in UG136, Chapter 6 Interrupts.
To integrate the Tile functionality into some other Silicon Labs development kit or your custom board, contact Silicon Labs technical support by creating a support ticket.