Ultimate Wifi and Bluetooth Presence Detection

All kinds of 'OS' scripts

Moderator: leecollings

User avatar
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

Post by remb0 »

I have an zwave card on my board indeed. but didn't use it.

I will remove it and try again.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 »

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
User avatar
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

Post by remb0 »

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.
User avatar
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

Post by remb0 »

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?
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 »

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?
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
User avatar
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

Post by remb0 »

I started with a fresh rpi image and guess what: it works out of the box!!
User avatar
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

Post by deejc »

this is working great for me right off the bat!! on my iPhone 5s
how might this affect battery life ?
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
User avatar
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

Post by deejc »

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
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 »

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
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
User avatar
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

Post by deejc »

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
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 »

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
jnoel68
Posts: 12
Joined: Tuesday 14 June 2016 15:44
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by jnoel68 »

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
trixwood

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by trixwood »

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...
jnoel68
Posts: 12
Joined: Tuesday 14 June 2016 15:44
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by jnoel68 »

Finally, I've got the iBeacon bluetooth mac address in my synology interface, they have been detected by the system :D
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
User avatar
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

Post by deejc »

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
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
jnoel68
Posts: 12
Joined: Tuesday 14 June 2016 15:44
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by jnoel68 »

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
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.
Thx
User avatar
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

Post by deejc »

got my £6 dongle today, working right away!!! thanks for the script
Domoticz 3.5641 on RPI (Raspbian GNU/Linux 8)
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 »

$3 mod for my $5 USB bluetooth adapter. :D
IMG_05044.JPG
IMG_05044.JPG (334.29 KiB) Viewed 7883 times
IMG_05054.JPG
IMG_05054.JPG (306.31 KiB) Viewed 7883 times
IMG_05094.JPG
IMG_05094.JPG (244.96 KiB) Viewed 7883 times
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
siebke
Posts: 3
Joined: Monday 29 August 2016 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by siebke »

Hi,

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
Tried manually pinging both Wifi and Bluetooth and this works perfectly.

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$

Any ideas guys what could be wrong?

Thanks!
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 »

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
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest