Announcement

Collapse
No announcement yet.

Presence detection using your smart phone Bluetooth and Big6

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Presence detection using your smart phone Bluetooth and Big6

    Problem: Motion sensors will register your presence in a room when you move. They will not if you sit or lay reading a book for example.
    Solution: Presence detection using your smartphone's Bluetooth

    It sounds easy but it is not. Smartphones (iPhones especially) do change their BT MAC constantly for privacy reasons. A team of programmers put a lot of efforts to come up with this solution

    espresense.com

    It requires a piece of hardware ESP32 that is cheap and widely available.
    Detailed instructions are at their web site of how to install and activate it.

    Once you do you can make a MQTT sniffer using Big6. You will need it in order to see how your smart phone is listed. There is a lot of "noise" that has to be filtered out as most likely there are other BT devices such as printers, mice, keyboards, tags that will report as well. You need to find and isolate the ones that interest you - your smart phone and family members smart phones.

    To "sniff" all the MQTT traffic that espresnse generates create a temporary Big6 MQTT profile called "Sniffer" and subscribe to a catch all topic espresnse/#

    Check the "enable log" checkbox. Go to Big6 --> Profiles setup --> Utilities --> Logs . Select the last one from the drop down menu to display selected profiles in th elogs.

    Let your ESP32 run esprensese and check the HS logs

    You'll see many records like this one

    [MQTT] [Big6 Plugin] [#PFL:Sniffer] [MQTT Sniffer - espresense/# (user: joe) IN]: {"id":"sid:0xfe9f","rssi@1m":-71,"rssi":-87,"mac":"516db37b99bd","raw":2.87,"distance":2.5,"speed":0 }

    Look carefully for records that contain "id" that resembles your device. For me it looks like this

    [MQTT] [Big6 Plugin] [#PFL:Sniffer] [MQTT Sniffer - espresense/# (user: joe) IN]: {"id":"apple:iphone13-2","name":"iPhone13,2","disc":"201a144b03f1","rssi@1m":-65,"rssi":-98,"mac":"7ba908089c85","raw":8.77,"distance":9.94,"speed":-0.1}

    Once you find all of the devices of interest than remove the "Sniffer" profile to avoid clogging your HS log.

    Create new profiles for each of the devices of interest as follows (using the example above)

    topic

    espresense/devices/apple:iphone13-2/office

    the word "office" is the location that you setup when you setup your ESP32 can be any word.

    Use the following as name expressions

    "rssi"&&"raw"&&"distance"

    Use the following as value expressions

    JSON_Num(input,"rssi")&&JSON_Num(input,"raw")&&JSON_Num(inpu t,"distance")


    "raw" is momentary reading of the distance while "distance" is refined by using noise filters to remove the noise. Distance is approximate distance in meters from your smart phone to the ESP32.

    As a result you will have all of the above values in your HS4 devices created and updated for you by Big6. Use them as usual in HS4 to trigger events turn on lights etc.
Working...
X