Getting started with Raspberry Pi

In this article I’ll show you how to get started with Raspberry Pi. At it’s simplest, Raspberry Pi is simply a low-cost computer used by millions of people globally for programming and/or low-end computing. The Pi can be used simply as a basic, low-cost desktop PC with full browser functionality, or in an array of multiple units to perform high-end computing.

Once you have mastered the basics, you’ll be able to move on to more “complicated” projects with the Pi. As an example, I use a couple of Pi units to run the web server hosting this blog and to run my home automation. Honestly, I mean complicated in the loosest sense because there are people doing some crazy things with Pis. We’ll assume you’re starting from scratch (like I did) and know absolutely nothing about the Raspberry Pi.

Raspberry Pi Logo

Contents

What is Raspberry Pi?

Hardware Requirements

Headless Install

Boot From USB

What is Raspberry Pi?

If you want to know the full story behind the Raspberry Pi, head over to Raspberrypi.org. Surprisingly, Raspberry Pi is a charity-based foundation with the sole purpose of improving computing access and knowledge. Specifically, the foundation targets young people to teach them the basics of computing, programming, and digital skills. Since the premise of the foundation is to provide low-cost computers for learning, their products are remarkably inexpensive in comparison to large brand names such as Microsoft, Dell, or Apple.

Because the foundation is a charity, and because the goal is for low-cost computing, the operating system is Linux-based. If you haven’t heard of Linux, its an open-source, free to us operating system. There are several variants of Linux, including Raspbian. You can install other OS’s (i.e. Ubuntu), the Raspbian OS is specifically designed to run on all Pi models.

Comparison of Raspberry Pi models

Pi ZeroPi Zero WPi 1 A+Pi 1 B+Pi 2 BPi 3 BPi 3 B+Pi 3 A+Pi 4 B
RAM512MB512MB512MB512MB1GB1GB1GB512MB2-8GB
CPUARMv6Z 32-bitARMv6 32-bitARMv6 32-bitARMv6Z 32-bit ARMv7 32-bit Quad 900MHzARMv8 64-bit Quad 1.2GHzARMv8 64-bit Quad 1.4GHzARMv8 64-bit Quad 1.4GHzARMv8 64-bit Quad 1.5GHz
USB32
USB 21444412
mUSB11
HDMI11111
Mini HDMI112
WifiXXXXX
LANXXXXX
BLEXXX
Starting Price$5$10$25$35$35$35$35$25$35

Linux versus Windows

Since the Pi runs on a Linux-based OS, it’s only fitting I touch on some differences compared to Windows. I can’t speak to Mac, since I don’t use the Apple OS. If you are used to a pretty user interface (or GUI), get ready for a small shock. You can use the Linux desktop, but most of what we’re going to do initially is going to run from the command line (or shell).

Linux logo

Probably the most pronounced difference I noticed versus Windows is related to user permissions. In Windows, as long as you are logged in as an administrator you can manipulate files without having to worry about approving each change. With Linux, most changes to system files require root user access. In Windows you “run as administrator” or access with administrator privileges. Generally, in Linux if you don’t have permission as a root user to change or add a file, you can’t do it. With a little practice it gets easier to wrap your head around permission’s structure, eventually.

Basic Linux Operations

Before we really dive in, let’s look at some basic operations. I started without having any clue as to what many of the shell arguments I was typing actually meant. For the most part, I had to figure it out as I went. However, I you want to get a detailed introduction to the command line, I recommend this book by William Shotts. Since this is going to be more focused on getting a Pi up and running, I’ll stick with the basics here.

CommandActionExample
sudoRun command as a root usersudo mkdir
cdChange directorycd /usr/bin
mkdirCreate directorymkdir /usr/bin/localfile
cpCopy file/directory cp /usr/bin/localfile /var/www/html/localfile
mvMove file/directorymv /usr/bin/localfile /var/www/html/
rmRemove file/directoryrm /usr/bin/localfile
rm -rRemove directory and all subfoldersrm -r /usr/bin/
rm -rfForce remove directory and all subfolders *beast of a command–no takesie backsies*rm -rf /usr/bin/

Getting started with Raspberry Pi-Hardware Requirements

Now that the basics are out of the way, here are the items required to get started:

  • A Raspberry Pi (model dependent on the application, but generally go with the latest)
  • Micro SD card
  • Micro SD card reader
Raspberry Pi 4

Optional items (but highly recommended):

  • For all Pi models I recommend a case to protect the board from accidental damage
  • The Pi 4 B can get a little warm so a small fan is a good idea if it will be in a case or enclosed area
  • A PoE splitter (if you have a POE switch) so you don’t have to have a separate power cable
  • An external USB SSD drive to use instead of a microSD card

If you buy a kit you’ll often end up with everything you need. Both of my Pi boards were purchased through CanaKit and included a case, fan, heat sinks, microSD card, power supply, and mini HDMI cable.

Getting started with Raspberry Pi-Initial Set Up

We’re going to do what is called a “headless” install of our Raspberry Pi. Simply put, a headless install doesn’t have the Pi directly connected to a computer monitor or peripherals. In this install we’re going to set up the Pi as if its just going to only be accessed remotely, and we’ll get as much as possible set up prior to booting the Pi for the first time. If you want to do the traditional method and play with it first you can follow the instructions that come with the kit before coming back to this guide. Of note, we’re going to be using a wired LAN connection to set this up initially.

Setting up the OS

