Presence detection with low cost BLE devices and Raspberry Pi/Zero W

I now have the amazefit bip smartwatch, and it can be used as ble beacon.
Batterylife should be arround 20-30 days.

It gets detected with the Happy Bubbles nodes.

This is awesome! Thanks for creating it and Iā€™m going to try it one of my ESP32 modules soon. Things have been pretty busy for me so I have not been checking forums as much but Iā€™m happy other people are taking on this challenge on the ESP32. Itā€™s what I wanted is for Happy Bubbles detectors to be very low cost and DIY, but I just could not get a performance I was happy with, I hope it improved.

Also, if you want to take a stab at detecting iBeacon and Eddystone types, have a look at my parsing code here: https://github.com/happy-bubbles/presence-firmware/blob/master/user/user_main.c#L305 in my firmware. Maybe itā€™s useful for you. Itā€™s in C so should be usable in Arduino hopefully.

1 Like

Thank you for the info, me too have been busy and didnā€™t make a lot of progress on this, it seems 1technophile also integrated bluetooth detection via ESP32. My next step will be to check the integration from 1technophile.

Hi all,
Iā€™m trying to setup room assistance, but I have some issues.

If I enable ble in the config file (set to true) I get this error:

module.js:471
    throw err;
    ^

Error: Cannot find module '../build/Release/binding.node'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/room-assistant/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js "index.js"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-03-10T15_17_56_852Z-debug.log

If I disable ble (set to false) room assistant start but obviously is useless.

This is the ble section in my local.json config file

},
  "ble": {
    "enabled": true,
    "channel": "room_presence",
    "max_distance": 3,
    "blacklist": [],
    "whitelist": ["6708eda4278d"],
    "use_mac": true,
    "system_noise": 0.01,
    "measurement_noise": 3,
    "update_frequency": 5000
  },

Any hint? what am I doing wrong?
thank you

EDIT:
npm is updated to the latest version.
Iā€™ve tried with latest version of node and with version 6.11.5 as suggested in previous posts. Same result.

ever get an answer?

Sometimes I get similar errors, usually when I upgrade npm or node.
My solution is always the same:

  • Backup your config file
  • Uninstall room-assistant & delete the folder
  • Git pull & reinstall room-assistant
  • Restore config file

PD: Iā€™m on mobile, sorry for the speechless instructions.

thanks. I was missing a comma after true under mqtt:)

I think I am missing something here. I have done the above and have 2 pis running the room presence and 2 sensors in ha. I can see both sensors and they are constantly updating distance like I would think they should.

But where is the software that ties this together. Do the math to determine which room I am actually in. Iā€™d like to use this for both home and room presence if at all possible.

Iā€™m using 2 pi3s and a tile. Just opened and activated donā€™t even have he app. Hat parts seems to be fine since both pis are updating at the same time.

Thank you

So is any one actively developing this on the ESP32 ?
@touliloup @1technophile @sfgreenwood @happybubbles

Yes, but we are encountering issues due to the esp32 developement environment maturity.
In particular wifi disconnection and multicore issue.
Wifi disconnection seems very depending on the local network situation.
I would like to use multicore so as to free one core for other gateways like RF or IR. If you donā€™t need RF or IR on the same hardware multicore option is not needed.

sounds promisingā€¦i think :yum:

Are there something in pre-alpha that we can flash into a device ?

you can test it there from master :

Donā€™t hesitate to give feedback.

Note also that last ESP32 env code is too big, take care of taking the revision pointed into the wiki.The BLE library to use should be taken from the repo here

How can I get the MAC address of BLE devices? I tried a various BLE scanners but donā€™t know how to find the MAC. For example if I purchase some TILE devices how can I get their MAC address?

I plan to use this device to track my cars so need to get the mac address from them also.
https://www.amazon.com/gp/product/B019G0VVZC/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

How do I see the message sent to the broker?
I am starting with the default embedded mqtt server so my config is simply
mqtt:
and I have configured room assistant with my HA server, port 8080, userid:homeassistant and password as found here MQTT - Home Assistant

Does the default mqtt use mosquitto? I donā€™t have a mosquitto_sub command on my hassbian install. Or does this suggestion assume you are using mosquitto for your mqtt server on itā€™s own? If so how can I see if my system is setup correctly with the embedded mqtt server?

@smart use the excellent MQTTFx ( http://mqttfx.jensd.de/ ) to monitor your MQTT server.
Or if you prefer a Chrome extension : https://chrome.google.com/webstore/detail/mqttlens/olchecfhjakpabcillcpffnlmmlnlbgj

@sfgreenwood I bought a few iTags and three of them work fine, but one of them turns itself off after five minutes. Have you experienced this? Iā€™ve seen some discussion online that this specific iTag is a later hardware revision and if itā€™s not paired up with a device it turns itself off? Obviously rendering it useless for what we want to do!

Iā€™ve made some headway on getting BLE beacon tracking working on the ESP32. If anyone is interested in adding some more detection nodes to their room presence system, Iā€™d love you to check it out.

The discussion thread is here, and you can get the code from the GitHub repo. Building and uploading is done via PlatformIO.

@smart you can use any number of beacon apps on your phone to get the ID of your beacons. I use NRF Connect on my Android phone. You can also use the app to configure the beacon to modify the default settings. For example, I changed the TX power setting on my key fob so it would report accurate distances.

I think I had one that did that and one that didnā€™t. I havenā€™t done much with them beyond that as Zanzito and Find provided better solutions (although still incomplete).

Thanks, I have had room assistant up and running for a while. I use the iBeacon tokens I listed above in my car to track my home arrival. Works perfect!

Is it possible to set up Room-Assistant to scan for the bluetooth on my phone? I always have it with me, and would prefer that over carrying around a beacon with me. Hard to find a place for it while walking around in my underwear lol, but I always have my phone close by.

I tried to just use my Android phone to detect beacons placed in rooms, but there doesnā€™t seem to be an Android app that works well and reliably enough to detect the beacon and communicate to HA via MQTT or http api.

@PlayedIn Because of the way phones will randomize their bluetooth mac addresses when advertising to any unpaired device, itā€™s a challenge to reliably detect the phone correctly.

However, you can emulate a beacon on your phone using an app. Iā€™ve had the best success with Beacon Scope, but there are other beacon broadcasting apps available (such as Beacon Simulator). You can configure your phone to broadcast as an iBeacon, and then configure the beacon uuid on the phone and in your configuration.yaml.