Razzmaster Configures Raspberry Pi Over the Network (And It’s Free!)

PubNub is a startup, and like many startups we use a lot of open source software. We are also huge fans of the Raspberry Pi. We’ve even built a Pi workshop because it’s so flexible and easy to get started with. Setting up Raspberry Pis for workshops and projects can be a pain, though, especially if you have a lot of them to set up. To address this I created a small open source tool called Razzmaster which lets you find and configure Raspberry Pis over a local network, even if you don’t know the IP address.

Scanning

Razzmaster is a simple program written in NodeJS to scan the network. It’s based on Adafruit’s awesome PiFinder program, but uses the command line instead of a full GUI (and is a smaller download). To scan for a Raspberry Pi just run:

razzmaster scan
screenshot of scanning for a raspberry pi

It will scan your local network (or multiple if you are connected to multiple networks at once), returning a list of computers it’s found and indicate which one it thinks is probably a RaspberryPi. Then you can ssh into it (most recent Raspberry Pi distros have ssh turned on by default).

Oh, and installing Razzmaster is easy. Since it’s just a nodeJS application you can do npm install -g razzmaster to get the latest version.

Of course, if you have multiple Raspberry Pis on your network how do you know which one you are actually connected to? It turns out every Pi has a green LED that we can control from software. Once you’ve identified the IP address of your Pi, run this to make it’s LED blink:

razzmaster blink --host 192.168.1.3

If you have left the default Raspbian username and password of pi/raspberry then it will just work and you’ll see the LED of the device you are connected to blinking. If you changed the user/pass then you can specify it on the command line with:

razzmaster blink --host 192.168.1.3 --username myusername --password bypass

You can also get the operating system version and other useful info from your Pi with:

razzmaster info --host 192.168.1.3
Razzmaster info example

Installation

Connecting to a Raspberry Pi isn’t very useful by itself. You’ll probably want to configure the wifi and install some packages. Razzmaster can do this too. Just create a JSON file with the wifi credentials and packages you want to install, like this:

{
  "packages":[
    "git",
    "curl",
    "nodejs"
  ],
  "wifi": {
    "ssid”:"MyWifiAP",
    "password":”myp@ssw0rd"
  }
}

and run razzmaster like this:

razzmaster install --host 192.168.1.3 --config myconfig.json

Razzmaster will configure the wifi, update the OS, and install the packages you want. NodeJS is treated specially. Node doesn’t come from the standard Raspbian repos. Instead it requires you configure a special Debian repo from nodejs.org. Razzmaster will handle this for you, automatically installing the latest version of NodeJS.

How Razzmaster Works

Razzmaster may seem like magic, but it’s actually just leveraging some common network utilities built into your operating system. Pretty much anything with a TCP/IP stack will respond to ARP requests. Razzmaster sends out a ping then waits for responses using the arp command. The responses include the IP address and the MAC address of each computer.

A MAC address is a number set by the manufacturer which uniquely identifies every Ethernet chip and WiFi device. While every device has a unique number, the numbers are assigned by the IEEE in large groups by manufacturer. By looking at the first few digits of the number we can make an educated guess of who made it. The ethernet card of all Raspberry Pis have the same prefix, so by matching against a whitelist of known Raspberry Pi related MAC prefixes we can tell if a given IP address is a Pi or not.

This system isn’t perfect. Sometimes a machine doesn’t respond quickly so it’s not included in the list. If Razzmaster can’t detect your Raspberry Pi try running it a few times. If it still doesn’t work, then maybe your Pi is using an unusual wifi dongle that Razzmaster doesn’t know about. Let me know and I’ll add it to the list.

Once you know the IP address, Razzmaster can blink the LED and install updates by using ssh to connect and run canned remote commands. Razzmaster supports the Raspberry Pi 1, 2, and 3 running Raspbian. I just tested the new RPi3 that came in the mail from Adafruit. In theory it should work on a Pi Zero but I haven’t been able to buy one to test it (still hard to get them in the US).

Next Steps

The goal of Razzmaster has always been to get a new Pi up and running as quickly as possible, and I think it does that pretty well. That said, there are a few features I’d like to add in the future. It would be nice if it could handle downloading new Raspbian distros and writing to SD cards automatically instead of having to remember the correct dd command. I’d also like to be able to configure some of the config.txt options like booting into console mode vs X windows.

Finally I’d really like to figure out how to make a Pi reliably boot into just a web browser pointing at a particular webpage. A TV with a Raspberry Pi duct-taped to the back makes a great screen for data dashboards, stock tickers, and looping videos. With the right version of Chromium it should be possible to set up a kiosk in just a few minutes.

Razzmaster is open source, MIT licensed, and available on github. Please file bugs and suggest new features. Special thanks to Adafruit for the original PiFinder program.

 

Turtle eating a raspberry

Try PubNub Today

Connect up to 100 devices for Free