First up, set up your Raspberry Pi. My recommendation is to start with a fresh install without any of the default packages. If you buy the CanaKit version of the Pi, it will come with an SD card that already has Noobs installed (that’s the installer for the basic Pi OS). You’re going to wipe the card and start fresh. To get started, insert the microSD card into the reader and plug it in to an available USB port on a desktop or laptop.

  1. If using Windows to complete the initial setup, download the Raspberry Pi Imager utility.
  2. Once downloaded and installed, you will format the micro SD card. Choose “Choose OS” and select “Erase” to format the card as FAT32. Select the the micro SD card and hit “Write”.
  3. Once the formatting completes, you’ll now need to choose the actual OS we will want to install. Repeat the above step, but instead of formatting, we’re going to go ahead and install an OS. The recommendation is Raspbian, but you can choose from several.

Enable SSH for a “headless” install (skip if connected to a monitor)

To be honest, if you search the web you’ll find that most places will tell you that it is not possible to do a headless install prior to booting the first time. While that is somewhat true, with a little legwork you can enable SSH so that you can access the command line remotely on first boot. This saves you a little bit of work, and a lot of running (especially if your pi is down a flight of stairs like mine). Likewise, in most cases once you set up the Pi, its never going to moved again depending on its function.

The process for this is actually very simple. Before you remove the microSD card from the desktop navigate to it and open it in file explorer. Using notepad, place an empty text file named ssh into the root folder. When you save the text file, rename it (select and hit F2) to “ssh” by deleting the .txt file extension. At this point, you’ve told the OS to enable SSH on boot.

One last step: make sure you have a SSH client downloaded on the PC you will be using to access the Pi. The most common client is PuTTy, which you can download from the Microsoft app store.

Start up and log in

Go ahead and plug the Pi in. While it boots, head back to your PC and start PuTTy (or your SSH client of choice). A quick note here regarding Linux. As already mentioned Linux is very picky about permissions; it is equally as picky with spelling, character spacing, and lowercase/uppercase. Always double-check your command entry before hitting the Enter key; once a command fires you may not be able to take it back.

  • raspberry pi login
  • raspberry pi raspi-config

After giving it a few minutes to start, log in to your Pi with PuTTy. To do so, type the IP address in of the Pi in as the host name, leaving the port at 22. Hit “Open” to start the session. On the first boot, the default username is “pi” with password “raspberry”. Notably, the password is hidden when you type it. We’ll change the default password later. If your not doing a headless install the initial username and password remains the same in the desktop.

Configure the SD card and VNC Viewer

The first thing we need to do is get everything set up for an easier viewer. Generally, you can do everything from the SSH session, but I prefer to use VNC viewer and the Linux desktop since it has a little more familiar feel to Windows. Let’s get started and type sudo raspi-config to open the config utility:

  1. First we need to tell the OS to use the entire SD card. By default the imager only uses part of the SD card (2GB). The same is true if you later go on and copy the SD card over to a SSD and boot from USB (which I highly recommend doing, since SD cards can be a bit flakey). Arrow down to Advanced Options, hit enter, and choose option “A1 Expand Filesystem”.
  2. Next, we want to change our display resolution, otherwise with VNC viewer you will likely encounter a blank screen. From the top menu, choose Display Options, Resolution, and your desktop resolution. Best bet is to go with 1920×1080.
  3. Last, we want to configure it to be able to use VNC Viewer. So from the top menu choose Interface Options, move to “P3 VNC”, and enable VNC.
  4. Tab over to “Finish” and reboot if prompted. If not, in the command line type sudo reboot

Download VNC Viewer

Your next task is to download VNC Viewer. This is a remote desktop client that will let you interact with your Pi in a more familiar interface. Once downloaded, start it and go to File>New Connection. Type in the IP address or hostname of your Pi and give it a friendly name (optional). Hit OK and an authentication screen will be shown. Since we left the default password the same, type in “raspberry” for the password and hit OK to open the desktop. As the default user you will need to configure a new password; make it a strong password that is not easy to guess. Go ahead and complete these, including the system update. Once it is complete and your Pi has rebooted, come back to the desktop, using the new password to log in through VNC.

Pi VNC Viewer

Optional-Use a SSD to boot from USB

MicroSD cards are a bit flakey. Many of the community forums I stalk have stories about their Pi suddenly kicking the bucket, and most of the time it is traced back to a bad microSD card. Fortunately, their is an easy way around this. Raspbian can be instructed to boot from USB, and with that we can boot from a SSD. I picked up a cheap 250GB USB 3.0 SSD from Amazon for $35.

  1. Make sure the Pi is up to date by running sudo apt-get update followed by sudo apt-get upgrade from the command line.
  2. Type sudo raspi-config to enter the configuration utility and select “Advanced Options”.
  3. Arrow down to “A7 Bootloader Version” and make sure that the latest version is selected.
  4. Make sure using another PC the SSD is formatted to FAT32 before plugging it in to the Pi.
  5. Next, from the Raspbian applications menu, click “Accessories” and then SD Card Copier.
  6. Make sure the Copy To Device matches your SSD and check the New Partition UUIDs box before hitting Start
  7. Finally, go back to the command line and raspi-config. Under Advanced Options select A6 Boot Order and then B1 Boot from USB if SD Card fails.
  8. Exit out of the configuration utility and type sudo shutdown. Once powered down unplug the Pi.
  9. Remove the microSD card from the Pi; store it in a safe place. Plug back in the Pi and allow it to reboot.

The last step is to go back and expand the filesystem to use the full SSD (under Raspi-config, advanced options, expand filesystem).

Wrapping up

And that’s it. You have set up a Raspberry Pi and can access it remotely. Getting started with Raspberry Pi is a rabbit hole, and can result in long hours spent toying around with the thousands of things it can do. See my article on setting up Node-RED for an example of how you can run home automation off a Pi, and stay tuned to see how to host a blog using a Raspberry Pi.

Raspberry Pi Logo

1 thought on “Getting started with Raspberry Pi

Comments are closed.

%d bloggers like this: