The Raspberry Pi 3 is the first in its family to natively support Bluetooth. Since at reelyActive we're passionate about the endless possibilities of detecting "advertising" Bluetooth Low Energy (BLE) devices, we were excited to make the Pi 3 into a sniffer using our open source code. In this tutorial we'll take you step-by-step through building a reliable, standalone BLE sniffer from a virgin Pi 3 (or a Pi Zero W).
At the Eleventh HOPE conference, we showed off a standalone Raspberry Pi 3 Bluetooth Low Energy (BLE) sniffer to the Hackaday crew, which they found cool enough to share with their readers.
You'll find instructions below to replicate the setup and more, making use of the integrated BLE radio. Just add power and network and you have yourself a versatile sub-$100 tool/toy!
Read the Hackaday PostWith the rollout of Pareto Anywhere (our version 1.x software), we've created the following two new tutorials for preparing a Pi and then installing our open source suite:
Our step-by-step guide to prepare a lean yet versatile SD card image for the Pi.
Our step-by-step guide to install and run Pareto Anywhere on a Raspberry Pi to make any physical space context-aware.
If you prefer to continue with the version 0.x software, instead follow the instructions below.
You'll also have access to REST APIs and a real-time data stream over websockets.
You'll need a Raspberry Pi 3 or Raspberry Pi Zero W (or equivalent) with native Bluetooth capability in order to make a standalone sniffer.
If you have a non-Bluetooth Pi, do not despair! You can connect a purpose-built reelyActive starter kit to your Pi via USB for even-better sniffage!
Both items can be purchased by following the links below. If you prefer to get your hands dirty with the reelyActive kit, you can also Build your own USB Hub and purchase the reelceiver.
Does your Pi already have an operating system (Raspbian/NOOBS) installed and is connected to the Internet?
Choose from one of the three options below:
Setup your SD card from a disk image that already has Stretch Lite, Node.js and our software installed. This is the same setup as in the From Scratch option, except we did most of the work for you so that you can skip ahead for instant gratification!
Download our compressed disk image which is pre-configured as follows.
Parameter | Value |
---|---|
Disk Image Version | 2018-07-19-reelyactive-pi |
Raspbian Version | Stretch Lite (2018-06-27) |
Node.js Version | 8.11.3 |
Pre-installed software | pi-suite, generable |
Pre-configured Ethernet | DHCP client with fallback to DHCP server, IP: 10.0.50.100 |
Hostname | reelyactive-pi |
SSH | Enabled. Username: pi, password: berryinsecure. |
Serial | Hardware enabled. Login disabled. |
Unzip 2018-07-19-reelyactive-pi.tar.xz to obtain the 4.0GB disk image: 2018-07-19-reelyactive-pi.img
Transfer the image to an SD card of at least 4GB. There's finally a friendly, cross-platform way to do this using Etcher:
Complete the following in order:
From the command line, ssh into the Pi as follows:
ssh pi@10.0.50.100
The default password will be berryinsecure. You're now connected to the Pi.
Configure the Pi by running the following from the command line:
sudo raspi-config
From the text-based menu, complete the following:
Select Finish, then select Yes when asked to reboot.
SSH back into the Pi once the reboot is complete (using the new password). The Pi is ready! Skip ahead to Start Sniffing!
This is the same setup as in the Quickest option, only starting from scratch using the latest Stretch Lite image and the most recent versions of Node.js and our software.
Download the latest Raspbian Stretch Lite image from www.raspberrypi.org/downloads/raspbian/.
Transfer the image to an SD card of at least 4GB. There's finally a friendly, cross-platform way to do this using Etcher:
Enable SSH (it is disabled by default) by browsing to the root of the /boot folder of the SD card and running from the command line:
sudo touch ./ssh
Disable consistent network device naming (introduced in Stretch) by editing the cmdline.txt file in the same /boot folder:
sudo nano /boot/cmdline.txt
Paste the following to the end of the first line of the file and save:
net.ifnames=0
Enable Ethernet static fallback so that you can directly connect the Pi to your PC and SSH in to a known IP address. Browse to the root of the / folder of the SD card and, from the command line open the dhcpcd.conf file for editing:
sudo nano /etc/dhcpcd.conf
Paste the following lines at the bottom of the file and save:
# Define static profile profile static_eth0 static ip_address=10.0.50.100/24 static routers=10.0.50.1 static domain_name_servers=10.0.50.1 # Fallback to static profile on eth0 interface eth0 fallback static_eth0
This will configure the Pi to use IP address 10.0.50.100 when it is connected to Ethernet without DHCP.
Complete the following in order:
From the command line, ssh into the Pi as follows:
ssh pi@10.0.50.100
The default password will be raspberry. You're now connected to the Pi.
Configure the Pi to act as a DHCP server on the Ethernet port when no external DHCP server is available. From the command line, run the following:
sudo apt-get install dnsmasq sudo mv /etc/dnsmasq.conf /etc/dnsmasq.default
This will install the dnsmasq software. Configure the DHCP server by creating and editing the new dnsmasq.conf file:
sudo nano /etc/dnsmasq.conf
Paste in the following lines and save:
interface=eth0 dhcp-range=10.0.50.2,10.0.50.99,255.255.255.0,12h
This will configure the Ethernet interface to serve IP addresses in the range from 10.0.50.2-99 using DHCP, with a 12-hour lease. Restart the service from the command line for changes to take effect:
sudo service dnsmasq restart
Configure the Pi by running the following from the command line:
sudo raspi-config
From the text-based menu, complete the following:
Select Finish, then select Yes when asked to reboot.
SSH back into the Pi once the reboot is complete (using the new password). The Pi is ready!
Take this beginner-friendly route if you intend to run your Pi as a multi-purpose computer with mouse and keyboard attached. Otherwise we highly recommend the other options which are optimised for performance.
The Pi's filesystem resides on an SD card. If your Pi came with a prepared SD card, lucky you, you get to skip this step!
The Quick Start Guide suggests an 8GB class 4 SD card, which we encourage you to purchase from an established vendor. If the card doesn't come formatted as FAT32, you'll need to do so (read the INSTRUCTIONS-README.txt included in the NOOBS ZIP file).
Download NOOBS and unzip the contents to the root folder of the SD card. You're all set!
Connect the following to your Pi:
Then power the Pi through a high-quality USB power source (ex: phone charger). Follow the instructions on screen to install the Raspbian operating system. This procedure will take some time. Perhaps enjoy a slice or two of delicious raspberry pie while you wait?
After Raspbian boots, connect the Pi to the Internet via either WiFi or Ethernet using the on-screen tools. The Pi is ready!
It is good practice to ensure that the software on the Pi is up to date before proceeding with any software installation. From the command line on the Pi, execute the following in order:
sudo apt-get update sudo apt-get upgrade
Do you have Node.js (version 8) and forever installed?
Yes No UnsureProceed to install pi-suite
Raspbian will likely include an old version of Node.js. Here we'll provide the instructions for installing a known working version of Node.js 8 for different variants of the Pi.
The hci-bluetooth-socket package, which is key to accessing the Bluetooth radio in the Pi, is no longer maintained by its original author and does not support more recent versions of Node.js.
If you wish to proceed with the latest version of Node.js, consider instead following the current version of this tutorial which overcomes this by using the @abandonware/hci-bluetooth-socket package. Otherwise expect things to break on the npm install
below...
Raspberry Pi 3 | node-v8.11.3-linux-armv7l | URL |
---|---|---|
Raspberry Pi Zero (W) | node-v4.8.2-linux-armv6l | URL |
From the command line on the Pi, execute the following in order, substituting the URL and Node version as per the table above:
cd ~/Downloads wget https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-armv7l.tar.xz tar -xf node-v8.11.3-linux-armv7l.tar.xz sudo mv node-v8.11.3-linux-armv7l /usr/local/node cd /usr/local/bin sudo ln -s /usr/local/node/bin/node node sudo ln -s /usr/local/node/bin/npm npm
Confirm that v8.11.3 (or the version you installed) appears when you run node --version
. Node.js is now installed.
cd /usr/local/bin sudo npm install forever -g sudo ln -s /usr/local/node/bin/forever forever
Node.js is a JavaScript runtime which runs libraries (such as our own) from the largest ecosystem of open source libraries in the world. The forever package is one of these libraries, and it will keep our programs running forever, even if they crash.
Open a terminal or command prompt, type node --version
and press Enter.
If the output is something like vx.x.x, you do indeed have Node.js installed. Repeat the test with forever --version
. If both are installed, click Yes above. Otherwise click No above.
The pi-suite is a collection of reelyActive open source software which allows your Pi to:
If you're running the Lite version of Raspian Stretch or Jessie, you'll first need to install git by running sudo apt-get install git-core from the command line.
From the command line on the Pi, execute the following in order:
mkdir ~/reelyActive cd ~/reelyActive git clone https://github.com/reelyactive/pi-suite.git cd pi-suite git checkout release-0.2 npm install
Choose your configuration below and get up and running in an instant.
From the command line on the Pi, where you should still be in the ~/reelyActive/pi-suite folder, execute the following:
sudo node pi-suite
The console output should include a line that says Browse to your Pi at http://xxx.xxx.xxx.xxx with the IP address of your Pi in place of the x values. Copy the link and open it in your browser.
The bubblescape is a visualisation of all the BLE devices sniffed by your Pi. Fancy yourself as a bubble? Install reelyApp on your Android or iOS device to experience the following:
Once you've finished your initial exploration of the various webpages displaying the live data, press Ctrl-C to terminate the execution of pi-suite before proceeding with the next steps.
A HAT is Hardware Attached on Top. We've created, as open hardware, a HAT which connects to the Pi header and provides a direct interface to our reel, allowing you to daisy-chain our reelceivers.
The Reel-Pi HAT communicates using the Pi's hardware serial port, which is disabled by default, but can easily be enabled with raspi-config. From the command line on the Pi, run sudo raspi-config
and then configure as follows:
From the command line on the Pi, where you should still be in the ~/reelyActive/pi-suite folder, execute the following:
sudo node pi-suite-reel
The console output should include a line that says Browse to your Pi at http://xxx.xxx.xxx.xxx with the IP address of your Pi in place of the x values. Copy the link and open it in your browser.
The bubblescape is a visualisation of all the BLE devices sniffed by your Pi. Fancy yourself as a bubble? Install reelyApp on your Android or iOS device to experience the following:
Once you've finished your initial exploration of the various webpages displaying the live data, press Ctrl-C to terminate the execution of pi-suite before proceeding with the next steps.
Connect your starter kit to any free USB port on the Pi taking care to respect the reelceiver directionality, as shown in the video.
From the command line on the Pi, where you should still be in the ~/reelyActive/pi-suite folder, execute the following:
sudo node pi-suite-pareto
Browse to pareto.reelyactive.com and log in with the credentials provided when you purchased the starter kit.
The console output should include a line that says Browse to your Pi at http://xxx.xxx.xxx.xxx with the IP address of your Pi in place of the x values. Copy the link and open it in your browser.
The bubblescape is a visualisation of all the BLE devices sniffed by your Pi. Fancy yourself as a bubble? Install reelyApp on your Android or iOS device to experience the following:
Once you've finished your initial exploration of the various webpages displaying the live data, press Ctrl-C to terminate the execution of pi-suite-pareto before proceeding with the next steps.
Unfortunately that means you have no Bluetooth Low Energy radio on which to listen, as indicated in the Hardware Prerequisites section. May we suggest you purchase a starter kit?
Would you like to do this?
Yes No UnsureIn order for the Pi to display a webpage in kiosk mode, we'll need the Chromium browser (which handles JavaScript much better than the default Epiphany browser) and a window manager. From the command line, execute the following:
sudo apt-get install chromium-browser sudo apt-get install matchbox-window-manager xautomation unclutter
This step applies only if your Pi is running the Lite version of Raspbian Stretch or Jessie which doesn't have a GUI pre-installed. If you're already able to boot into a friendly desktop environment, skip this step . From the command line, execute the following:
sudo apt-get install --no-install-recommends xserver-xorg sudo apt-get install --no-install-recommends xinit sudo apt-get install --no-install-recommends x11-xserver-utils
Here we'll specify what programs to run on boot via the rc.local file. From the command line, open the file for editing with the command sudo nano /etc/rc.local
and paste the following line above the exit 0 line:
sudo forever start /home/pi/reelyActive/pi-suite/pi-suite.js
Press Ctrl-X to save and exit the editor. Note that if you're using the Pi as a hub for a reelyActive starter kit that should forward the real-time data to Pareto, you'll need to change the first line to instead run pi-suite-pareto.js.
Unfortunately, it's tricky to get Chromium to run (as normal user) from the rc.local file, but a workaround is to boot it from the pi user's .bashrc file. From the command line, open the file for editing with the command sudo nano ~/.bashrc
and paste the following line at the end:
xinit /home/pi/reelyActive/pi-suite/display-chromium -- vt$(fgconsole)
Now that the Pi is configured to run-on-boot with a kiosk display, there's no reason for it to load the desktop and waste valuable computing and memory resources. Instead we'll configure the Pi to boot to the console and log in automatically. From the command line, run sudo raspi-config
and from the Boot Options menu, select Console Autologin (which may be under a Desktop/CLI sub-menu).
Reboot the Pi with the command sudo reboot now
or with a power cycle. Confirm that after a minute or so you can browse to the Pi and observe the webpage decoding BLE devices. Also confirm that the webpage is projected on an HDMI-connected monitor (connect the monitor before the reboot so that the resolution can be detected).
Check out the other optional features below.
This final OPTIONAL step configures the Pi to run pi-suite automatically on boot, as well as display its webpage on any monitor via the HDMI port.
If that's what you'd like to do, click Yes above.
Consider implementing the following optional features.
The Pi can easily be pre-configured to connect to multiple WiFi networks. This feature is useful if the Pi is moved to different locations, each with their own WiFi credentials. To pre-configure WiFi credentials, from the command line, open the wpa_supplicant.conf file for editing with the command sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
and paste the following block of code, once for each network, at the bottom of the file.
network={ ssid="ENTER_SSID_HERE" psk="ENTER_PASSWORD_HERE" key_mgmt=WPA-PSK }
Don't forget to enter the SSID and password for each network with much care! Although networks commonly use a pre-shared key (PSK) for authentication, as specified in the example above, it may be necessary to tweak the settings as discussed in details here.
Ethernet fallback ensures that you can always directly connect to your Pi at a known static IP. The Pi will assume the static IP on its Ethernet port in the absence of a DHCP server. To enable Ethernet fallback, from the command line, open the dhcpcd.conf file for editing with the command sudo nano /etc/dhcpcd.conf
and paste the following lines of code at the bottom of the file.
# Define static profile profile static_eth0 static ip_address=10.0.50.100/24 static routers=10.0.50.1 static domain_name_servers=10.0.50.1 # Fallback to static profile on eth0 interface eth0 fallback static_eth0
When all else fails, to log on to the Pi, directly connect your computer to the Pi via Ethernet, set your computer's IP address to 10.0.50.101, and ssh pi@10.0.50.100
Scheduled reboots ensure that the Pi will eventually recover from any soft failure. To force daily reboots via a cron job, from the command line, open the crontab file for editing with the command sudo nano /etc/crontab
and paste the following line of code above the closing #.
0 5 * * * root reboot
The 5 signifies 5am. Adjust this and the other parameters as your application requires.
Enable additional features such as data logging by editing pi-suite.js with the command nano ~/reelyActive/pi-suite/pi-suite.js
or pi-suite-pareto.js with the command nano ~/reelyActive/pi-suite/pi-suite-pareto.js
.
Simply comment or uncomment the desired options by adding or removing two backslashes at the start of each concerned line. Press Ctrl-X to save the file and exit.
Our Pareto platform combines even more features and functionality with the convenience of SaaS. You can even use your Raspberry Pi as a gateway.
Create a beautiful dashboard to display on your kiosk screen! Follow our Build web apps with beaver.js tutorial to tap into the live socket.io data feed from our open source software running on the Pi.
Convert your Pi into the heart of a generative art station with our GeneraBLE project!
Connect your BLE-sniffing Pi to openHAB by following this thread.
If you build your own unique hub and would like to share your project, please get in touch!
Build web apps with beaver.js Make generative art Return to diyActive