Ultimate Wifi and Bluetooth Presence Detection
Moderator: leecollings
- remb0
- Posts: 499
- Joined: Thursday 11 July 2013 22:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
I have an zwave card on my board indeed. but didn't use it.
I will remove it and try again.
I will remove it and try again.
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
ok, you can use both if you get an external bluetooth usb dongle, mine cost about $5 

Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
- remb0
- Posts: 499
- Joined: Thursday 11 July 2013 22:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
I don't use this card anymore.
I have done this to fix this:
> sudo apt-get install raspberrypi-sys-mods
When prompted to overwrite the config, type Y
> sudo apt-get install --reinstall pi-bluetooth
Still shows an error, let's reboot to pick up the new UART config
> sudo shutdown -r now
Note that we no longer get an hciuart error message during boot
Once rebooted, do:
> systemctl status hciuart.service
Now shows Bluetooth loaded and active (running)
for a video how to use bluetooth on linux:
http://www.cnet.com/how-to/how-to-setup ... erry-pi-3/
Now I'm gonna test the presence script
feedback on script:
- Update doesn't work when using ssl (htps) because links starting with http
http/https variable in settingsblock?
- cooldown period?
- examples how to change ping frequency?
I experience a lot of online/offline with my samsung s7. while the telephone is in range (even next to it) and pingable /scanable.
I will test it a little bit longer.
I have done this to fix this:
> sudo apt-get install raspberrypi-sys-mods
When prompted to overwrite the config, type Y
> sudo apt-get install --reinstall pi-bluetooth
Still shows an error, let's reboot to pick up the new UART config
> sudo shutdown -r now
Note that we no longer get an hciuart error message during boot
Once rebooted, do:
> systemctl status hciuart.service
Now shows Bluetooth loaded and active (running)
for a video how to use bluetooth on linux:
http://www.cnet.com/how-to/how-to-setup ... erry-pi-3/
Now I'm gonna test the presence script

