piBeacon: 1- how does it work, read me first

Posted on
Sun Jan 31, 2016 11:01 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: 1- how does it work, read me first

What it does:
  • It will allow bluetooth v4 (BLE) iBeacons to be used as presence detector devices with very fast reaction time (~ 0.5 seconds) and independent of any internet connection.
    Each iBeacon has a unique MAC number as well as a UUID-Major-Minor number. The UUIDs can be the same, - The plugin will be using the MAC number to identify each iBeacon and show the UUID-Major-Minor in the notes field.
  • With version >1.8 you can attached different sensors (temp, humidity, pressure, light, analog voltage, resistor measurements, IR switches, PIR , gyroscope, magnetometer, microwave sensor etc) and use GPIO pins or a DAC as output to drive e.g. LED or switches. (see sensors thread http://forums.indigodomo.com/viewtopic.php?f=187&t=15563
  • With V > 1.17 you can connect to any BLE enabled device. You must have its BLE-MAC#. It will initiate a connection, wait for the first package back and stop. It will deliver info UP/Down RSSI and TxPower -can be used similar to an iBeacon. This means you can use your (i)Phone as presence detector. The reaction time is ~ 5-10 seconds to show UP when the Phone enters the range of an rPi.

a simple step by step for a basic setup is here:
https://www.dropbox.com/s/k2ed4ibuhmlgy39/How%20to%20install%20piBeacon%20plugin%20and%20Raspberry%20Pi.pdf?dl=1
and the word file, if someone was to add:
https://www.dropbox.com/s/5q38yqk925cl4v8/How%20to%20install%20piBeacon%20plugin%20and%20Raspberry%20Pi.docx?dl=1


The whole setup consists of
1. a plugin
2. one or up to 20 raspberry pi (rPi)
3. a bluetooth dongle connected to the USB port on the rPi (rpi3 comes with all required devices included)
4. iBeacons, and or sensors etc
5. if you like you can connect sensors or digital inputs or outputs to the rPi. They are set/managed and read by the plugin ,see

use http://forums.indigodomo.com/viewtopic.php?f=187&t=15120 for discussion.
tested beacons: http://forums.indigodomo.com/viewtopic.php?f=187&t=15360

The iBeacon functionality:
  1. The plugin piBeacon will communicate with and configure 1-10 raspberyPi's to be detectors for the BLE devices.
  2. The plugin will create one indigo device for each BLE device found. It will contain STATES: Pi_#_Signal,Pi_#_Distance, Pi_#_Time, x,y,z position at your home from each pi-server#.
  3. Each Pi server collects messages from all devices in their range and will send updates once a minute (can be changed) to the plugin. If a NEW device is found or a down device reappears a (curl) message will be send immediately(~0.5-1 second) through the indigo web server which will populate a variable and the plugin is listening to any changes in these variables..
  4. Then the plugin will create/update a device with the name "beacon-MAC#" of the bluetooth device in the indigo folder piBeacons. - You can create a list of MAC numbers you want to exclude from being tracked (can be reversed later) in the plugin menu.
  5. If a BLE device has send a msg (they do this each 0.1..10 seconds) the status of the beacon device will be set to “up”.
  6. After a defined time if no signal is received from ANY pi-server for a BLE-beacon the plugin status will be set to DOWN from UP and to EXPIRED from DOWN. This time can be set in the config -
  7. When enabled: a message is send to fingscan, FINGSCAN then uses the up/down info to be used in Events like iFindStuff or MotherCookie devices..

Screen Shot 2016-02-12 at 4.13.21 PM.png
Screen Shot 2016-02-12 at 4.13.21 PM.png (170.22 KiB) Viewed 8236 times
Screen Shot 2016-02-12 at 4.13.08 PM.png
Screen Shot 2016-02-12 at 4.13.08 PM.png (124.36 KiB) Viewed 8236 times


With this info you can
-set triggers: If device xx/status changed to “up” you are coming home, if it changes to down or expired you are gone.
- determine where in your home the beacon is
By adding enough pi-servers you can cover the whole house as the range is ~ 20 meters or 1-2 wooden walls

The plugin calculates the distance from the py with the formula:
Code: Select all
 distance= sqrt( 10^(transmitPower-receivedPower)/10) ( transmitPower =powerMeasured at 1m)
powers are in dBm (-99 is off; 0 is very high; normal measured values are -50 to -85)
This works well as long as the pi and the beacon are in the same room. Each wooden wall adds~ 20 m to the distance.
It also calculate the approximate position of the beacon relative the to raspberry server by picking the lowest and correcting the postion by a weighted (x,y,z) distance to the next rPi's ((x,y,z)rip-(x,y,z)rpi0)/distance. This gives an approximate ~ 3-5 meter accuracy in the room.

None of this requires any communication to the Internet everything is done on your home network - and VERY fast ~ 0.5-2 seconds response time depending on settings

BLE is better fitted for this task than WiFi. BLE is CONSTANTLY sending low energy signals. Using WiFi takes too much energy for battery devices and hence they go to sleep frequently and do not answer PINGs. On the other side BLE has a limited range. But this can be covered by setting up multiple raspberry pi to cover the whole house eg front, middle and back of home.



How to install .. no programming is required, follow installation steps and the plugin will configure each raspberry pi for you.

    buy:
    • 1..10 Pi servers. I recommend Pi-3 as it comes fully configured. The rPi2 needs wifi and BLE dongle
      an 8GByte SSD card for each raspberry ($4 Amazon)
      if you have rip,1,2 you need a bluetooth dongle for each Pi, I recommend CSR Bluetooth 4.0 (~$11 Amazon)
      ... can't use ethernet get a wifi dongle . I recommend Kootek Raspberry Pi Wifi Dongle Adapter - 150Mbps Fully Compatible USB Wifi For Raspberry Pi/Windows /Linux/Mac OS ($8)
      total ~ $55-$70
    • as many Beacon as you like - I recommend e.g. RADIUS RadBeacon Dot http://store.radiusnetworks.com/collect ... beacon-dot. They are cheap, have an on/off button and can be configured ( using your iphone: signal output strength and refresh frequency and name). They are about $15 per device. Or the XY ones, see thread on iBeacons tested.
    download from dropbox http://forums.indigodomo.com/viewtopic.php?f=187&t=15152 install
    • follow the instructions how to image each SSD card and then insert into each pi - add bluetooth dongle/ ethernet cable/ wifi into pi.
    • load plugin and configure:
      • in config define the general parameters
      • In menu/piBeacon/"setup rPi servers" configure each pi with IP number userid/passwords etc. (use the router or fingscan to find the ip numbers assigned by your DHCP server ie router)
      • if you use WiFi, first connect each pi with an ethernet connection and set it up. Then add router wifi SSID and password in config. In the plugin menu do "configure wifi” configure each for each WiFi pi (that will configure the proper interface files on the pi). — Then you can disconnect the ethernet cable. and next time it will boot into wifi if you disconnect the ethernet card
      • then use menu/piBeacon/"replace indigo web server plugin with .. " This will add one line to the default indigo web server i.e. do not log all the messages receiving from the pi servers in the log file. You will need to restart the indigo server to activate it. You can restore the old version by copying the saved (.original) back to the .py file, see log file for instructions You do not have to do this, but the log file will be busy with messages from the Pi- servers as the logger will write a message every 60 seconds for each pi server or much more if you use also sensors.
[/list]
That should be it. Ready to use the system. I would recommend to just start with ONE raspberry pi, figure it out and when you feel comfortable add more. AND you will be astonished how many BLE devices you have in your home, or that walk or drive by your house

As you use it you might want to play with the expert parameters and tune them to your need. ie refresh rate, how often each pi will send info, how fast the state transition from Up to down to expired etc


screen shots:
detailed config steps:
the plugin selection menu:
menu1.png
menu1.png (111.12 KiB) Viewed 8135 times

first setup config, enter userid and passwords of router and mac:
Screen Shot 2017-06-02 at 17.48.58.png
Screen Shot 2017-06-02 at 17.48.58.png (231.85 KiB) Viewed 5761 times

then setup the rPi parameters. The plugin will be using THIS info to send config, programs etc to the rPis. without this the rPis don know where the MAC is.
pi config-3.png
pi config-3.png (70.36 KiB) Viewed 8232 times

the let it run. The plugin will be creating iBeacons and also the devices for the rPi(s).
DO NOT CREATE IBEACON DEVICES for rPi and iBeacons yourself !!!

Then go and configure the rPi devices they are named : pi-xx:xx:xx:xx Please name them to e.g. PI-0-Place :
config pi.png
config pi.png (54.45 KiB) Viewed 8135 times

and the ibeacon devices if need.: beacon-xx:xx:xx:xx Please name them to e.g. b-Place. If they are not renamed, the plugin will delete them with 1 hour of inactivity-see later for discussion why
Screen Shot 2016-02-12 at 4.48.17 PM.png
Screen Shot 2016-02-12 at 4.48.17 PM.png (66.6 KiB) Viewed 8232 times
the normal settings should be ok.

The main indigigo device screen with the states.
devlist.png
devlist.png (296.33 KiB) Viewed 8135 times

Then after some time, especially if you have cars driving by your house you will see many iBeacons popping. (I have a bout 50 new per day)
Thats where the ignore feature comes in. The plugin will delete iBeacons if they show up once and have no activity for > 1 hour. But the plugin will be remembering them in case they come by tomorrow again. Once put on the "IGNORElist" they will not be visible as devices.
To make life easier you can also set a certain type of UUID to be ignored If they have the same 12 first characters in their UUID field you can select the in the family ignore to be ignored or un-ignored.
Screen Shot 2016-02-12 at 4.57.26 PM.png
Screen Shot 2016-02-12 at 4.57.26 PM.png (81.31 KiB) Viewed 8232 times
Screen Shot 2016-02-12 at 4.57.59 PM.png
Screen Shot 2016-02-12 at 4.57.59 PM.png (208.33 KiB) Viewed 8232 times


with map uuid to name you can replace the UUID string shown in the notes field with a readable name:
map uuid to name.png
map uuid to name.png (32.74 KiB) Viewed 8135 times


You can also use iPhones as iBeacon if you run the app locate for exanple. The issues is that the iPhone changes its MAC number overtime the app restarts, but the UUID stays the same. So we added the feature to not identify a device by its MAC number but by the UUID:
Screen Shot 2016-02-12 at 5.01.13 PM.png
Screen Shot 2016-02-12 at 5.01.13 PM.png (27.86 KiB) Viewed 8231 times

here you select a Beacon device and declare it an iPhone. After that the MAC number will be ignored and the system will only look for the UUID for THIS device.


As the system is using the indigo web server, any message coming from the rPi will be logged in the indigo log file. You can switch that of with the option "replace indigowebserver file by reduced logging option version. This version will loo to the signature of the rPi messages and will ignore them in the logger.

For the SENSOR and OUPUT setup please check outhttp://forums.indigodomo.com/viewtopic.php?f=187&t=15563


you can also print the current config to the log file with the last option in the menu:
Code: Select all
=============================  example of a prin t config to log file:
    pi configuration                ---------------------- Parameters START ----------------------
  pi configuration                debugLevel Indigo            0
  pi configuration                debugLevel Pi                0
  pi configuration                distance Units               1.0   1=m, 0.3=f, 0.9=y
  pi configuration                myIp Number                 
  pi configuration                port# of indigoWebServer   
  pi configuration                indigo UserID                ....
  pi configuration                indigo Password              ....
  pi configuration                WiFi key_mgmt                WPA-
  pi configuration                WiFi Password                .....
  pi configuration                WiFi SSID                   
  pi configuration                Router IP                   
  pi configuration                Seconds UP to DOWN           80.0
  pi configuration                enable FINGSCAN interface    1
  pi configuration                rejct Beacons with txPower > 999 dBm
  pi configuration                beacon folder Name           piBeacons
  pi configuration               
  pi configuration                Parameters for each PI       
  pi configuration                  # R# IP#            Vers beacon-MAC        indigoName            Pos X,Y,Z    indigoID UserID       Password            If-rPI-Hangs  SensorAttached
  pi configuration                  0  0 192.168.1.20    3   5C:F3:70:6D:DA:7A Pi-0-Karl               10,12,5   191577428 pi           raspberry           reboot        3    i2cBMExx,     
  pi configuration                  1  1 192.168.1.21    3   5C:F3:70:69:69:FB Pi-1-FL                   4,1,0   898861938 pi           raspberry           restartLoop   3    0,             
  pi configuration                  2  2 192.168.1.22    3   5C:F3:70:6B:BD:ED Pi-2-Leo                  1,1,5   570781268 pi           raspberry           reboot        3    DHTxx,         
  pi configuration                  3  3 192.168.1.23    3   5C:F3:70:6D:D8:E9 Pi-3-GR                  6,15,5  1948695375 pi           raspberry           reboot        3    0,             
  pi configuration                  4  4 192.168.1.24    3   5C:F3:70:6B:BE:A8 Pi-4-Fam                  1,7,0   751583395 pi           raspberry           reboot        3    0,             
  pi configuration                  5  5 192.168.1.25    3   5C:F3:70:6D:D9:4D Pi-5-kons                 3,7,5   589031887 pi           raspberry           reboot        3    i2cBMPxx,     
  pi configuration                  6  6 192.168.1.26    3   5C:F3:70:6D:DA:76 Pi-6-FR                   8,8,0  1258418029 pi           raspberry           reboot        3    0,             
  pi configuration                  7  7 192.168.1.27    3   5C:F3:70:6D:D9:6E Pi-7-EX                 12,17,0  1805051158 pi           raspberry           reboot        3    0,             
  pi configuration                  8  8 192.168.1.28    3   5C:F3:70:6D:DA:75 Pi-8-Kitchen              9,5,0  1472673344 pi           raspberry           reboot        3    0,             
  pi configuration                  9  9 192.168.1.29    3   5C:F3:70:6D:D9:4A Pi-9-MB                   8,1,4   498181979 pi           raspberry           reboot        3    0,             
  pi configuration               
  pi configuration                EXPERT parameters for each PI:----------
  pi configuration                delete History after xSecs   86400
  pi configuration                MaxCall BLE bfsend           900
  pi configuration                Max Parse Seconds            1.0
  pi configuration                ask BLE for x Msgs           20
  pi configuration                colct x secs bf snd          60
  pi configuration                reboot pi after xSecs        86400
  pi configuration                port# on rPi 4 GPIO commands 9999
  pi configuration               
  pi configuration                #  defined beacons-------------
  pi configuration                #  Beacon MAC        indigoName               Status             type    txMin ignore sigDlt b-lvl   LastUp[s] ExpTime updDelay   created
  pi configuration                1  E8:D4:17:49:9C:6A b-big-black              up               Jaalee      -60      0    999   100           0      90       60 2016-01-31 00:14:21
  pi configuration                2  D4:D4:36:86:9B:60 b-big-white              up               Jaalee      -60      0    999    50           1      90       60 2016-01-31 00:14:21
  pi configuration                1  D4:F5:13:79:F3:E7 b-big-Green              up                sanwo     9999      0    999                 1      90      300 2016-01-31 00:14:21
  pi configuration                1  D4:DA:48:4A:C9:F7 b-tile-x                 up                 tile      -67      0    999                 1      90        0 2016-01-31 00:14:21
  pi configuration                2  CB:4A:59:D7:C6:6B b-tile-y                 up                 tile      -67      0    999                 0      90        0 2016-01-31 00:14:21
  pi configuration                3  F1:4C:CE:08:E4:80 b-tile-zz                up                 tile      -67      0    999                 1      90      300 2016-01-31 00:14:21
  pi configuration                1  00:EA:23:0B:E2:54 b-xy-a                   up                   xy     9999      0    999                 1      90      300 2016-01-31 00:14:21
  pi configuration                2  00:EA:23:09:81:54 b-xy-blue-volvo          up                   xy     9999      0    999                 1      90      300 2016-01-31 00:14:21
  pi configuration                3  00:EA:23:11:2B:E4 b-xy-red-mazda           up                   xy     9999      0    999                 1      90      300 2016-01-31 00:14:21
  pi configuration                1  0C:F3:EE:00:80:39 b-radius-3               up               radius     9999      0    999                 1      90      300 2016-01-31 00:14:21
  pi configuration                2  0C:F3:EE:00:83:40 b-radius-2               up               radius      999      0    999                 0      60        0 2016-01-31 00:14:21
  pi configuration                1  0E:0A:00:00:19:F9 b-pebblebee-a            up            pebbleBee      999      0    999                 1      90      120 2016-01-31 00:14:21
  pi configuration                1  00:1B:35:0E:9E:A6 b-jin-bec05              up                JINOU      -69      0    999                 1      90        0 2016-01-31 00:14:21
  pi configuration                1  9C:20:7B:86:88:6C beacon-9C:20:7B:86:88..  up                other      999      0    999                11      90      100 2016-01-31 00:14:21
  pi configuration                2  E0:48:5B:9B:B5:5A b-tile bb                up                other      -67      0    999                 1      90       60 2016-01-31 00:14:21
  pi configuration                3  00:EA:23:0B:E2:57 beacon-00:EA:23:0B:E2..  up                other      999      0    999                 1      90      100 2016-02-12 08:18:39
  pi configuration                4  0E:0A:14:09:49:52 b-pebblebee-y            up                other      -60      0    999                 1      90       60 2016-01-31 00:14:21
  pi configuration                5  0E:0A:14:09:3F:19 b-pebble-Beex            up                other      -60      0    999                 1      90        0 2016-01-31 00:14:21
  pi configuration                6  00:EA:23:09:81:57 beacon-00:EA:23:09:81..  up                other      999      0    999                 1      90      100 2016-02-12 08:18:17
  pi configuration                7  D0:4F:7E:21:73:37 b-in the back            up                other      -50      0    999                 1      90        0 2016-01-31 00:14:21
  pi configuration                8  0C:F3:EE:00:66:15 b-radius-1               up                other     9999      0    999                 1      90      100 2016-01-31 00:14:21
  pi configuration                1  5C:F3:70:6D:D9:4D Pi-5-kons                up                  rPi      999      0    999                 0      90      300 2016-02-12 08:18:39
  pi configuration                2  5C:F3:70:6D:D9:4A Pi-9-MB                  up                  rPi      999      0    999                 0     240      300 2016-02-12 08:16:31
  pi configuration                3  5C:F3:70:6D:DA:7A Pi-0-Karl                up                  rPi      999      0    999                 1     240      300 2016-02-12 08:18:17
  pi configuration                4  5C:F3:70:6D:D8:E9 Pi-3-GR                  up                  rPi      999      0    999                 1     360      300 2016-01-31 00:14:21
  pi configuration                5  5C:F3:70:6D:DA:75 Pi-8-Kitchen             up                  rPi      999      0    999                 0      90      300 2016-01-31 00:14:21
  pi configuration                6  5C:F3:70:6D:DA:76 Pi-6-FR                  up                  rPi      999      0    999                 0      90      300 2016-01-31 00:14:21
  pi configuration                7  5C:F3:70:6B:BE:A8 Pi-4-Fam                 up                  rPi      999      0    999                 0     240      300 2016-02-12 08:16:16
  pi configuration                8  5C:F3:70:69:69:FB Pi-1-FL                  up                  rPi      999      0    999                 0     240      300 2016-02-12 08:18:41
  pi configuration                9  5C:F3:70:6B:BD:ED Pi-2-Leo                 up                  rPi      999      0    999                 0     360      300 2016-02-12 08:18:56
  pi configuration                10 5C:F3:70:6D:D9:6E Pi-7-EX                  up                  rPi      999      0    999                 1     240      300 2016-02-12 08:16:23
  pi configuration                1  6A:8E:C0:17:8D:39 beacon-6A:8E:C0:17:8D..  down              other      999      0    999               173      90      100 2016-01-31 00:14:21
  pi configuration                1  0E:0A:14:09:08:8A b-pebbleBee-2            expired       pebbleBee      -60      0    999     0  1455318353     180       60 2016-01-31 00:14:21
  pi configuration                1  5C:F3:70:6D:F1:5C b-Pi-11                  expired           other     9999      0    999     0  1455318353      90        0 2016-01-31 00:14:21
  pi configuration                2  FC:21:66:75:7A:27 beacon-FC:21:66:75:7A..  expired           other      999      0    999     0        2346      90      100 2016-01-31 00:14:21
  pi configuration                3  C0:1C:E2:C7:41:8C beacon-C0:1C:E2:C7:41..  expired           other      999      0    999     0        2804      90      100 2016-02-12 08:18:56
  pi configuration                4  C9:04:FD:42:1A:96 beacon-C9:04:FD:42:1A..  expired           other      999      0    999              2836      90      100 2016-01-31 00:14:21
  pi configuration                5  7A:CD:21:CE:4F:43 b-iphone-3-2             expired           other     9999      0    999     0  1455318353      90        0 2016-01-31 00:14:21
  pi configuration                6  68:D7:89:9F:C5:3C beacon-68:D7:89:9F:C5..  expired           other      999      0    999               399      90      100 2016-01-31 00:14:21
  pi configuration                1  60:14:2D:E3:D2:90                          ignored           other      999      1    999     0      149325      90        0 2016-01-31 00:14:21
  pi configuration                2  6D:78:2C:F3:1C:2F                          ignored           other      999      1    999     0      105434      90        0 2016-01-31 00:14:21
  pi configuration                3  52:20:D0:64:68:AF                          ignored           other      999      1    999     0       82295      90        0 2016-01-31 00:14:21
  pi configuration                4  60:03:08:B7:00:03                          ignored           other      999      1    999     0      173643      90        0 2016-01-31 00:14:21
  pi configuration                5  4A:73:AC:87:9D:52                          ignored           other      999      1    999     0       98284      90        0 2016-01-31 00:14:21
  pi configuration                6  56:FE:4D:64:A7:3D                          ignored           other      999      1    999              6500      90        0 2016-01-31 00:14:21
  pi configuration                7  56:12:63:64:53:A2                          ignored           other      999      1    999     0       82569      90        0 2016-01-31 00:14:21
  pi configuration                8  73:57:B7:49:87:2C                          ignored           other      999      1    999             17929      90        0 2016-02-12 08:18:56
  pi configuration                9  77:94:DC:3A:31:59                          ignored           other      999      1    999     0      105186      90        0 2016-01-31 00:14:21
  pi configuration                10 E8:58:1C:57:E1:C0                          ignored           other      999      1    999     0      165136      90        0 2016-01-31 00:14:21
  pi configuration                11 71:58:0D:A1:66:F9                          ignored           other      999      1    999     0      170979      90        0 2016-01-31 00:14:21
....

Future additions:



Karl

appendix...



What can go wrong:
- ip config of the RPI is wrong. You might need to manually configure the ip setup of the PI

Detailed installation steps for the SSD card for the Raspberry Pi
see http://forums.indigodomo.com/viewtopic.php?f=187&t=15482Karl


a good reference for the rPi pin layout:
Screen Shot 2016-02-17 at 7.43.40 PM.png
Screen Shot 2016-02-17 at 7.43.40 PM.png (1001.71 KiB) Viewed 8159 times

Posted on
Tue May 24, 2022 3:38 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 1- how does it work, read me first

Attention:
with MAC os 12.2 and higher you need to enable terminal to access directories.
in system prefs / security / privacy / full disk access / check terminal

This is needed as several functions to eg. create compressed png files for several functions ie position of beacons in house, lid images etc are launched in a terminal session.

Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron