Introduction: Prep Your Raspberry Pi for Anything!

Picture of Prep Your Raspberry Pi for Anything!

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

Picture of 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

Picture of 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:

  1. insert your microSD card in your card reader
  2. start the SD Memory Card Formatter
  3. 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

Picture of 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:

  1. choose an image file to write to the card (that's the Raspbian you just extracted from its archive);
  2. choose a device on which to flash the operating system;
  3. 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

SSH connectivity or Secure Shell is a way to establish a secure connection to a computer over your network. It is currently disabled by default in Raspbian - so we're going to enable it!

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

Picture of 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?

Comments

NormanE (author)2017-11-21

Why do you need to format the card first? doesn't the card come already formatted? You are going to overwrite it with the image which then leaves only part of it as is but most of that image will be ext4. Then when you expand it to fill all the SD card all of that will be ext4.

Mind you I use Linux anyway and use dd to install the image.

jocomakerspace (author)NormanE2017-12-15

Hello NormanE,

Since we don't know where everyone reading this tutorial is coming from (Mac? PC? Linux?), formatting the microSD card helps establish a baseline for the rest of the Instructable and make sure everyone gets the same results, as much as possible.

It's also (absolutely) something we do out of habit.

Thanks for your comment!

tincho1962 (author)2017-11-20

1.es algo muy util ya tener la R Pi ya precargada para cualquier proyecto!

peabody1929 (author)2017-11-15

How about a tutorial to share a laptop's WIFI with the Rasp Pi? Plug an ethernet cable into the Pi and the notebook. Connect the notebook to the Internet using WIFI. Bridge or share this connection to the headless Pi.

Hi peabody1929! It's a great suggestion - we will add it to the list of follow-up setups in the last step of the Instructable.

Have a good day!

About This Instructable

1,495views

42favorites

License:

More by jocomakerspace:Connect Your Headless Pi to a Library WiFi NetworkPrep Your Raspberry Pi for Anything!PCB + CNC = OMG
Add instructable to: