Well, it works, partially. What I mean is that it is capable but for some unknown reasons, I am not the only one recognizing this, it seems recognized BT devices are suddenly & randomly reported as away and then found again, at least when used in the above referred project. No such problems when using an external dongle. Besides the BT range is better when using some BT dongles
I see. I haven't had any application for BT yet, but I'm about to start on a project which needs it, so it's interesting to hear what issues others have encountered.
I use the BT with the Monitor project to announce to Node-RED when I leave/come back to our house. Our home alarm system is integrated with Node-RED to enable video recording from our cameras when it is armed.
So in my case I just block the video recording for a few minutes when I approach the house, gives me time enough to disarm our home alarm system, thus preventing receiving a lot of pictures of myself via Telegram to my iPhone (since I'm a trusted person approaching our house)
Many other use-cases are of course at hand once you have the information available in Node-RED
PS If I don't take the opportunity to disarm, the video recording will of course be enabled again once the the time out has ended
That is nearly the same use case that I'm going to implement, using Bluetooth LE as presence detection.
What are you using as BLE beacon? Your phone or one of these battery-powered dongles for your key ring?
I’ve done it the other way round.
I have a usb ibeacon plugged in, in the house
and then use Owntracks on my phone to detect when my phone is in range.
Owntracks then sends a message via MQTT
In the beginning I used beacons (long range usb powered) and Owntracks. That was not good enough since it required me to have Owntracks installed on my iPhone, and IOS was deciding when the app should have access to the network, made things unreliable. So now I just use ASUS BT dongles, they have a range of 10-15 meters. Once my phone is detected, the information is forwarded to NR. This has worked very well. No app required on the phone, just BT has to be enabled.
I'd rather have something not tied to the phone.
My basic idea was some transmitter beacon on the key ring. Then use an ESP32 (or Raspi) as Bluetooth scanner near the entrance hall, where the keys are usually located when I'm at home. These would push their data via MQTT to Node-RED for further processing.
I guess that would work as well, I think Monitor can detect beacons as well but I did not try that
Using the phone as beacon would not work very well for me, as I often disable Bluetooth, when I don't need it.
To work reliably, I would need to keep it always activated.
The second thing is, sometimes I leave my phone at home... an unusual thing for most people nowadays, but it happens.
Your key ring is something you always carry around, as soon as you leave your home.
But I have yet to find a suitable BLE beacon with reasonable battery life. Most will only work up to a year (some only months) before you need to change the battery.
The use of Owntracks,,,,well,,,I think it depends if you have an iPhone or an android type. It might work better with android but IOS is not giving apps full freedom to use the network when they want, at least if you run the app in a "low power mode". That is anyway the reason why I abandoned it for my setup
I did purchase my beacons from here:
I believe using key ring beacons would be the simplest and most reliable solution in my case.
Using the phone (Android in my case) with some extra software like Owntracks would introduce too much overhead (reliable network connection, active location services, ...)
I will have a look at that, thank you.
Could you please provide details of which ibeacon works well with OwnTracks? I'd like to try something similar.
i bought an unbranded usb ibeacon from aliexpress five years ago.
Having configured it and adding the details to owntracks it has been happily working ever since
I did some testing with iBeacons and NR, see screenshot below
Used this node but please notice also the issue about node version (in my case tested with Node 8.11.1):
Maybe this is more interesting for you if you want a pure Node.js module
Anyway, seems to be working fine, scanning is running and detecting reachable beacons. I'm running this is in a RPi3 and using the internal BT. With this I think you can build a reliable presence monitor
Encouraged by the joy, I continued testing various setups to scan for iBeacons. In one of the tests I tried the https://flows.nodered.org/node/node-red-contrib-bleacon
I think it would be a better alternative since the node allows you to control the scanning, i.e. you can turn it on/off. Besides there is a node that allows you to create a virtual iBeacon device. Unfortunately the nodes doesn't work in the latest NR versions, the same problem as reported above (I have raised an issue with the author and he has responded). Another thing is that it stops scanning "after a while". Don't know why but it forced me to invent a work-around in NR, see the picture below. This self-monitoring requires however that there is a stationary iBeacon within reach all-the-time, in my case I have such, a usb powered stick
When moving an iBeacon in and out of range, this is well detected and the event can be used for numerous of things. In my case, I just publish the events to a broker, available to any interested subscriber
Next experiment was, well, definitively more advanced and required quit a lot of work and perseverance...
The idea was to create an external service that could do the scanning and report the results to NR via MQTT. I also wanted a solution that would work in later NR versions without any eventual dependency of node.js specific versions
Since there are already libraries for GATT Protocol for Bluetooth LE devices available, I decided to jumpstart with one of them, gattlib for Python
Now the real journey started, it took many hours and googling to figure out and fix all dependencies initially required until I finally had the library installed in a Pi for Python3
The end result is working great, it has been running flawless since yesterday in two separate Pi's. The detection is not better or worse than the other setup but it works also fine in the latest NR beta
This post is not intended as a full instruction of how to do with all that Python and other dependency stuff required, it is at this stage intended as informative
The Python script running and scanning:
The NR configuration to control & monitor the execution of the script. It allows
- for automatic restart of the script if it should stop delivering scans
- manual aborting & restarting
- filtering of monitored iBeacons (in this case I am just watching one single device)
- iBeacon enter/leave events sent to my iPhone via Telegram (currently useful for debugging)
Very nice - will you be prepared to share that at some point ? I could see some good use cases for this - i was previously - playing around with the Monitor stuff from HA - but was not really comfortable with it just being a Bash script.
I thought it would be better to make a separate topic here
I guess you have already worked this out, this is then maybe just an example of how I just configured a esp32 device as an iBeacon scanner according to your idea
Ordered a couple of esp32 devices from here: https://www.aliexpress.com/item/32996463686.html?spm=a2g0s.90423220.127.116.111e4c4ddEXHi2
Used this esp project: "A BLE to MQTT bridge running on an ESP32"
Yes, I think I even tried the same project, but hit some issues with my ESP32 boards. Also spare time is in high demand these days, but I plan to continue soon.
Nice Raspberry rack by the way