feedback on script:
- Update doesn't work when using ssl (htps) because links starting with http
http/https variable in settingsblock?
- cooldown period?
- examples how to change ping frequency?
I experience a lot of online/offline with my samsung s7. while the telephone is in range (even next to it) and pingable /scanable.
I will test it a little bit longer.
- remb0
- Posts: 499
- Joined: Thursday 11 July 2013 22:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
pinging works create but the bleutooth not.
l2ping -c1 -s32 -t1 "34:14:5f:17:2e:f6"
I got: Can't connect: No route to host
what can I check?
l2ping -c1 -s32 -t1 "34:14:5f:17:2e:f6"
I got: Can't connect: No route to host
what can I check?
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
remb0 do you have more than 1 bluetooth dongle on that system?
Can you run hcitool scan and detect a bluetooth device in discover mode?
Can you run hcitool scan and detect a bluetooth device in discover mode?
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
- remb0
- Posts: 499
- Joined: Thursday 11 July 2013 22:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
I started with a fresh rpi image and guess what: it works out of the box!!
- deejc
- Posts: 168
- Joined: Tuesday 22 September 2015 18:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5641
- Location: UK
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
this is working great for me right off the bat!! on my iPhone 5s
how might this affect battery life ?
how might this affect battery life ?
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
- deejc
- Posts: 168
- Joined: Tuesday 22 September 2015 18:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5641
- Location: UK
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
Actually I may have been a bit premature in my celebration. I put notifications on the switch for each on and off and it can't ping it quite often. It seems to goto deep sleep and even Bluetooth fails, shame, I thought it had it sorted with this script. Oh well back to the drawing board!
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
Well obviously if the device won't respond at all via either Wifi or Bluetooth then no script is going to be able to see it... That said it works perfectly with my iPhone 6s, I haven't noticed any additional drain on the battery. Also keep in mind the short range of Bluetooth.
Another option for you might be to use the iBeacon feature within Pilot to turn on a Domoticz device when the phone detects an iBeacon.
viewtopic.php?t=12906
Another option for you might be to use the iBeacon feature within Pilot to turn on a Domoticz device when the phone detects an iBeacon.
viewtopic.php?t=12906
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
- deejc
- Posts: 168
- Joined: Tuesday 22 September 2015 18:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5641
- Location: UK
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
not sure why the phone drops off both the wifi and BT but it does.
i tried the iBeacon script but it seems my bt dongle is an old one and won't work properly
Can't set advertise mode on hci0: Input/output error (5), maybe i'll get a BTLE dongle
i tried the iBeacon script but it seems my bt dongle is an old one and won't work properly
Can't set advertise mode on hci0: Input/output error (5), maybe i'll get a BTLE dongle
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
It must be Bluetooth 4.0 or higher to be able to broadcast an iBeacon.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
-
- Posts: 12
- Joined: Tuesday 14 June 2016 15:44
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
Works fine for me, with a CSR 4.0 USB dongle plugged on my synology.
I'm able to detect my iPhone via Wifi or Bluetooth.
But I would like to go further and try to detect my beacons (chipolos), but I'm not able to find their ble mac address.
Any idea guys ?
Thx
I'm able to detect my iPhone via Wifi or Bluetooth.
But I would like to go further and try to detect my beacons (chipolos), but I'm not able to find their ble mac address.
Any idea guys ?
Thx
Re: Ultimate Wifi and Bluetooth Presence Detection
If you mean scanning ibeacons, there are also for the iphone apps available, but I used on my mac
https://itunes.apple.com/us/app/beacon- ... 4474?mt=12
but thats ibeacons,... not sure if that is the same...
https://itunes.apple.com/us/app/beacon- ... 4474?mt=12
but thats ibeacons,... not sure if that is the same...
-
- Posts: 12
- Joined: Tuesday 14 June 2016 15:44
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
Finally, I've got the iBeacon bluetooth mac address in my synology interface, they have been detected by the system
BUT, because there is always a BUT, l2ping doesn't work with the 2 address of my iBeacons
Is l2ping able to dialog with BLE devices (I don't have any issue with my iPhone or mac detection with l2ping) ?
Thx
PS : I'm running on synology, not on PI, not sure if I have the latest version of l2ping

BUT, because there is always a BUT, l2ping doesn't work with the 2 address of my iBeacons

Is l2ping able to dialog with BLE devices (I don't have any issue with my iPhone or mac detection with l2ping) ?
Thx
PS : I'm running on synology, not on PI, not sure if I have the latest version of l2ping
- deejc
- Posts: 168
- Joined: Tuesday 22 September 2015 18:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5641
- Location: UK
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
Why are you trying to ping the beacons? They usually are in fixed positions and the phone uses them for location
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
-
- Posts: 12
- Joined: Tuesday 14 June 2016 15:44
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
iBeacons may not be the correct term. I have bought bluetooth trackers (chipolo), and I want to know when they are at home (as my iPhone), that's why I want to ping them.deejc wrote:Why are you trying to ping the beacons? They usually are in fixed positions and the phone uses them for location
Sent from my iPhone using Tapatalk
Thx
- deejc
- Posts: 168
- Joined: Tuesday 22 September 2015 18:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5641
- Location: UK
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
got my £6 dongle today, working right away!!! thanks for the script
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
$3 mod for my $5 USB bluetooth adapter.

Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
-
- Posts: 3
- Joined: Monday 29 August 2016 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
Hi,
Really liked the presence detection script but somehow it doesn’t seems to work the right way. The output I’m getting is:
Tried manually pinging both Wifi and Bluetooth and this works perfectly.
Any ideas guys what could be wrong?
Thanks!
Really liked the presence detection script but somehow it doesn’t seems to work the right way. The output I’m getting is:
Code: Select all
pi@raspberrypi:~/domoticz/scripts$ sudo ./iphone_roger.sh
./iphone_roger.sh: 1: ./iphone_roger.sh: #!/bin/bash: not found
./iphone_roger.sh: 25: ./iphone_roger.sh: [[: not found
./iphone_roger.sh: 35: ./iphone_roger.sh: [[: not found
./iphone_roger.sh: 45: ./iphone_roger.sh: [[: not found
./iphone_roger.sh: 55: ./iphone_roger.sh: [[: not found
Status in sync
./iphone_roger.sh: 25: ./iphone_roger.sh: [[: not found
./iphone_roger.sh: 35: ./iphone_roger.sh: [[: not found
./iphone_roger.sh: 45: ./iphone_roger.sh: [[: not found
./iphone_roger.sh: 55: ./iphone_roger.sh: [[: not found
Status in sync
Code: Select all
pi@raspberrypi:~/domoticz/scripts$ sudo l2ping -c1 -s32 -t1 "34:A3:95:DE:2B:A2"
Ping: 34:A3:95:DE:2B:A2 from B8:27:EB:60:5E:3A (data size 32) ...
32 bytes from 34:A3:95:DE:2B:A2 id 0 time 6.96ms
1 sent, 1 received, 0% loss
pi@raspberrypi:~/domoticz/scripts$ fping -c1 -b 32 -t1000 192.168.2.40
192.168.2.40 : [0], 60 bytes, 112 ms (112 avg, 0% loss)
192.168.2.40 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 112/112/112
pi@raspberrypi:~/domoticz/scripts$
Thanks!
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: Ultimate Wifi and Bluetooth Presence Detection
That error usually appears when you try to run the script via SH, example:
sh script.sh
The correct way to run the script is sudo ./script.sh
In this case however there may be something wrong with your linux installation.
Try running the command:
sudo /bin/bash
Post the output
sh script.sh
The correct way to run the script is sudo ./script.sh
In this case however there may be something wrong with your linux installation.
Try running the command:
sudo /bin/bash
Post the output
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Who is online
Users browsing this forum: No registered users and 1 guest