Setup your Raspberry Pi 2/3 with Raspbian headless (without cables)

Claudio Carnino
A Swift misadventure
3 min readJul 11, 2016

As mentioned in a previous article, I need to control some electronic circuit with the GPIOs pins of the Raspberry Pi. I could easily achieve that with Python or C. But I am a cool kid. I want to use Swift.

Jokes aside, I work full-time with Swift, so I got pretty good at it. And I think it will be a great language for robotics.

The plan is that I am going to install Raspbian (Debian customised for Raspberry Pi), configure it and then install the Swift 3.0 binaries.

Background excursus

The Swift team is supporting Ubuntu as their main Linux distro. Ubuntu is great. But to setup a basic Ubuntu installation, you need a monitor and keyboard. With Raspbian, you just turn the RPi on and after 2 minutes it has configured itself. It will have a default user ready. And it comes with installed WebMD, which exposes the machine to the network. So you can immediately ssh into the it. Pretty handy.

Step 1: Preparation

Get your Raspberry Pi 2 or 3, an SD memory card with 8Gb or more memory (class 10 or more), a micro USB cable and an ethernet cable and the Wifi USB dongle.

Step 2: Flashing Raspbian on the SD card

Start by downloading Raspbian Jessie Light (no GUI. GUIs are for posh folks. or kids. or non-techies. or people who want to actually do some productive work. not for you).

No you have to flash the image you just downloaded to the SD card. On the web you find a lot of multi step command line guides. But that’s nuts, since you have a great apps, called Etcher.io, that make the process incredible simple, faster and safer.

Download Etcher app (for all platform), then select the Raspbian image, the SD card (which you have to insert in your computer) and flash it. Few minutes and it will be done and verified.

Put the SD card into the RPi, you’re ready to rock!

Step 3: Ssh-ing into your RPi

After you’ve inserted the freshly backed SD card into your RPi connect the ethernet cable between the RPi and your router. Turn the RPi on by connecting the micro USB cable to the electricity or to your computer.

Wait 2–3 minutes, then open your terminal and type:

ssh pi@raspberrypi.local
(password raspberry)

You should be in! That’s badass like the Administrator in the movie Hackers.

You are now connected to the RPi via the network. The only problem is that you still need to keep the RPi connected to the network through the ethernet cable. But let’s address that.

Step 4: Going wireless

Attach the USB dongle to your Raspberry Pi. Then, while connected to the RPi with ssh, open the wireless configuration file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

and add at the end of the file the informations about your wifi network:

network={
ssid="your-network-ssid-name"
psk="your-network-password"
}

Save and exit the editor. Remove the ethernet cable and then reboot with:

sudo reboot

Now in about 30 seconds your RPi should be up an running. If you try again to ssh into the RPi should just be able to connect as before. But on wifi!!

Step 5: Final configurations

I suggest you to secure your login with a rsa key authentication and enabling it only the port 22. Here a guide.

A classic system update is also suggested:

sudo apt-get update
sudo apt-get upgrade

The-wise-guy-last-step: Backup your RPi

It’s very easy to burn an SD card by writing to it too many times. Or irreversibly fuckup your configuration by doing what sudoer should not do. Cloning your SD card, as an image that you can flash on a new card when you need it, is the perfect backup strategy. Here you find how.

You are now ready to install Swift on your hot-n-sexy Raspberry Pi.

To get my latest Swift misadventures subscribe to the publication. Cheers.

--

--