Skip to content

Instantly share code, notes, and snippets.

@jkeefe
Last active September 16, 2023 14:33
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jkeefe/5d3d04ab544405c96147 to your computer and use it in GitHub Desktop.
Save jkeefe/5d3d04ab544405c96147 to your computer and use it in GitHub Desktop.
Notes on using Adafruit's "Bluefruit" BLE sniffer with a Raspberry Pi

BLUETOOTH SNIFFER

Working to sniff Bluetooth Low Energy with the adafruit sniffer

For more information, see this blog post

Going the python route, as described here

before installing pySerial, did ...

apt-get update
apt-get upgrade

which was probably unnecessary and took a long time :-(

then did

sudo pip install pyserial

downloaded the adafruit python sniffer package, sniffer.py

sudo git clone https://github.com/adafruit/Adafruit_BLESniffer_Python.git

changed into that directory

cd Adafruit_BLESniffer_Python/

tried their example command, which worked:

sudo python sniffer.py -h

in order to get pyserial to talk with the usb port, apparently need to do this, to add the "pi" user to the dialout group:

sudo usermod -a -G dialout pi

ok, so now I need a port to listen to ... where the sniffer device is. so apparently I do this:

ls -l /dev/tty*

which lists a whole bunch of things I don't understand, except that the last lines are:

crw------- 1 root root      4,  7 Dec 31  1969 /dev/tty7
crw------- 1 root root      4,  8 Dec 31  1969 /dev/tty8
crw------- 1 root root      4,  9 Dec 31  1969 /dev/tty9
crw-rw---- 1 root tty     204, 64 May 16 13:09 /dev/ttyAMA0
crw-rw---T 1 root dialout   5,  3 Dec 31  1969 /dev/ttyprintk
crw-rw---T 1 root dialout 188,  0 Dec 31  1969 /dev/ttyUSB0

Tried the AMA0 one, which didn't work. The USB0 one, did!

sudo python sniffer.py /dev/ttyUSB0

Results:

Scanning for BLE devices (5s) ...
Found 2 BLE devices:

  [1] "" (B8:78:2E:1C:2F:10, RSSI = -104)
  [2] "MetaWear" (EA:A1:88:31:45:21, RSSI = -88)

Select a device to sniff, or '0' to scan again
> 

Very cool.

@qifeiLiu
Copy link

qifeiLiu commented May 4, 2018

I have tried this on pi3, but the process hung. I don't have Adafruit's BLE sniffer device, just use onboard bluetooth.

crw--w---- 1 root tty 4, 8 May 4 03:17 /dev/tty8
crw--w---- 1 root tty 4, 9 May 4 03:17 /dev/tty9
crw-rw---- 1 root dialout 204, 64 May 4 03:17 /dev/ttyAMA0
crw------- 1 root root 5, 3 May 4 03:17 /dev/ttyprintk

pi@raspberrypi:~/Adafruit_BLESniffer_Python $ sudo python sniffer.py /dev/ttyAMA0
Capturing data to logs/capture.pcap
Connecting to sniffer on /dev/ttyAMA0
Scanning for BLE devices (5s) ...

@EmmettMartinBig
Copy link

Can this be used with ubertooth one?

@jojoschmitt
Copy link

I have tried this on pi3, but the process hung. I don't have Adafruit's BLE sniffer device, just use onboard bluetooth.

crw--w---- 1 root tty 4, 8 May 4 03:17 /dev/tty8
crw--w---- 1 root tty 4, 9 May 4 03:17 /dev/tty9
crw-rw---- 1 root dialout 204, 64 May 4 03:17 /dev/ttyAMA0
crw------- 1 root root 5, 3 May 4 03:17 /dev/ttyprintk

pi@raspberrypi:~/Adafruit_BLESniffer_Python $ sudo python sniffer.py /dev/ttyAMA0
Capturing data to logs/capture.pcap
Connecting to sniffer on /dev/ttyAMA0
Scanning for BLE devices (5s) ...

Still having the same issue in 2021. Here is what came from the log:
12-Jan-2021 11:13:00 (+0000) INFO: Software version: SVN rev. 1111
12-Jan-2021 11:13:00 (+0000) INFO: args: ()
12-Jan-2021 11:13:00 (+0000) INFO: kwargs: {'callbacks': [('*', <bound method Sniffer.passOnNotification of <Sniffer(Thread-2, initial)>>)]}
12-Jan-2021 11:13:00 (+0000) INFO: board ID (random): 120
12-Jan-2021 11:13:00 (+0000) INFO: Error on port /dev/ttyAMA0. file: Packet.py, line 257: Port is already open.
12-Jan-2021 11:13:02 (+0000) INFO: Error on port /dev/ttyAMA0. file: Packet.py, line 258: Write timeout
...

@luishds22
Copy link

Is there a way to use this on Rpi 4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment