© Brian Schell 2019
B. SchellComputing with the Raspberry Pihttps://doi.org/10.1007/978-1-4842-5293-2_1

1. Setting Up the Raspberry Pi As a Computer

Brian Schell1 
(1)
Flint, MA, USA
 

In this chapter, we’ll look at the hardware aspect of our project. We’ll go over all the options for hardware and parts; then we’ll assemble everything. The biggest part of the project is installing the basic operating system, and going through the initial setup phase of Raspbian, the Raspberry Pi operating system.

If you’ve ever assembled a desktop computer, this is essentially the same process, but everything is just a little different on the Pi. If you’ve never “built” a computer before, then you’re in for a fun chapter; once you’ve got all the parts, the rest is just a matter of following the instructions.

It’s obvious why you need the hardware; you wouldn’t have a computer without the physical parts. But why do we need to install an operating system? You don’t usually need to do that with a Mac or Windows computer, so why is this necessary for the Pi? The simplest reasons are freedom and choices.

If you have a Mac, you’re going to run MacOS (formerly OSX). If you have a consumer-style PC, it’s going to come with Windows 10. You don’t need to install anything; just plug them in and they’ll work, but you don’t get to choose. You generally don’t run Windows on a Mac or MacOS on a PC. There’s no choice.

The Raspberry Pi, on the other hand, runs the Linux operating system rather than MacOS or Windows. Linux is a free operating system that was created and is maintained by volunteers working for free. These millions of volunteers are constantly improving and debugging and working tirelessly so that there are alternatives to MacOS and Windows.

Like with any large group, when you have that many developers, it’s hard to get everyone to agree on what’s best, so there are numerous different types of Linux. These different flavors are called distributions. Each one is essentially the same at the core, and that’s what makes them Linux; but there are many aspects of the operating system that are optional, like what the desktop looks like, how the setup screens work, what apps are included, which web browser is the default, and things like that. There are about a dozen different distributions of Linux that work on the Raspberry Pi, and we’ll only be focusing heavily on one of them; but at any time, it’s easy to set up and use a different version, and surprisingly enough, it’s a lot of fun—you may want to try several and see which one works the most like what you want in a computer.

Hardware Requirements and Notes on Getting Started

I said we’d be going minimal here, and I wasn’t kidding. There aren’t any tricks or hidden costs here. There are no subscription services to pay every month, and no extra hardware is needed; but most of the usual PC hardware accessories, like hard drives, flash drives, fancy mice, keyboards, and Bluetooth devices, can be optionally used, so you don’t have to limit yourself to the basics.

Here’s a quick “shopping list” of things you probably don’t have lying around already. All prices are in US dollars:
  • Raspberry Pi model 4 system board ($35–$55).

  • 5.1V/3.0A DC output power supply with micro-USB plug (around $8).

  • Micro SD card with 8GB capacity or more (around $6).

  • Some kind of enclosure or case made for the model 4 system.

  • CanaKit (and other sources) offers a complete starter kit with case, power supply, heat sinks, SD card, and Raspberry Pi main board for $79.95 at the time of this writing.

    Alternatively,

  • Raspberry Pi model 3B+ system board (around $35)

  • 3.5A power supply with micro-USB plug (around $7)

  • Micro SD card with 8GB capacity or more (around $6)

  • Some kind of enclosure or case made for the 3B+ system ($6 and up)

The following are additional things to consider:
  • Motherboard: For the system board, you can use older Raspberry Pi models instead of the 4 or 3B+, but I wouldn’t recommend it. The Pi model 2s were quite a bit slower and also required a dongle for Wi-Fi and Bluetooth. Wi-Fi and Bluetooth are built-in with the model 3 Pi. Also, the 3B+ is faster and has better networking speed than the original 3B. The Raspberry Pi Zero is a current device, but has significantly less processor power, and we need that power with many desktop applications. It’s only logical that for maximum power, we want the newest and most powerful Pi, which is the model 4 (as of this writing). You can use the Pi Zero or the older versions if you want, but same apps may have difficulties that are hard to predict. Everything mentioned in this book has been thoroughly tested with the model 3B+ and 4.

  • Model 3B+ Power Supply: Depending on your phone, the charger you use for it might work fine here. Check the amperage and that it uses a micro-USB plug. Most Android phones have this plug, but iPhones don’t. The power requirements for the Raspberry Pi model 3 are 5V and 2.5A. The Pi model 2 and some older models can use 2A power supplies, but the models 3 and 3+ are stricter in requiring a steady 2.5A. If in doubt, buy an approved power supply. Various models are available online ranging from $7 to $10.

  • Model 4 Power Supply: The newer model 4 RPi boards take their power from a USB-C connector, not the micro-USB of all the previous models. They also have a generally higher power consumption than any previous system. You’ll need a 15.3W USB-C power supply for the model 4. Again, a phone charger might work, but to be safe get the approved power supply.

  • Micro SD Card: You can use almost any micro SD card if you have one lying around, but the ones marked “class 10” are the fastest. This is essentially our boot-up hard drive, so any speed bump we can get in this area is good. The “official” maximum size for the card is 32GB. Although there are reports of some larger sizes that work, there are no guarantees, and some larger cards definitely do not work. My recommendation is to get an 8–16GB class 10 card to start, depending on what kind of a deal you can get. Later on, we’ll look at setting up the Pi to boot from an actual external hard drive, and this will be a better, safer solution for storing larger quantities of data. A new 16GB card is available for less than $6 as I write this, so if you have a slow card already, I’d recommend splurging on a new one.

  • Case: I’ve seen plenty of people use the Pi with the exposed board lying on the tabletop. It works, but I wouldn’t recommend it. Get a case that you like. If you are going to be using this system for any length of time, you’ll want to keep dust and dirt off of the board, and you’ll need to handle the computer to plug in the power supply and various USB cables. A nice case just protects everything and makes it all look good. There are cheap plastic cases available for as low as $6 and some fancy hand-carved wooden ones for upward of $50. They all work essentially the same, so cheap is fine. There are some high-end cases that include fans, but this is almost certainly not necessary for the kinds of software we’ll be running. I’d recommend getting the cheapest case you can find, but don’t be afraid to splurge later. If you’re handy with wood, or if you have a 3D printer, you can even make your own! Also, keep in mind that the model 4 has a completely different port layout than any older model, so a case made for a model 3 will not work for a model 4.

Here are some other things you’ll need that you may already have:
  • Keyboard

  • Mouse

  • Monitor

  • HDMI cable for connecting the Pi to your monitor

With the introduction of the Raspberry Pi model 4 in June of 2019, the Raspberry Pi Foundation also introduced an official keyboard and mouse for the Pi. These are attractively color-coordinated to match the official Pi case, and the keyboard has a “raspberry button” on it in the usual “system key location,” but otherwise, they are not required. You can use any USB mouse or keyboard, and these can be either wired with USB or they can use Bluetooth for their connections. Other than that, you can use the same keyboard and mouse you had for your old computer.

Any standard monitor will work, but you’ll need a cable with a micro-HDMI plug to connect with your model 4 Pi or a full-size HDMI port to plug into any of the previous models. If you are using the Raspberry Pi model 4, you also have the option of using two monitors at once if you choose. Obviously, you would need two monitors and two micro-HDMI cables to take advantage of the dual-monitor capability.

Creating the Initial Boot Media

Initially, we’ll need to download the operating system software and install it on the SD card. This will require a separate computer running Windows, Mac, or Linux. If you really can’t make that work, there are many places that will sell you a SD card with the software already installed; a simple Google search will find a source in your country.

You will need a micro SD card and adaptor to fit the card into whatever slot your computer has.

There are many distributions, or “brands,” of Linux that are easily available. Two of the most popular are Raspbian and Ubuntu MATE. Both of these focus on different things: Raspbian is the “official” operating system of the Raspberry Pi, and Ubuntu MATE is a much heavier, desktop-oriented operating system. Raspbian is faster and more efficient, while MATE is easier to use and includes more built-in software, but it is also slower.

The current version of Ubuntu MATE as of this writing is 18.04, which was released in April of 2018. That sounds “old,” but Ubuntu has an update system in place where they offer something called LTS, or “Long-Term Support,” edition of their operating system. They guarantee support for an LTS version for up to 4 years. The downside of this is that they only release a new version every 2 years. So there won’t be new LTS edition until April of 2020. Ubuntu does offer upgrades to its regular operating system every 6 months, but they don’t do it for the Raspberry Pi version. So we’re all stuck in 2018 for a while.

Ubuntu MATE can be found at https://ubuntu-mate.org/download/ .

Raspbian, on the other hand, is released on an irregular schedule whenever enough changes accumulate. The latest version as of this writing is called “Buster ” (June of 2019). If you want the cutting edge, most “official” version of the Raspberry Pi operating system, this is the one to use.

I’ll mostly be focusing on Raspbian in this book, but I will occasionally point out something that can be done differently in MATE. One of the great things about the Raspberry Pi is that for the cost of a second SD card, you can switch back and forth very quickly. Why not try both?

Raspbian can be found at www.raspberrypi.org/downloads/raspbian/ .

The next piece of software that we’ll need is a special utility to copy the operating system to the SD card and make it bootable. The easiest application I’ve found to do this is balenaEtcher, usually just referred to as Etcher. There is a version available for Windows, Mac, and Linux; so wherever you’re coming from, they make a version for you.

balenaEtcher can be found at www.balena.io/etcher/ .

Note

It is also possible to create an SD card image from the command line from MacOS or Linux, but it is complex and not at all possible from Windows. For the sake of maximum compatibility and simplicity, I’m going to stick with Etcher here. If you need to do it from the command line, the official documentation can be found here: www.raspberrypi.org/documentation/installation/installing-images/README.md .

The process of creating a bootable SD card is simple once you have the preceding ingredients. Download one of the operating system files, either Ubuntu MATE or Raspbian. Whichever you choose, you’ll end up downloading one large file.

Once that’s done, launch Etcher, and it should look like Figure 1-1.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig1_HTML.jpg
Figure 1-1

balenaEtcher with source file and destination drive selected

There are three buttons/icons. Click the one on the left, and it will allow you to choose a disk image. This is either the Raspbian or Ubuntu MATE file you just finished downloading.

Insert an SD card into the computer. You may need to use an adaptor, dongle, or hub to make it fit. Once the computer recognizes the card, click the middle icon to select the card. Make absolutely sure not to select the wrong disk, as you can delete your computer’s hard drive if you aren’t careful!

When you’re done selecting the operating system file and the target drive, then click the third icon, “Flash!” This will begin the process of formatting the SD card and copying the operating system onto it. This process may take 5–10 minutes depending on various factors, as in Figure 1-2.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig2_HTML.jpg
Figure 1-2

Etcher partway through flashing

Once the process has completed, Etcher will tell you that it has flashed the card successfully, or it will give you an error message. If there’s an error, follow Etcher’s suggestions and figure out why. Assuming it worked, you can eject the card and proceed to assembling your Pi.

Assembling the Computer

The following lists outline the required and optional assembly parts:

  • Required Parts
    • Raspberry Pi motherboard

    • Power supply

    • Micro SD card with an operating system installed on it (from the previous section)

    • Mouse

    • Keyboard

    • Monitor

    • Monitor cable

  • Optional Parts
    • Case for motherboard

    • Audio listening device (headphones, earbuds, or speakers or just plug it into your monitor’s input) with either 3.5mm jack or Bluetooth capability

    • Ethernet cable to plug into your router if you aren’t using Wi-Fi

Assembly Instructions

Assuming you have purchased or scrounged all the necessary pieces, assembling the Raspberry Pi into a desktop computer is very easy, as it should be obvious where all the cables go.
  1. 1.

    Insert your Raspberry Pi motherboard into your chosen case and assemble it using whatever instructions come with the case. If your case came with some form of heat sink, be careful not to get fingerprints on either the top of the processor or the bottom of the heat sink.

     
  2. 2.

    Slide the micro SD card into the slot on the underside of the Raspberry Pi.

     
  3. 3.

    Plug in the HDMI cable into the monitor and the RPi.

     
  4. 4.

    Plug in the audio cable into speakers, headphones, or your monitor.

     
  5. 5.

    Plug in the mouse and keyboard into any of the four USB ports. If you have other USB items, I would recommend sticking with just the mouse and keyboard for now; add other peripherals after those are working. It’s probably OK to use a Bluetooth mouse or keyboard at this stage, as these should be detected on startup. In the rare chance that they aren’t, a wired keyboard or mouse may be needed to get the settings configured.

     
  6. 6.

    Plug in the Ethernet cable if you aren’t going to use Wi-Fi. If you do plan to use Wi-Fi, then this is not needed.

     
  7. 7.

    Plug the monitor into the wall outlet.

     
  8. 8.

    Plug the Raspberry Pi power adaptor into the wall outlet.

     
  9. 9.

    The final step, after everything else, is to plug the power supply into the Pi. The Raspberry Pi itself does not have a power switch, so applying power will start the boot process. If your power supply does come with a switch or button, then turn it on now.

     

At this point, your monitor will show a colorful “test pattern;” then clear the screen and show a number of raspberry icons at the top of the screen. After this, a bunch of status messages and texts may scroll up the screen.

First-Time Raspbian Setup

As mentioned earlier, we’re going to be focusing on the Raspbian distribution from here out. Ubuntu MATE will be very similar, but not exactly the same, as what’s shown here.

Assuming you got past the test pattern and the “raspberries,” you’ll wind up at the Raspbian welcome screen, as seen in Figure 1-3.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig3_HTML.jpg
Figure 1-3

Welcome screen for Raspbian

Click “Next,” and we’ll get a localization screen that looks a lot like Figure 1-4.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig4_HTML.jpg
Figure 1-4

Localization settings

Use the dropdown boxes to select your location as accurately as possible. This is used to set the time and determine what the various keys on your keyboard do. I once had a friend complain that Raspbian didn’t work with any of his keyboards, as the punctuation keys were all wrong. Turned out, he had left the following dialog set to a UK keyboard, and he was in the United States. It’s not all the same!

Now it’s time to change the password for the default user, as shown in Figure 1-5. It might be useful to know if you don’t change it here, the default is user “pi” and that user’s password is “raspberry.” Since this is the same username and password for every default Raspbian install, everywhere, it’s a very good idea to change the password. This user has superuser access and has the ability to delete and change literally anything, so make the password something hard to guess.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig5_HTML.jpg
Figure 1-5

Setting the root password

We will investigate creating a separate, more personalized user account later. If you are experienced with Linux, the Pi user is a root-level account, so it’s not really a good idea to use this account for everyday work.

The next screen, shown in Figure 1-6, pertains to your monitor and screen resolution. The screens up to this point have been low resolution and pretty plain, since everything is at the lowest resolution possible. If the Raspbian desktop is currently filling your entire screen, then don’t check the box. If there’s a black bar or border on the edges, then click the box, and Raspbian will adjust your settings accordingly. Be aware that you will not see anything happen until the installation is done and the system reboots.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig6_HTML.jpg
Figure 1-6

Do you need screen resolution adjustments?

Now, in Figure 1-7, it’s time to set up your Wi-Fi network. If you are going to use Ethernet for your network, you can click “Skip.” Otherwise, find your network here. Note that the Pi model 3B+ has both 2.4GHz and 5.0GHz capabilities available to you, while the regular non-plus model 3B and all the older models can only access 2.4GHz networks. Click the network you want to connect to, and then enter the password for the network on the following screen:
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig7_HTML.jpg
Figure 1-7

Setting the Wi-Fi password

After this, we are essentially done with the installation. The next and final screen, similar to Figure 1-8, will give us the opportunity to download updates and patches to software that didn’t make it into the release on our SD card. You can skip this if you’re in a hurry, but it’s always best to have a fully updated system.
../images/485525_1_En_1_Chapter/485525_1_En_1_Fig8_HTML.jpg
Figure 1-8

Let the updates begin!

If you choose to let it do the updates, you’ll eventually get a dialog telling you your “System is up to date.” At this point, you’ll need to reboot the system, and everything should be ready to go.

It’s safe at this stage to explore the menus and try out a few apps. Figure 1-9 shows a shot of LibreOffice Writer, the File Manager app, and the Chromium browser, all of which are already installed. Can you find them in the menus?

Hint

The Raspberry icon in the top-left corner is essentially Raspbian’s version of the “Start” button for the menuing system.

../images/485525_1_En_1_Chapter/485525_1_En_1_Fig9_HTML.png
Figure 1-9

LibreOffice, File Explorer, and Chromium come installed by default

Conclusion

This chapter set the stage for the rest of the book. We bought and assembled all the pieces, and then we downloaded and created out boot media. We then went through the setup menus and ended up with a bare-bones but still fully working little computer. Feel free to poke around in the menus and run the apps, and see what it can do. If your needs are simple, such as just web browsing and email, you may already have all you need in a computer. More likely, you’ll need to install a bunch of apps to do the things you want to do with the RPi. If you want to use your Raspberry Pi as a normal desktop computer, then you’re good to go. Still, there are other ways of accessing the computer than just sitting in front of a monitor, as we’ll see in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.218.147