10

I'm working remotely and it would be handy to know when someone has gone out for a meeting / lunch in my office.

I thought I might be able to passively detect what phones near the raspberry pi (and then publish them to the web / dropbox / whatever)

What would be the easiest way to do this? MAC address detection? Bluetooth?

10

Much hunting - learned quite a bit - no luck detecting other peoples devices without much of a low level wireless scan - Bluetooth works for iphone if both are your own devices:

  1. Wifi scan might work for some devices, but iOS ones do not connect when screen is off! My iphone 6 could be detected with simple arp command (gives table of ip and mac numbers of connected devices on the same subnet) but this would happen only when phone screen is lighted up. Once the phone screen sleeps - it is out of bounds on wifi! I bet this is in the interest of battery life.

  2. Bluetooth dongle worked. No distance computation unlike some fancy algorithms out there - just present/absent can be done with very little power consumption on rPi and iPhone. Install bluetooth dongle on rPi as: (sudo aptitude install bluetooth bluez-utils bluez-compat). Figure out mac of your phone device by making it searchable and then do (hcitool scan) on rPi. Then connect to your device (make sure its searchable) as: sudo bluez-simple-agent hci0 mac_of_your_device and say yes on both sides. Then sudo bluez-test-device trusted mac_of_your_device. Now they both "know" each other. Then do sudo hcitool name mac_of_your_device in your favourite script to figure out if the iphone is nearby. This will not create a connection - but just say hi to it. If it returns a name, phone is nearby. If it returns nothing - phone is not nearby or bluetooth is switched off. Compared to creating connections or other distance computation methods out there - this method conserves battery on both sides and keeps airwave pollution to a minimum.

9

Me and some friends of mine have been developing a bluetooth-proximity scanner to open our front door lock of our hackerspace.

We've paired all allowed devices and essentially used hcitool to test if one of the paired device is nearby. As an example, if the paired device has the adress "00:00:00:00:00:00", you would do this on the command line console:

hcitool cc 00:00:00:00:00:00 && hcitool auth 00:00:00:00:00:00 && hcitool dc 00:00:00:00:00:00;

If this returns zero, the device is in proximity.

One downside is that this will take ~5 seconds to time-out if the device isn't nearby.

We have published the source-code on Github under the apache open-source licence.

  • 2
    I can confirm that this is working using hcitool .... However, you have to chain the commands like in the example given above. The connection is only active for a very short amount of time. You can add proximity into the mix by doing hcitool rssi .... – Gunnar Nov 21 '16 at 9:16
2

I have seen some setups using bluetooth for similar use cases, but it will probably involve some hacking. The phones you want to detect are typically not in discoverable mode.

If the phones use wifi, you can probably detect some proximity, but this will also probably mean you will have to scan for them at a rather low layer, since they will not access your wifi antenna, and they will probably connect encrypted. Have a look at kismet for some low level wireless bonanza.

The easiest way to detect whether someone is in a room or not, though, I would guess, would be to use the camera module and a panaramic mirror.

1

If you have a WiFi network that they connect to when they are in the office, you could have the PI scan for MAC addresses every x period of time, and update a web page (dropbox, whatever) with current status. Probably the most reliable route.

You might be able to do something with bluetooth, and a USB Bluetooth adapter, but I have no experience with that.

Without them connected to the pi, or the network the pi is on, I don't think you will have much success.

  • Nice. So what tech/app/platform were you thinking I would use to scan the MAC addresses? – ACooleman Apr 26 '14 at 6:52
  • The way I would do it is with nmap, the command line version, and a little custom python code (I'm sure there is a python api), do a quick ping sweep/MAC query, compare that to a pre built list, use that to build a php(HTML?) page and serve it up using lightppd(Apache?) web server. Set the python job to run ever x period of time, and have the web page auto refresh every y period. It's a cool project idea... I might have to give it a shot after i finish up all the other projects that are on my plate. – Butters Apr 27 '14 at 15:24
  • You might be able to query your router for the ARP table, or you DHCP server as well... Might make it a little quicker.. – Butters Apr 27 '14 at 15:25
1

Reading the above answers also triggered me into thinking about the following possiblity:

use airmon-ng to continuously scan the network for client devices on wifi. The output can be written to a file, so if the file changes either a client has entered or left the range of the pi. Having a list of known mac addresses allows you to identify the user and due to the file changing you could trigger some actions....

it is quite an interesting idea! Thanks!

Arjen

  • Large stores use this technique to monitor how shoppers browse their goods, which rayon they skip etc. But due to privacy laws it's not always legal to link a mac address to a person in every country. – Havnar Oct 20 '14 at 11:59
1

As long as the devices are all on the same network, you can easily use a Raspberry Pi to do this.. Here's a complete project with all the code you need...

http://www.element14.com/community/people/mcollinge/blog/2014/09/12/raspberry-pi-network-spy--part-1

  • There is interesting information in the link you provide, however you could improve your answer including what answer to the question. – mpromonet Apr 25 '15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.