androidgeofencingrssiindoor-positioning-systemphilips-hue

Control Philips Hue Bulbs with Indoor Geofencing


for a study project, I have to find out if it's possible to control Philips Hue bulbs indoor based on geolocation. Philips Hue allows for geofencing via GPS, for example if you leave the house or return, but is it somehow possible to increase the accuracy of the geofencing? The idea would be to switch the light when leaving a room and entering the next room.

I am at the very beginning of my work and am currently reading through dozens articles about indoor navigation. It seems that the best approach would be a positioning system via RSSI.

In the end there should be an app on the smartphone, that automatically switches the light when the smartphone is in a specific range of the bulb. Biggest problem, as far as I can estimate, is that most smartphones don't support Zigbee (yet).

So before I dive deeper into this issue, I would like to ask, if there is any possible way to achieve this. Is it possile to read the signal strength of the Philips Hue bulbs? Is there maybe another approach that I didn't think of yet?

Even if I would buy a Xbee module and an Arduino board for example, would it be possible to read the RSSI of the bulbs? And would it be possible to use this information in Android in any way?

Does anyone have practical experience with this issue?

I really appreciate every tip / opinion / explanation that you could give me.

Greetings, Michael


Solution

  • Industry standard approach for indoor positioning seems to be RSSI using Bluetooth Low Energy beacons. I would choose this approach and forget about trying to integrate with the Zigbee network unless your project is Zigbee specific.

    I've played about with a few BLE beacons. You can alter their transmission power depending upon your need, with the lowest setting resulting in the beacon only being visible to the phone from a few feet away.

    With a beacon in each room I don't see why this wouldn't work for you. If the rooms don't have doors between them then maybe a pair of beacons in each room would be more reliable.

    BLE support is baked into Android from version 4.3 onwards, it's easy to measure signal strength, estimate distance to beacon etc. Then it's just a case of making REST calls to the bridge depending upon which beacon is closest to the phone. If you have a Raspberry Pi 3 you can configure it to act as a BLE beacon for testing before buying any dedicated beacons.

    In terms of Hue integration I would probably set up a new sensor on the bridge for each room and have the phone modify the value of this sensor based on signal strength from each beacon. Then on the bridge I would create rules to react to changes in these sensor values. This would make it easy to deploy an Android app involving minimal code and use the Hue bridge to create more complex conditional rules like what to do if someone walked quickly in and out of a room, handle multiple people in the same room etc.

    Edited to add the following in response to your comment, apologies for the lengthy post!

    Within the Hue API one of the available resources is sensors. If you buy Hue products like motion sensor, light switch etc these are added to the bridge as individual sensors. However you can also create your own generic sensors using the API and use these to store values that you update via the REST interface. The values of your custom sensors can be used in the rules on the bridge as conditions and triggers, you can even read the sensor values via the API to use in your own applications. This is where the system becomes very customisable.

    As you are developing using Android I would recommend the Tasker app along with the RESTasker plugin as this provides an easy way to integrate with the Hue bridge and react to BLE sensors.

    Here are examples of how I have used sensors in my setup, which works in conjunction with a raspberry pi:

    So from these few custom sensors the bridge can now trigger rules based on who is at home, whether they are in bed or not and whether or not the TV is on. Some of my rules are:

    In terms of approaching your project I would create a sensor on the bridge to go with each room in the house, set with an initial value of 0. Then in Tasker I would scan for the closest BLE sensor. Lets say the closest BLE sensor is living room, I would have Tasker read the living room sensor variable from the bridge (value is 0) and then add 1 to the value and write it back to the bridge (value is now 1). I would have Tasker save a variable that the last sensor updated was living room and keep scanning for BLE beacons. Now if Tasker finds a different BLE beacon which is closer than living room I would have it read the living room sensor from the bridge again (still 1), subtract 1 from the value and write it back (so now its 0) and then repeat the process above, adding 1 to the sensor value for the room the phone is now closest to. In the bridge I would have rules that said if sensor value for a room = 0 turn off lights in that room, if sensor value > 0 turn on lights in that room. Because you are reading the existing value and adding or subtracting from it when a phone enters a room the system can cope with multiple phones/people in the house. If two people are in a room then the room sensor value will be 2 so the lights will only turn off when the last person leaves, not if one of them goes to get a drink or whatever.

    As you can tell I've spent far too long tinkering with my Hue, but it's been a great learning process. I came to it knowing very little about programming at all and found the API very easy to understand, it's flexibility and ease of integration with other things inspired me to become proficient in several languages and make some cool projects along the way.