The Raspberry Pi is marketed as a small and affordable computer that you can use to learn programming. At least that was its initial goal. As we will see in this book, it is much more than that.
The following topics will be covered in this chapter:
- A brief history of the Raspberry Pi
- A look at operating systems for the Raspberry Pi
- Installing the Raspbian OS
- A quick overview of the Raspbian OS
First released in 2012, the first Raspberry Pi featured a 700 MHz single core processor and 256 MB of RAM. The Raspberry Pi 2 was released in February of 2015 with a 900 MHz quad core processor and 1 GB of RAM. Released in February of 2016, the Raspberry Pi 3 increased the processor speed to 1.2 GHz. This model was also the first one to include wireless LAN and Bluetooth.
Here is an image of a Raspberry Pi 3 B (2015):
This version of the Raspberry Pi features the following parts:
- Four USB 2 ports
- A LAN port
- A 3.5 mm composite video and audio jack
- An HDMI port for video and audio
- An OTG USB port (which we will use to connect the power)
- A microSD slot (to hold our operating system)
- A DSI display port for the Raspberry Pi touchscreen
- A General Purpose Input Output (GPIO) pins
- A camera port for a special Raspberry Pi camera
The Raspberry Pi Zero was released in November of 2015. Here is an image of it:
Although not as powerful as the previous Raspberry Pis, the Zero featured a smaller size (65 mm X 30 mm), perfect for projects with limited physical space (namely, wearable projects). Plus, the Raspberry Pi zero was priced at $5 USD, making it very affordable. The Raspberry Pi zero W was released on February 28, 2017 at double the price ($10 USD) with built-in Wi-Fi and Bluetooth capabilities.
The latest model, as of the time of writing, is the Raspberry Pi 3 B+, which was released on March 14, 2018. The processor speed has been upgraded to 1.4 GHz as well as the wireless LAN now supporting both 2.4 GHz and 5 GHz bands. Another upgrade is the addition of Bluetooth low energy, a technology built for applications that do not require large amounts of data to be exchanged but are required to have a long battery life.
Creators of the Raspberry Pi initially believed that they would sell at most 1,000 units. Little did they know that their invention would explode in popularity. As of March 2018, sales of Raspberry Pi computers has passed the 19 million mark.
There are various operating systems (or system images) that may be installed on the Raspberry Pi. These range from application-specific operating systems, such as audio players, to various general purpose operating systems. The power behind Raspberry Pi is the way it can be used for various applications and projects.
The following is a list of just a few of the operating systems (system images) available for the Raspberry Pi:
- Volumio: Do you have a desire to set up a networked audio system where you access your music list using a computer or cell phone? Volumio may be what you are looking for. Installing it on a Raspberry Pi creates a headless audio player (a system that does not require a keyboard and mouse) that connects to your audio files either over USB or a network. A special audio Hardware Added on Top (HAT) may be added to your Pi to provide a pristine audio connection to an amplifier and speakers. There is even a plugin to add Spotify so that you can set up your Raspberry Pi to access this service and play music over your sound system.
- PiFM radio transmitter: The PiFM radio transmitter turns your Raspberry Pi into an FM transmitter, which you can use to send audio files over the air to a standard FM radio receiver. Using a simple wire connected to one of the GPIO pins (we will learn more about GPIO later), you can create an antenna for the transmitted FM signal, which is surprisingly strong.
- Stratux: ADS-B is the new standard in aviation where geo-location and weather information are shared with ground controllers and pilots. The Stratux image with additional hardware turns the Raspberry Pi into an ADS-B receiver of this information.
- RetroPie: RetroPie turns your Raspberry Pi into a retro game console by emulating gaming consoles and computers from the past. Some of the emulations include Amiga, Apple II, Atari 2600, and the Nintendo Entertainment System of the early 1980s.
- OctoPi: OctoPi turns your Raspberry Pi into a server for your 3D printer. Through OctoPi, you may control your 3D printer over the network, including viewing the status of your 3D printer using a webcam.
- NOOBS: This is arguably the easiest way to install an operating system on the Raspberry Pi. NOOBS stands for New Out-Of-the Box Software, and we will be using NOOBS to install Raspbian.
In this project, we will install the Raspbian operating system onto our Raspberry Pi. After installation, we will take a quick tour of the operating system to familiarize ourselves with it. We will start by formatting a microSD card to store our installation files. We will then run the installation from the microSD card. After Raspbian has been installed, we will take a quick look at it in order to familiarize ourselves with it.
This project should take about two hours to complete, as we install the Raspbian operating system and take a quick look at it.
The following is required to complete this project:
- A Raspberry Pi Model 3 (2015 model or newer)
- A USB power supply
- A computer monitor
- A USB keyboard
- A USB mouse
- A microSD RAM card
- A Raspberry Pi NOOBS image (https://www.raspberrypi.org/downloads/noobs/)
The Raspbian OS is considered the default or go-to operating system for the Raspberry Pi. In this section, we will install Raspbian using the NOOBS image.
Raspberry Pi uses a microSD card to store the operating system. This allows you to easily switch between different operating systems (system images) for your Raspberry Pi. We will be installing the default Raspbian OS for our projects using the NOOBS image.
Start by inserting the microSD card into a USB adapter and plug it into your computer:
You may need to format the microSD card. If so, use the utilities appropriate for your computer's operating system to format the card to FAT32. It is recommended that you use a card with a capacity of 8 GB or greater. For Windows OS and cards with 64 GB of capacity or greater, a third-party tool such as FAT32 format should be used for formatting.
Unzip the NOOBS image that you downloaded. Open up the unzipped directory and drag the files over to the microSD card.
The files should look the same as in the following screenshot:
We will now install Raspbian on our Raspberry Pi. This step should be familiar to those that have previous experience installing operating systems such as Windows or macOS. The Raspbian operating system will be installed and will run off of our microSD card.
To install Raspbian onto our microSD card, do the following:
- Start by inserting the microSD card into the appropriate slot on the Raspberry Pi. Be sure to install it so that the label side (opposite side of the exposed contacts) is facing up. Insert it with the metal contacts facing the board. The microSD card should have a slight ridge at the top of the label side, which is good for easy removal using a fingernail.
- Insert a keyboard and mouse into the USB slots on the side, a monitor into the HDMI port, and lastly, a USB power cable into the power port. The Raspberry Pi does not have an on/off switch and will power up as soon as the power cable is connected:
- After an initial black screen with rolling white text, you should see the following dialog:
- In the previous screenshot, we clicked on the Language option. For our purposes, we will keep the default of English (UK). We will also keep the keyboard at the standard gb.
- As the Raspberry Pi 3 has wireless LAN, we can set up our Wi-Fi (for older boards, please plug a Wi-Fi dongle into a USB port or use the wired LAN port and skip the next step):
- Click on the Wifi networks (w) button. Choose the Authentication method using the radio buttons. Some routers are equipped with a WPS button that allows you to connect directly to the router. To use the password method, choose the Password authentication radio button and enter the password for your network. After connecting to your network, you will notice that there are now more operating system options to select from:
- We will go with the top option, Raspbian. Check the box beside Raspbian [RECOMMENDED] and then click on the Install (i) button at the top-left corner of the dialog. Raspbian will start installing on your Raspberry Pi. You will see a progress bar with previous graphics, describing various features of the Raspbian operating system:
- After the progress bar hits 100%, the computer will reboot and you will see a screen with text before the default desktop loads up:
The Raspbian desktop is similar to the desktops of other operating systems such as Windows and macOS. Clicking the top-left button drops down the application menu where you may access the various pre-installed programs. We may also shut down the Raspberry Pi from this menu:
The second button from the left loads the Google Chromium web browser for the Raspberry Pi:
The Chromium browser is a lightweight browser that runs remarkably well on the Raspberry Pi:
The two-folders button opens up a window showing the home folder:
The home folder is a great place to start when looking for files on your Raspberry Pi. In fact, when you take screenshots using either the scrot command or the Print Screen button, the file is automatically stored in this folder:
The third button from the left opens up the Terminal. The Terminal permits command-line access to Raspberry Pi's files and programs:
It is from the command line where you may update the Raspberry Pi using the sudo apt-get update and sudo apt-get dist-upgrade commands.
apt-get updates the packages list, and apt-get dist-upgrade updates the packages:
It's a good idea to run both of these commands right after installing Raspbian using the sudo command. The default user for Raspbian on the Raspberry Pi is pi, which is part of the Super Users group in Raspbian, and thus must use the sudo command (the default password for the pi user is raspberry):
ls: Command to see the contents of the current directory
cd: Command to change directories. For example, use cd to move up a directory from where you currently are
pwd: Command to display the directory you are currently in
sudo: Allows the user to perform a task as the super user
shutdown: Command that allows the user to shut down the computer from the Terminal command line
The third and fourth buttons are for Mathematica, and a terminal to access the Wolfram language, respectively:
Mathematica spans all areas of technical computing and uses the Wolfram language as the programming language. The areas in which Mathematica is used include machine learning, image processing, neural networks and data science:
Mathematica, a proprietary software first released in 1988, can be used free for individuals on the Raspberry Pi through a partnership that was announced in late 2013.
Now let’s take a look at some of the programs that are accessed from the main drop-down menu.
Sonic Pi is a live coding environment for creating electronic music. It is accessed from the Programming menu option. Sonic Pi is a creative way to create music as the user programs loops, arpeggios, and soundscapes in real time by cutting and pasting code from one part of the app to another. Synthesizers in Sonic Pi may be configured on a deep level, providing a customized experience for the music coder:
Geared toward an EDM style of music, Sonic Pi may also be used to compose classical and jazz styles of music.
Scratch and Scratch 2.0 are visual programming environments designed for teaching programming to children. Using Scratch, the programmer creates their own animations with looping and conditional statements.
Games may be created within the program. The first version of Scratch was released in 2003 by the Lifelong Kindergarten group at the MIT media lab. Scratch 2.0 was released in 2013, and development is currently underway with Scratch 3.0:
Scratch and Scratch 2.0 may be accessed under the Programming menu option.
LibreOffice is a free and open source office suite that forked over from OpenOffice in 2010. The LibreOffice suite consists of a word processor, a spreadsheet program, a presentation program, a vector graphics editor, a program for creating and editing mathematical formulae, and a database management program. The LibreOffice suite of programs may be accessed through the LibreOffice menu option:
We started this chapter with a look at the history of the Raspberry Pi. What started as an initiative to promote programming to a new generation has grown into a global phenomenon. We then downloaded the NOOBS image and installed the Raspbian OS, the default operating system for the Raspberry Pi. This involved formatting and preparing a microSD card for the NOOBS files.
It's easiest to think that a computer as inexpensive and small as the Raspberry Pi is not all that powerful. We demonstrated that the Raspberry Pi is indeed a very capable computer, as we took a look at some of the applications that come pre-installed with the Raspbian OS.
In Chapter 2, Writing Python Programs Using Raspberry Pi, we will begin Python coding using the Raspberry Pi and some of the development tools available in Raspbian.
- What year did the first Raspberry Pi come out?
- What upgrades did the Raspberry Pi 3 Model B+ have over the previous version?
- What does NOOBS stand for?
- What is the name of the pre-installed application that allows for creating music with Python code?
- Where is the operating system stored for the Raspberry Pi?
- What is the name of the visual programming environment designed for children that comes pre-installed with Raspbian?
- What is the name of the language used in Mathematica?
- What is the default username and password for Raspbian?
- What does GPIO stand for?
- What is RetroPie?
- True or false? Clicking on the two-folders icon on the main bar loads the home folder.
- True or false? The microSD card slot is located at the bottom of the Raspberry Pi.
- True or false? To shutdown the Raspberry Pi, select Shutdown from the Application menu.
- True or false? You may only install the Raspbian OS with NOOBS.
- True or false? Bluetooth low energy refers to people that eat too many blueberries and have a hard time waking up in the morning.
For more information on the Raspberry Pi, please consult the main Raspberry Pi website at www.raspberrypi.org.