Presence Detection

Presence detection is an important part of making the smart home smart but it isn’t an easy thing to accomplish and I’m always experimenting with new methods in this area.  I see presence detection as having two levels of granularity, on the larger scale “am I at home or away” and on the smaller scale “where in the house am I”. A layered approach seems to be the best way to accomplish this, eg. does OwnTracks say I’m at home, is my phone connectable via Bluetooth and WiFi? If so then I am almost certainly at home. Has a PIR or door contact been triggered, has a button pressed or the fridge door been opened? If so that confirms I’m at home and also places me in a particular room. Accurate presence detection is a bit of  holy grail and is something I’m actively looking to improve on at the moment.


I use DD-WRT on my router which makes it easy to see if my phone is connected to WiFi, I just do an HTTP GET to https://router-ip/ and check to see if my phones MAC address is present or not.  From there I set a global context and update the presence/nsc MQTT topic with home or away and also update the presence/nsc/lastseen topic with the timestamp if it is connected.



Bluetooth is something I have recently been experimenting with more over the last year. There are several different approaches to this, the RSSI (signal strength) can potentially be used to tell how far from a fixed point a device is. In practive this isn’t that useful for me as I tend not to take my phone around the house with me and it usually sits on a charging pad on my desk or on a table in the lounge. I’d love to get this working with my Pebble watch as that is always on my person but it does not seem possible as you can’t make it always visible. My current solution is just to detect if my phone is in the house, this is one with a Bluetooth dongle in a Raspberry Pi running a small Python script that uses the hcitool name command to query the mac address of my phone and see if it gets the name back, if it does, I’m here, otherwise not. The script then updates an MQTT topic to say if I am home or away.  This works in conjunction with the WiFi method.


Something else I’ve been experimenting with is Eddystone beacons but more work needs to be done on this yet.


I use OwnTracks for location tracking, this is an MQTT based system with an app that runs on my OnePlus 3 and connects to my remote secure MQTT broker via SSL, this broker is bridged to the MQTT broker on my home network which does not use SSL or passwords for simplicity of connecting small devices with limited capability.

OwnTracks will track my location anywhere I go outside the house and geofences can be used to signal that I am in a specific location such as home, work etc.


PIR motion sensors

I have a number of PIR sensors around the house that are independent from the security system. Most are from the Home Easy range with a couple of old X10 units as well, all these are RF based and they are received by a 433MHz OOK receiver connected to one of my Tiny328 boards running the JeeLabs Ookrelay2 sketch, this receives the OOK signal from the X10 and Home Easy sensors and relays it over the RFM12B which is in turn received by the Tiny328 connected to my Debian server and fed into Node-RED. More about this in this blog post.

I also have some home made units using the cheap BIS0001 based PIR motion sensors which communicate directly with the RFM12B network and an external PIR sensor also warns me if there is movement detected at the rear of the house when there shouldn’t be.

HE303x10-ms13 HE413 pir-housing


Magnetic door/window contacts

There are Home Easy RF magnetic contacts on both the front and back doors as well as the most used windows, these can be used for presence detection as well as quick report of the security status of the house independent from the security system. These communicate with the server in the same way as the Home Easy PIR motion sensors described above.

I also have a TinyTX with a magnetic contact on the fridge door, the primary purpose is to warn if the fridge door has not been shut properly but it can also be used to indicate presence in the kitchen. This communicates directly with the RFM12B network.


Human interface

Obviously if an RF wall switch is used, a Flic button is pressed, an NFC tag is read, or a touch screen operated in a particular location this means there is someone there (although the cat has been known to operate a touch screen on occasion) and this can also be added to the presence metric.

To do

I’ve been thinking  about using chair sensors, similar to a pressure pad for a security system to detect when a chair is occupied. This would allow automatic lighting control that doesn’t plunge you in to darkness when you have sat still for too long.


Read more about  my smart home automation system here.


Last modified: 26 August 2016

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.