In order to get started with Johnny-Five and the Raspberry Pi, we will need to set up the Raspbian operating system by burning it to a microSD card. Then, we'll need to edit some files on the SD card in order for the Raspberry Pi to boot with Wi-Fi and the ability to SSH in. Lastly, we'll need to boot up the Raspberry Pi and get some settings in place before finally installing Node.js, Johnny-Five, and Raspi-IO.
The following steps will show you how to download Raspbian Lite:
- The first step is downloading the Raspbian Lite image so we can burn it to our microSD card. The best place to get the image from is https://www.raspberrypi.org/downloads/raspbian/, as shown in the following screenshot:
A screenshot of the Raspbian download page, with both Full and Lite download links
- Select
RASPBIAN STRETCH LITE
(or whichever version is the current one), which will replace the wordSTRETCH
. Give yourself some time for this step to complete; although Raspbian Lite is much smaller than Raspbian Full, it is still several hundred megabytes, and can take time to download!
Luckily, the tools for burning OS images to SD cards have evolved arcane command-line tools that can overwrite your computer's hard drive as easily as it can the SD card. My current favorite is called Etcher, and it can be downloaded for any platform at https://etcher.io/, as shown in the following steps:
- The free version is more than enough for our needs, so download and install it as you download Raspbian Lite.
- Once they are both downloaded, you'll want to place the micro SD card in your computer, either by placing it into a full-sized SD adapter and then into a slot on your computer, or by using a USB-to-micro-SD adapter. Whichever you use, make sure your computer can see the volume as a drive before continuing. Then, boot up Etcher. The following screenshot shows Etcher running on a Mac:
A screenshot of the Etcher program running on a Mac
- Once you see a window similar to the preceding screenshot, you'll need to select the Raspbian Lite image you just downloaded. You don't even need to unzip the
.zip
file—Etcher can handle that outright! Once you've selected the image, Etcher should select your micro SD card drive, so long as your machine can see it! Once you've ensured that the image and micro SD card drive are properly selected, hitFlash
!
to begin the process.
Note
Sometimes, with larger micro SD cards, you'll get a warning from Etcher about the drive being very large (this happens to me when I use 64 GB cards). This is to prevent you from overwriting your computer's hard drive. You can bypass the warning by going through a confirmation window—just be absolutely sure that your micro SD card drive is selected first!
A few minutes will pass as Etcher burns the image to your micro SD card, then verifies that it is present on the card. Once this is done, remove and reinsert the micro SD card so that your computer recognizes it as a drive again; the drive should be namedboot
. We're not quite done editing the image files yet, so Etcher's polite attempt to eject the micro SD card drive needs to be ignored.
We need to edit and create some files on our Raspberry Pi's image in order to be able to access it with SSH when we turn on the Raspberry Pi. First, we'll set up the Wi-Fi using the following steps:
Note
If you're using an Ethernet cable and port to connect the Raspberry Pi to the internet, you can skip this step. If this doesn't get the Wi-Fi to work, you'll want to look at the information box under the section Booting up the Pi for troubleshooting steps and an alternative (if clunkier) way to set this up.
- In order to set up the Wi-Fi, you'll want to create a file in the root of the micro SD card drive called
wpa_supplicant.conf
that contains the following text:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="yourNetworkSSID" psk="yourNetworkPasswd" }
- Replace
yourNetworkSSID
with the SSID of the Wi-Fi network you wish to connect to, and then replaceyourNetworkPasswd
with that Wi-Fi's network password.
Note
The Raspberry Pi's Wi-Fi chip can only connect to 2.4 GHz networks at the time of writing, so you need to make sure that you input a network that operates on that bandwidth or your Raspberry Pi will not be able to connect!
- After you've set up the Wi-Fi network, you'll want to tell the Raspberry Pi to allow you to SSH into it. To do this, you'll want to create a file called
ssh
in the sameroot
folder as thewpa_supplicant.conf
file. Make sure that thessh
file is empty and has no extension. When you're all done, theroot
directory of the micro SD card drive will look similar to the following screenshot:
A list of files on the micro SD drive, once I've made my edits
Once this is all done, fully eject the microSD drive, take the microSD card and insert it into the Raspberry Pi. We're now ready to boot up the Raspberry Pi and start installing software.
Once the micro SD card is inserted, plug your power source into your Raspberry Pi. A red and green LED should light up. The red LED should be solid—this is the power indicator. The green light will flicker on and off—this is the LED that indicates activity. The Raspberry Pi should take a maximum of a minute or so to boot up once you've plugged it in. Next, we'll SSH in.
If you're on a Mac or Linux machine, you'll open up a Terminal and type the following:
ssh [email protected]
If you're successful, you'll see a question appear, asking about the authenticity of the host. Respond by typing yes
and hitting Enter. You'll then be asked for a password, which is raspberry
, as shown in the following screenshot:
Successful SSH into a Raspberry Pi from a Mac Terminal
Once you've entered the password, you should see the following:
Successful login to a Raspberry Pi via SSH from a Mac
In order to SSH from a Windows machine, you'll need to use a program called PuTTY. You can get it on https://putty.org/. But first, you'll want your Raspberry Pi's IP address. You'll need a monitor, an HDMI cable, and a USB keyboard. Once you have these, go through the following steps:
- Plug the monitor, HDMI cable, and USB keyboard into the Raspberry Pi before booting it up. Then plug in the power supply.
- When it prompts you for a username, type
pi
. When it asks for a password, enterraspberry
. Once you are logged in, typeifconfig
. You should see a lot of information appear. - Look for the
wlan0
section and theinet
address under that heading. For the following output, the IP is192.168.1.106
, as shown in the following screenshot. Write this IP down. Then, you can unplug the display and the keyboard—you won't need them again:
Getting the IP address from the Terminal
The PuTTY configuration window
- Type the IP address that you obtained into the field labeled
Host Name (or IP address)
and click theOpen
button. You'll be asked about the authenticity of the host (only the first time you connect). SelectYes
. Then enterPi
as the username andraspberry
as the password when prompted. Once that's done, you should see the following:
Successful login to the Raspberry Pi with PuTTY
Now that everyone's logged in, let's set up our Raspberry Pi for our projects!