Introduction: Indoor Positioning With Bluetooth Low Energy (BLE)
The idea is to build a proof of concept for indoor positioning using Intel Edison and TI SensorTag. The SensorTag with its small and lightweight footprint is an ideal device for being used as ID cards in various use-cases like school children, employees of a company, waiters of a restaurant, etc. The base stations can be installed on various locations/zones inside a school or company premises and on vehicles like school buses or employee carrier vehicles. The base stations are smart enough to recognize a set of known ID cards nearby and broadcast the information to a web server on cloud.
The data and statistics collected by the server will be made available to parents and officials thru their mobile phones. In addition to tracking location, each ID card can serve as a wearable tracker too (similar to Fitbit One) in order to capture the activity details throughout the day using various onboard sensors available on SensorTag like accelerometer, gyroscope, magnetometer, etc.
The scope of this instructable is to demonstrate indoor location tracking using Intel Edison as base station (or beacon) and TI CC2650 SensorTag as ID card. Location tracking is achieved by reading samples of RSSI (Received Signal Strength Indicator) values between base stations and ID cards.
Following are the parts needed:
- 1x Intel Edison + Arduino Breakout Board (for every zone or vehicle)
- 1x Texas Instruments CC2650STK SensorTag (for every child or employee)
- 1x iOS or Android device (for every admin)
Step 1: Setup Intel Edison for BLE Development
- Assemble the Edison Compute Module with Arduino Breakout Board by following the steps here.
- Download and install the Edison installer which will flash the Edison with latest firmware and install the Intel XDK IoT edition. I used Windows 64-bit version installer and IDE.
- Setup a USB serial connection to Edison using putty.
- Assign a name & password to the board, and then connect it to WiFi. Running the following command from putty will allow you to do these one by one: "configure_edison --setup".
- By now, you should be ready with your Intel Edison board for development with Intel XDK IoT edition. You can test your setup once with blink example if necessary.
- Enable Bluetooth on the board and install necessary libraries for communicating with BLE enabled devices.
Step 2: Setup Database and Mobile App on Cloud
Before going further into base station setup and testing location tracking, let's setup the database and mobile app on a web server or cloud. You can create the database and mobile app in any tool of your choice. I used Microsoft SQL Server 2008 R2 Express for creating the database and ASP.NET & C# in Visual Studio Express 2012 for Web to create the mobile app. The database schema can be inferred by going through the DB scripts.
- Add records into ZoneList and DeviceList table depending on how many base stations and ID cards you have. Each zone corresponds to a base station (Intel Edison board) and each device corresponds to an ID card (CC2650 SensorTag).
- Download and open the mobile app code in Visual Studio. Modify the connection string in DBHelper.cs file so that it points to the correct database you restored. The mobile app contains two web pages namely API.aspx and ChildList.aspx. Modify the auth-key in Page_Load event of both web pages. The mobile app uses this auth-key to validate whether the requests received are from known base stations. The base stations call API.aspx with appropriate values as part of query string in order to log the device events whenever a person with the ID card reaches or leaves a zone.
- Publish and deploy the mobile app into your web server. I used IIS-7 (Internet Information Services) to publish the ASP.NET mobile app.
- Test the mobile app by opening the below URL in a desktop or mobile browser. Replace "localhost" with your web server IP address and "key" with your auth-key. You should be able to see the list of devices you configured in DeviceList table.
Step 3: Setup Base Station
Let's setup the Intel Edison boards to work as base stations (similar to iBeacons).
- Download and open the base station code in Intel XDK IoT edition.
- Replace the Web API Server URL and Web API Key in main.js based on what you setup in Step 2 above.
- Choose the target base station board (Intel Edison + Arduino Breakout board) from IoT Device dropdown. The screenshot shows two of my Intel Edison boards named as CLASSROOM and SCHOOLBUS.
- Build and run the project on the selected device. You should be able to see the text "Listening for ID Cards.." in the console log and also the onboard LED should begin blinking indicating that the base station has started listening for ID cards nearby.
Note: If you see the text "Please check if Bluetooth is ON" in the console log, check whether you have turned on the Bluetooth as mentioned in Step 1 above.
Step 4: Track the ID Cards
Finally, we're here... let's begin simulating the location tracking by using Intel Edison as beacons and SensorTag as mobile roaming devices.
- Connect each base station to a power source (a fully charged 9V battery should be sufficient for Intel Edison + Arduino Breakout Board) and place them in different places across your home or wherever you are. You can also place one in your car, provided the board has access to your web server. In real time, the base stations installed on vehicles can communicate with web server using cell data (not in scope of this article).
- If you are using the CC2650 SensorTag for first time, pull the tab on the battery to power on the device. Otherwise, turn the device on using the power button on the right.
- Open the below link in your mobile browser (iOS or Android or other). I created a simple iOS app with a full-screen web browser control to launch the below link in my iPhone 5S (shown in the demo video). You should see the list of devices along with the last event associated with each of them.
- Take different ID cards to nearby different base stations along with your mobile phone. You should be able to see real-time event changes for each ID card (reached a zone or left a zone) on your mobile device.
In the demo video, I have two CC2650 SensorTags named Alice and Bob being tracked by a base station (Intel Edison) and providing real-time updates to my iPhone.
We have a be nice policy.
Please be positive and constructive.