Table of Contents
Indoor Location Tracking / Presence Detection
In February 2019, I started working on a project which would allow my server at home to know which room of the house I was in. This could be used for home automation or for generating statistics.
I am running an iOS app called OwnTracks which supports GPS location tracking via MQTT and HTTP(s). I have configured OwnTracks to send location updates via HTTPS to a VM on my home server via a Cloudflare tunnel; this data is immediately processed by Node-Red which can then log the data and perform any home automation actions I may have set up.
I was previously sending the data to a VPS with MQTT running on it which was bridged to my house. This allowed me to have a static IP address and a public server without opening up my server at home. Thanks to Cloudflare Tunnels, I no longer need the VPS.
I found some inexpensive iBeacon modules on ebay which can be powered with a CR2032 battery or 3.3v DC. This module appears to be a HM-11 (which is based on the Texas Instruments CC2541 SoC) so it should be capable of much more than just broadcasting iBeacon messages.
Here is an image of the iBeacon module I am using:
These can be found on ebay by searching for “bluetooth ibeacon” and looking in the price range of about $5-8. There now appears to be a new design which has more sellers but I haven't tried it.
The UART pins are clearly labelled on this module which makes it very easy to configure. This PDF file on elecrow.com lists the supported AT commands but I'll also list the commands I used for configuration below:
AT+RENEW - Factory Reset AT - responds 'ok' when ready for commands AT+MARJ0x0001 - sets the iBeacon major value (0000-FFFF) AT+MINO0x0001 - sets the iBeacon minor value (0000-FFFF) AT+ADVI3 - sets the broadcasting interval (0-F) AT+ADTY3 - sets 'advertising only' mode to save power AT+IBEA1 - enables iBeacon mode AT+IBE012345678 - Sets the first 8 bytes of the UUID to '12345678' AT+IBE198765432 - Sets the next 8 bytes of the UUID to '98765432' AT+IBE288888888 - Sets the next 8 bytes of the UUID to all 8s. AT+IBE322222222 - Sets the final 8 bytes of the UUID to all 2s. AT+PWRM0 - enables 'auto sleep' to save power
When setting up your iBeacon, you should use a random UUID rather than my example above.
The broadcast interval command AT+ADVI (0-F) values are listed below:
0: 100ms 1: 152.5 ms 2: 211.25 ms 3: 318.75 ms 4: 417.5 ms 5: 546.25 ms 6: 760 ms 7: 852.5 ms 8: 1022.5 ms 9: 1285 ms A: 2000ms B: 3000ms C: 4000ms D: 5000ms E: 6000ms F: 7000ms
I'm using '3' for some of my iBeacons which means they send out a broadcast every 318.75ms. The iBeacon specification says that broadcasts should be sent every 100ms but this will consume more battery and not necessarily yield any improvements to the accuracy or reliability.
These inexpensive iBeacons are a really good way to give per-room location accuracy and home automation without sacrificing your privacy.
These beacons can also be attached to things you are worried about losing. When your phone leaves range of it, you can perform whatever action you think is relevant (push notification, drop a pin on a map, etc). This can have a negative affect on your privacy though because these beacons use static IDs which can be tracked by people monitoring Bluetooth signals.
In my experience, the battery life of these modules is around six months when broadcasting 3 times a second using a cheap battery. Where possible, I am now powering these with power supplies to reduce the number of batteries I waste.