Here at the MakerSpace, we love the Raspberry Pi! And whether we're going to use it for programming, hosting a webserver or testing the latest Raspbian distribution, we always prep it the same way. It's a great starting point to play with the Raspberry Pi, build a basic Raspberry Pi toolbox, and we thought it's a great way to help you get started!
In this tutorial, we will show you:
- how to prep a microSD card
- install Raspbian for the Raspberry Pi computers
- connect to your Raspberry Pi with a serial cable and Putty
Next stop: the things we'll need!
Step 1: The Things We'll Need
To prep your Raspberry Pi, we will need:
- A Raspberry Pi computer
- A microSD card and a microSD card adapter
- A micro-USB cable
- A 5V charger
- A USB to TTL serial cable (we used one from Adafruit)
When you have everything, let's get started by preparing your microSD card!
Step 2: Prep Your Raspberry Pi Card
First, we'll format your microSD card using the SD Memory Card Formatter. You can download this official tool from the SD association at https://www.sdcard.org/downloads/formatter_4/ - the download links will be further down the page.
Once you have downloaded and installed the SD Memory Card Formatter:
- insert your microSD card in your card reader
- start the SD Memory Card Formatter
- format your microSD card
Be careful when you pick which drive to format! if you have important flash drives plugged into your computer before formatting your microSD card, make sure you know which is which. Many people (including us) have formatted flash drives with important files for lack of attention!
After formatting, it's time to flash the Raspbian operating system to your microSD card!
Step 3: Flashing an Operating System on Your MicroSD Card
The Raspbian operating system is officially supported by the Raspberry Pi Foundthwation. You can download the latest version of this system at https://www.raspberrypi.org/downloads/.
Raspbian comes as a compressed file archive: after downloading and extracting it, you'll need to flash the system to the microSD card we formatted earlier. My go-to software for that is Win32 Disk Imager: you can download it at https://sourceforge.net/projects/win32diskimager/.
Again, be careful that you are flashing the operating system to the correct drive, and:
- choose an image file to write to the card (that's the Raspbian you just extracted from its archive);
- choose a device on which to flash the operating system;
- click Write and wait a few minutes for the program to write the system to the card.
After it's done, don't eject your microSD card - we're going to tweak a few things to access the system over a serial connection and SSH.
Step 4: Enabling the Serial Connection
After the SD card image has been written to your microSD card, don't eject it!
Using the file explorer, browse to the /boot/ directory on your card and
open the config.txt file there - preferably with software like Notepad++ to avoid altering the formatting of the file.
Add the following at the end of the file:
#enabling serial cable connection enable_uart=1
Save and exit, and you're done! Now to enable SSH connections...
Step 5: Enabling an SSH Connection
Again, open your editing software and create an empty file called ssh (no need for a file extension). Move the file to the /boot/ directory on the microSD card.
That's it! Eject the card, connect a keyboard, mouse and charger and go through your Pi's first boot. Now is a good time to use the raspi-config tool to:
- change the default password
- set up the date and time
expand the file system to the whole microSD card
You can find a detailed explanation of what raspi-config does and how to use it on the Rasberry Pi website.
Once you're all done, meet us at the next step to download a command line web client!
Step 6: Connecting to Your Pi With the Serial Cable
Remember when we set up a Serial Cable connection earlier? This is where it comes in handy. Lugging a computer screen, mouse and keyboard around is not always fun: that's why you can use a serial cable and a laptop when you're at the library instead!
- First, download the drivers for your serial cable (if like me you're using an Adafruit USB to TTL Serial cable, you can find all the information you need on the product page);
- next, connect your serial cable to your Raspberry Pi's GPIO pins like like depicted in the picture above;
- then, connect your serial cable to your computer (and download the corresponding drivers, if you haven't done it already).
- Finally, download and open Putty, and click on Serial on the main screen - you will find the COM number of your cable in the Devices menu if you're using Windows.
Congratulations, you are ready to hit Connect and press Enter on your keyboard to start communicating with your Pi. Log in using the credentials you defined during setup and you should be good to go: if you need more detailed instructions, you can find a guide on how to connect over serial on Adafruit.
Step 7: What Next?
Now that your Raspberry Pi computer is ready, we can build up on this tutorial!