Orange Unit: A Person-Centered Launch
4C: Getting Started with the Raspberry Pi
Choose Your Own Adventure
There are several ways to interface with the Raspberry Pi computer and operating system. Before we can configure your Raspberry Pi microcomputer, we must determine the best way forward, based on the tools available to you. Take a minute to answer the following questions, which will lead you to the right exercise.
Option 1: Do you have a wired or wireless USB keyboard and mouse? Do you have a television or computer monitor with an available HDMI port and HDMI cable?
- If yes: Follow the instructions in the Quickstart Guide to configure your Raspberry Pi.
Option 2: Do you have an SD card reader? A card reader may be built-in on your laptop. They are also available as stand-alone products.
- If yes: Follow the instructions in the Headless Guide to configure your Raspberry Pi.
Other options:
- If you said “yes” to a keyboard, mouse, and monitor, but no to the HDMI port: You may be able to purchase a cable or an adapter, as needed, to pursue the Quickstart Guide. Or, you may purchase an SD card reader in order to follow the Headless Guide.
- As you proceed through the rest of the textbook, you may find it helpful to come back and choose a different option as your skills, interests, and needs change.
Option 1: Raspberry Pi Quickstart Using a Monitor, Keyboard, and Mouse
This activity uses a , which displays on the monitor.[1] Later, we will instead use a . Many of our everyday microcomputers, from those in our car to the routers connecting an Internet Service Provider to the in our buildings, don’t use a monitor. We then use a wired or wireless connection to configure, troubleshoot, and make adjustments to the computer.
But for now, if you have an HDMI monitor, USB keyboard, and USB mouse available, this is the easiest way to get your feet wet with the Raspberry Pi.
You will need:
- A television or computer monitor with HDMI port (and cable)
- A USB keyboard and mouse (wired or wireless is fine)
To do this, you’ll need to install an operating system (OS). The 8 GB MicroSD card with NOOBS comes with the toolkit. NOOBS stands for New Out Of the Box Software. The MicroSD card that comes with the Raspberry Pi Starter Kit includes both the Raspberry Pi OS, and the LibreELEC ‘Just enough OS’ Linux. For our purposes, Raspberry Pi OS is a solid choice, and the one we’ll use.
Connecting and Starting Your Pi
Take a minute to watch the following video, then go through the steps as follows:
Steps
- Begin by plugging your keyboard and mouse into the USB ports on the Raspberry Pi.
- Next, insert your Micro SD card into the SD card slot on the Raspberry Pi. It will only fit one way.
- Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI 1, DVI, etc.).
- Connect your HDMI cable from your Raspberry Pi to your monitor or TV.
- When you have plugged all the cables and SD card in correctly, connect one end of the micro USB power supply to a 120/240 volt power source, and the other to the Raspberry Pi. This action will turn on and boot your Raspberry Pi. You should see:
- A small red LED come on in the lower left side of the Raspberry Pi board, right next to the power port, indicating it properly has power.
- A small green LED should blink whenever there are data transfers happening between the MicroSD card and the circuitry on the Raspberry Pi board.
- Your monitor should begin displaying visuals that it is booting up, followed by a Graphical User Interface (GUI) display window as seen in the video below.
- Use the Raspberry symbol to open the applications menu and explore the range of applications installed by default on the full Raspberry Pi OS included in the Raspberry Pi starter kit.
- Connect your Raspberry Pi to your local wired or WiFi Ethernet.
Initial Configuration
When you start your Raspberry Pi for the first time, it is important that you configure the system for your context. This includes setting up your password, country, language and timezone. In addition, for exercises in this book, this includes enabling a range of special interfaces.
Take 10 minutes to watch the following video. This is shortened slightly from the actual time you will need to execute the steps and wait on computer processing. Then proceed as follows:
Steps
- In the upper left of the GUI of Raspberry Pi OS, click on the image of a raspberry.
- You’ll see menus for Programming, Office, Internet, Games, Accessories, and Help. Feel encouraged to take a moment to explore and see what’s been installed.
- Click Preferences, then Raspberry Pi Configuration.
- Within the “System” tab at the top of the Raspberry Pi Configuration window that opens:
- Change the password from the default “raspberry” to something of your choosing that will be more secure.
- For ongoing monitoring and troubleshooting at computer boot moving forward, disable the Splash screen. This will enable a more verbose textual boot of the Raspberry Pi OS.
- Next, click the “Localisation” tab to configure the system for your locale. Configure locale, timezone, keyboard, and WiFi to the location in which you are working on the activities in the book, and to your preferred language and keyboard system configurations.
- To enable needed and potentially needed interfaces for the activities in this book, next choose “Interfaces” at the top of the window. Check each of the following if they are not enabled already:
- SSH: This enables remote command line access through a secure shell. A secure password should be established for all users first.
- VNC: This enables the RealVNC virtual network computing server on the Raspberry Pi, allowing your laptop to have remote GUI access over wired or wireless Ethernet using an installed RealVNC viewer on the laptop.
- SPI: This enables data sharing using the Serial Peripheral Interface, a widely used synchronous serial communication specification for short-distance communication, primarily with embedded systems.
- I2C: Pronounced I-squared-C, this is another synchronous serial communication specification for short-distance communication. I2C is packet switched, allowing communication between multiple integrated circuits with microcontrollers and computers.
- Serial: This enables asynchronous console shell and messages on a serial connection. This is needed to provide TTL to USB UART Serial Communications between the Raspberry Pi and your laptop without the use of a keyboard, mouse, and monitor connection to the Raspberry Pi.
Key Takeaways
In this exercise, we launched the Raspberry Pi microcomputer with the Raspberry Pi OS for the first time. For anyone who has used a keyboard, mouse, and monitor to start a brand new computer for the first time — whether they were separate from the case of the computer or an all-in-one like a laptop — there may be many similarities as well as some differences. These similarities and differences, though, aren’t just between the Raspberry Pi and any other computer you’ve ever used. Rather, brands and generations of computers each have been shaped by a wide range of social, cultural, and economic factors that have influenced the look, feel, and functionality of a given computer within a given context. To this extent, Raspberry Pi is just like other computers in use today.
- Compare and contrast your experiences with the different computers you have used. There are three primary types of operating systems used today:
- Microsoft Windows-based operating systems, developed by Microsoft in the early 1980s.
- Apple Mac-based operating systems, a Unix-based system released at the end of the century to replace the “classic” Mac OS introduced in 1984.
- Linux-based operating systems, including:
- Android, a mobile operating system developed by Google, first commercially used in 2007.
- Chrome OS, an operating system that uses the Google Chrome web browser as its principal user interface and first used commercially in 2011.
- Ubuntu, Mint, Fedora, and other popular Linux distributions used on laptop, desktop, and server computers around the world.
- Raspberry Pi OS Linux, the first choice in most cases for the Raspberry Pi computer.
- If possible, compare and contrast any brand new computers you’ve turned on for the very first time.
- As you compare and contrast operating systems, consider how the following components vary:
- The graphical user interface
- The setup and configuration files
- The included everyday applications
Option 2: Configure the Raspberry Pi “Headless”
We are most accustomed to interacting with a computer through its , which displays on the monitor. In lieu of this, we can connect to and control the Raspberry Pi using tools on our laptop, including the . Connecting your Raspberry Pi to your laptop in this way is known as a “headless” connection.
Communication between devices takes many shapes and forms, using a range of protocols. For this exercise we will make use of UART (Universal Asynchronous Receive Transmit) interfaces. UART is actually a microprocessor with a package of integrated circuits on a printed circuit board, along with program logic, and is used to attach serial devices to a computer. This allows the computer and attached devices to “talk” and exchange data. USB (Universal Serial Bus) TTL (Transistor Transistor Logic) serial cables provide connections between USB and serial UART devices.
You will need:
- Your laptop (Must be Windows 10 or Mac 10.12 or newer)
- A microSD card reader (Note: Some laptops have a built-in card reader)
- From your Raspberry Pi toolkit:
- Three pin-to-pin wires
- USB to TTL cable
- Power cable for Raspberry Pi
- Raspberry Pi, connected to Cobbler and breadboard
- MicroSD card
It’s worth noting that in this process we may be doing something which the system administrator or others have decided we cannot do, based on other, unknown priorities. But know that what we are trying to accomplish is perfectly safe to do. The devices you use for this book may have been configured in a way to prevent you from moving forward in this process. Take these challenges as a not-yet moment. We should not assume that we are doing something silly or wrong because the process is not straightforward or does not work immediately the way we expect it to.
Configure files on microSD card
Take a minute to watch the following video for your laptop’s operating system, then go through the steps as follows:
Steps
- Insert the microSD card into the card reader on or connected to your laptop. Many windows may open and you may get a pop-up which says, “You need to format the disk in drive H: before you can use it.” You can ignore this prompt and select “Cancel.”
- Navigate within the to the BOOT drive.
- Within the BOOT drive, open the config.txt file. Be sure to open it with a text editor, not a word processor. This file contains a range of configuration settings used each time the operating system is loaded on computer boot up.
- If you are unable to open or edit files through the File Manager, you can work through the command line interface.
- Resources on using the terminal are available at the end of the book.
- A standard used in Linux is for the symbol called pound or hash to indicate a comment. In this case, there are both comments and also options that have a pound symbol in front of them. The presence of a comment indicates that a line of code in a file is “commented out” or not currently activated. By removing the the pound sign, this line of code is thus activated.
- Near the bottom, there are three optional hardware interfaces that are currently commented out.
- Uncomment the parameter:
dtparam=i2c_arm=on
We’ll be using this to bring the Raspberry Pi and Circuit Playground Express together later in the book. - At the bottom of the file, create a new line with the words
enable_uart=1
This will enable the Universal Asynchronous Receive and Transmit serial console on the Raspberry Pi moving forward. - Save and exit this file.
- On the Boot drive, create a new file with the type “text document.” Name this file
ssh
. Make sure the file does NOT end with a .txt or .rtf file extension. You will get a warning that this may make the file unusable. Click “Yes” to continue making the change. This empty file will tell the Raspberry Pi OS to enable the secure shell remote login for use moving forward. We’ll dig into what this means very soon. - With these steps done, right click on the RECOVERY drive and select EJECT. You’ll get a notice that you can remove it from your laptop. It’s now ready to use with your Raspberry Pi when you need to use the USB to TTL cable to work with the Raspberry Pi using a serial console on your laptop.
- Note that when files are written, it’s a two-step process, where the file is written to temporary storage, and then transferred to the permanent storage. When you choose the “Eject” option rather than immediately removing the microSD card (or USB drive or any other form of removable storage), the computer checks whether both steps have been completed. By hitting Eject in this way, you can be certain that your file was written.
Connect The Hardware Components
Steps
- From your toolkit, select three pin-to-pin wires in white, black, and green.[2]
- Using the diagram for guidance, connect the wires to the breadboard accordingly:
- Ground (black) wire to breadboard, aligned with GND row on the Cobbler.
- TXD (white) wire to breadboard, aligned with TXD on the Cobbler. This means transmit.
- RXD (green) wire to breadboard, aligned with RXD on the Cobbler. This means receive.
- Select a UART cable from your toolkit. This has a USB port on one end and female pins in red, white, black, and green on the other end.
- Connect each of the cables from the breadboard to the corresponding input on the UART cable. Matching each of these is very important: Ground to Ground (green), TXD to TXD (white), and RXD to RXD (green). Note that the red port is for power. Leave this disconnected as it could overload and damage the Raspberry Pi.
- Connect the USB side of the cable to your laptop.
- Insert NOOBS microSD card (in which config.txt has been edited to enable UART) into Raspberry Pi microSD card port.
- Connect the microUSB power to the Raspberry Pi and to a wall outlet.
Set up Laptop as USB Console
At this stage, the instructions differ for Windows and Mac users. If your computer runs the Mac operating system, jump to your instructions below. If your computer has the Windows operating system, proceed here:
Windows Steps
- Usually, Windows will automatically install the CP2104 driver when you connect your breadboard to the laptop. But just in case it doesn’t, visit the SiLabs website to download and install the required driver manually.
- Next, you will need to download and install PuTTY. PuTTY is free and open source software which supports several network protocols for connecting two devices, such as secure shell (SSH) and secure copy (SCP), both of which we will explore later.
- From the list of downloads select the binary called just putty.exe from the section For Windows on Intel x86. This will prompt you to save the file. Save it onto the Desktop for now. Note that this actually saves the Program itself not an installer. Simply double click putty.exe to run PuTTY!
- Before you start PuTTY, you need to know which com port is being used for the cable. You can find this by looking in the Ports section of the Windows Device Manager.
- The Device Manager is accessible from the Control Panel under System. Within the Device Manager, scroll down to “Ports” and expand to show the available ports. The com port will be in parentheses, for example (COM3) or (COM7). It will often say “SiLabs” or “Prolific” or similar next to it.
- Open PuTTY. You will see a connection window.
- Select a connection type of “Serial” from the radio buttons.
- Set the speed to 115200 and the serial line to the com port shown in your Device Manager.
- Finally click “Open” to connect. Press ENTER to start communications. Wait for the screen to load, as it may take a minute.
Mac OS Steps
- Go to the Adafruit tutorial and download the required driver.
- Open a terminal window and type in the command:
ls /dev/cu.*
- This command will list all of the available serial ports.
You should see something like this:/dev/cu.Bluetooth device
.
You’re looking for something like:/dev/cu.usbserial-NNNN
or/dev/cu.SLAB_USBtoUART
or/dev/cu.usbmodem
. - Once you’ve identified the name, you can then run one of these corresponding screen commands. This command detaches a terminal window, creating a separate window within which you can access and control the Raspberry Pi. Your device will have a slightly different name than the examples here. The last number, 115200, is the baud rate. This number remains the same.
screen /dev/cu.PL2303-00001004 115200
screen /dev/cu.SLAB_USBtoUART 115200
screen /dev/cu.usbserial-A4001nCf 115200
- One way to quickly figure out the name of your device is start typing
screen /dev/cu
and then press the TAB key to auto-complete the command. Before pressing enter, add 115200 to the end. - Hit enter again. Wait for the screen to load, as it may take a minute.
Initial Configuration
Steps
- If prompted, log in to Raspberry Pi OS with username “pi” and password “raspberry”, the default for new installations. Now you can use the command line on your laptop to control your Raspberry Pi!
- In the command line, enter:
sudo raspi-config
- Using the arrow keys and enter key, navigate through the configuration menu.
- Select 1: Change User Password. Change the password from the default “raspberry” to something of your choosing that will be more secure.
- Select 2: Network Options. Select N2 WiFi. Set the SSID (name) of the network, and the passphrase for the network. Or, optionally, connect the Raspberry Pi to a router using a wired Ethernet cable.
- Select Finish to close the Raspberry Pi configuration tool.
An introduction to the terminal window can be found at the end notes of the book: Using the Unix Command Line.
Key Takeaways
In this exercise, we launched the Raspberry Pi microcomputer with the Raspberry Pi OS for the first time. For anyone who has used a keyboard, mouse, and monitor to start a brand new computer for the first time — whether they were separate from the case of the computer or an all-in-one like a laptop — there may be many similarities as well as some differences. These similarities and differences, though, aren’t just between the Raspberry Pi and any other computer you’ve ever used. Rather, brands and generations of computers each have been shaped by a wide range of social, cultural, and economic factors that have influenced the look, feel, and functionality of a given computer within a given context. To this extent, Raspberry Pi is just like other computers in use today.
- Compare and contrast your experiences with the different computers you have used. There are three primary types of operating systems used today:
- Microsoft Windows-based operating systems, developed by Microsoft in the early 1980s.
- Apple Mac-based operating systems, a Unix-based system released at the end of the century to replace the “classic” Mac OS introduced in 1984.
- Linux-based operating systems, including:
- Android, a mobile operating system developed by Google first commercially used in 2007.
- Chrome OS, an operating system that uses the Google Chrome web browser as its principle user interface and first used commercially in 2011.
- Ubuntu, Mint, Fedora, and other popular Linux distributions used on laptop, desktop, and server computers around the world.
- Raspberry Pi OS, the first choice in most cases for the Raspberry Pi computer.
- If possible, compare and contrast any brand new computers you’ve turned on for the very first time.
- As you compare and contrast operating systems, consider how the following components vary:
- The command line interface
- The setup and configuration files
- The included everyday applications
Wrap Up
Now that the Raspberry Pi is up and running, we’ll dive directly into two exercises, first, to implement Python code on the Raspberry Pi which will control the LED lights we have set up on the breadboard. Second, we will play our counterstories for the first time on the Raspberry Pi.
- Raspberry Pi learning resources and documentation are licensed under CC-BY-SA 4.0. The Raspberry Pi Help Guide offers a deeper dive into the materials in this part of the chapter. Headless activity adapted from Adafruit Industries PiUART tutorial. ↵
- Fritzing breadboard graphics are licensed under CC-BY-SA 3.0. ↵
The core software bundle of a computer. The OS supports different aspects of a computer’s basic functions, overseeing the coordination between the physical electronics of the computer and the many software applications that allow us to do our daily computer-based activities. While the physical electronic components of most personal computers support multiple different operating systems, only one OS can be run on a computer at a given time since it is the central control system of those physical electronics. That is, the OS has the final word on how software interacts with hardware when the computer is turned on and functioning.
The kernel is the heart of the OS, and for the most part remains hidden from view. On the opposite side, the Graphical User Interface (GUI) serves as the visual mechanism for interacting with a computer, whether via keyboard, mouse, and monitor, touchpad, or something else. All modern computers also include a Command Line Interface (CLI) such as a terminal window in which applications can be run and data is displayed using text. Indeed, for higher-level programming, research and development, and systems management, a combination of GUI and CLI interfaces used in parallel prove essential.
The simplest type of Internet-based area networks is a Local Area Network (LAN). A LAN is a network with connected devices in a close geographical range. It is generally owned, managed, and used by people in a building. For example, connecting to a WiFi network at a coffee shop or library would mean your device would be a node on the cafe or library's publicly accessible LAN. Many businesses and institutions have a second, private LAN for use by staff only.
The heart of the operating system. It is the go-between from applications between input/output controllers, memory, the Central Processing Unit (CPU) and storage devices.
A file manager is a software program that helps you manage all the files on your computer. For example, file managers allow you to view, edit, copy, and delete the files on your computer's storage devices. It is known as the File Manager within the Windows Operating System and as the Finder on the Mac Operating System. The file manager makes use of the Graphical User Interface (GUI). The same tasks you can complete with the file manager can also be done through the Command Line Interface (CLI) terminal.