iBeacon...but in reverse

Posted on
Sun Nov 08, 2015 6:37 pm
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

iBeacon...but in reverse

So I am new to Indigo, but not to HA. I have been playing around with iBeacon at a very low level. So my idea is for a plugin which will scan via Bluetooth for the presence of an iBeacon. From my understanding iBeacon are fixed at a location and you phone then connects when in range and sends a webhook, which is picked by a plugin in Indigo.

My idea (which may have already been done, but my search didn't find anything) is to do away with the phone, and use just a small iBeacon and the bluetooth on the Mac.

So using something like this: http://www.ebay.co.uk/itm/BEACON101-IBe ... =undefined attached to your keyring. When you get within range the plugin would then detect you and either set a variable or be a virtual motion sensor. These iBeacons are relatively inexpensive £4.99, have unique ID's, have a range of about 40m, and the battery can last up to 12 months (with a poll of 1 sec). So seems like the ideal presence device. Plus you could put one on your key chain, one somewhere on the car, and one for the wife, and with a bit of logic it could work out if you have both left the house, who has taken the car, or if you have both gone etc etc.

I have found an App for the Mac (http://www.hugeinc.com/ideas/perspectiv ... ty-for-osx), which seems to do the bluetooth scanning side of things (works quite well testing with my Mac and my iPhone as an iBeacon).

Now comes the problems, I am not a programmer in any way, shape or form, so this is where I get stuck. Anyone willing to pick this up? Or at least point me in the right direction?

Thanks

Stuart

Posted on
Mon Nov 09, 2015 9:31 am
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

So to follow up a little more on this I have found the following: http://www.freeibeaconapps.com/#page-bl ... 78y0mp9zfr

A couple of Apps of interest in this; the first being Beacon Launcher, this runs a script when a Mac enters the range of an iBeacon, however could also work in reverse when an iBeacon enters the range of a Mac.

The second would fit more with a plugin, and this is beaconscan. This is a command line tool which can output in a JSON format. I wonder if this can be used with the current Beacon plugin which takes an input on port 6192.

Anyway a few ideas.

Posted on
Mon Nov 09, 2015 12:06 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: iBeacon...but in reverse

I would be interested in jumping into that..

have to check where I can get cheap ibeacons in the us.

Karl

Posted on
Mon Nov 09, 2015 12:13 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: iBeacon...but in reverse

the cheapest I could find was $11 at amazon,

what source / model are you looking at?

Karl

Posted on
Mon Nov 09, 2015 3:27 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: iBeacon...but in reverse

the 40m meter distance is likely only true without walls, we probably need more that one receiver .. raspberry pi looks like a valid tool, may be we can even use an ESP 8622 with a BLE board to submit the data to mac.

this looks interesting

Karl

Posted on
Tue Nov 10, 2015 6:41 am
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

I have been using an App on my iPhone so it can act as a beacon. This seems to work ok. However I have one of the cheapy beacons coming from eBay, so will be able to test it once I get it.

Posted on
Tue Nov 10, 2015 8:46 am
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

Just to follow up, I have cross posted the idea here: viewtopic.php?f=134&t=11935&p=105288#p105288

It looks like the output from beaconscan can be sent to the Beacon Plugin via JSON. So now just need a script to run beaconscan, filter the results and send via HTTP POST to beacon.

Posted on
Tue Nov 10, 2015 3:54 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: iBeacon...but in reverse

Code: Select all
karlMacMini:documents karlwachs$ ./beaconscan -scantime 10
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-31
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-35
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8971 MinorNumber:57940 RSSI:-68
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-31
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-35
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-31
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8971 MinorNumber:57940 RSSI:-67
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-35
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-34
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8977 MinorNumber:11236 RSSI:-31
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8971 MinorNumber:57940 RSSI:-69
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8969 MinorNumber:33108 RSSI:-73
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8969 MinorNumber:33108 RSSI:-68
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8971 MinorNumber:57940 RSSI:-61
RegionUUID:07775DD0-111B-11E4-9191-0800200C9A66 PowerCalibration:-60 Type:iBeacon MajorNumber:8969 MinorNumber:33108 RSSI:-68


got 3 "find It" from amazon for $40

The utility forks fine!
But the signal definitely does not go through 2 walls( wood). Through one wall signal goes from -35 down to -80.
One would need SEVERAL receivers throughout the house to get signal from everywhere, may be a job for a raspberry setup .

Karl

Posted on
Tue Nov 10, 2015 6:03 pm
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

Look what i found: http://developer.radiusnetworks.com/201 ... eacon.html

This does pretty much exactly what is needed. The code here:

Code: Select all
#!/bin/bash

 gpio mode 1 out
 trap "gpio write 1 0" exit
 while read line
 do
   if [[ `echo $line | grep "2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 1 1" ` ]]; then
     gpio write 1 1
   fi
 done


Would just need to be changed and the references to the gpio stuff removed. My view of the code would be:

Code: Select all
#!/bin/bash

 while read line
 do
   if [[ `echo $line | grep "2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 1 1" ` ]]; then
   curl -H "Content-Type: application/json" -X POST -d '{"sender":"user","location":"home","event":"LocationEnter"}' http://INDIGO_IP:6192 
   fi
 done


Obviously changing the UUID, major and minor values for those of your own.

You could run this on several Pi's if needed, which maybe able to drill down on internal location too. For instance if you are inclose to one PI it could send a unique location instead of home for instance it could send "kitchen" or "garage".

Just need to figure out the leaving part of the script to send when you exit the beacon.

Posted on
Tue Nov 10, 2015 6:20 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: iBeacon...but in reverse


Posted on
Thu Nov 12, 2015 8:46 am
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

This is from Radius Networks, they have a prebuilt image with the Bluetooth stack and beaconscan built in: http://developer.radiusnetworks.com/pib ... pdate.html

Just choose your image and write it to the SD Card.

Posted on
Sat Nov 14, 2015 8:03 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: iBeacon...but in reverse

did anyone get this to work on a pi?

I tried the regular raspberry image ( with many sudo apt-get install ..) and got a very basic response , but not the python example to work
and with the radius image , the dongle is recognized but the beacon gives me an error message "set scan parameters failed"

anyone successful?

Karl

Posted on
Sat Nov 14, 2015 2:08 pm
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

I got it running using the radius image and running
Code: Select all
sudo beacon scan


Shows up the beacon which is running on my iphone.

Posted on
Sat Nov 14, 2015 2:32 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

iBeacon...but in reverse

Which ble device did u use and was it pi 1 or 2?


Sent from my iPhone using Tapatalk

Posted on
Sat Nov 14, 2015 5:37 pm
stuartcolman offline
Posts: 81
Joined: Nov 01, 2015
Location: Essex, United Kingdom

Re: iBeacon...but in reverse

I'm using a Pi version 1 I think it's the B one of the early ones. I have a Plugable USB Bluetooth adapater (http://plugable.com/products/usb-bt4le).

I have also abandoned beacon scan for moment.

I found this article: http://www.makeuseof.com/tag/auto-locki ... ty-sensor/

This is a bluetooth proximity lock script. I have adapted the python script shown in it to run a shell command to send presence via the Beacon plugin. At the moment it's detecting my phone, so I'm waiting for the iBeacon to turn up and play around with that.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests