Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

The Official Raspberry Pi Beginner's Guide: How to use your new computer
The Official Raspberry Pi Beginner's Guide: How to use your new computer
The Official Raspberry Pi Beginner's Guide: How to use your new computer
Ebook473 pages3 hours

The Official Raspberry Pi Beginner's Guide: How to use your new computer

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Raspberry Pi is a small, clever, British-built computer that's packed with potential. Made using a desktop-class, energy-efficient processor, Raspberry Pi is designed to help you learn coding, discover how computers work, and build your own amazing things. This book was written to show you just how easy it is to get started.

Learn how to:

  • Set up your Raspberry Pi, install its operating system, and start using this fully functional computer.
  • Start coding projects, with step-by-step guides using the Scratch 3, Python, and MicroPython programming languages.
  • Experiment with connecting electronic components, and have fun creating amazing projects.

This revised edition is updated for the latest Raspberry Pi computers: Raspberry Pi 5 and Raspberry Pi Zero 2 W as well as the latest Raspberry Pi OS. It also includes a new chapter on the Raspberry Pi Pico!

Whichever model you have, a standard Raspberry Pi board; the compact Raspberry Pi Zero 2 W; or the Raspberry Pi 400 with integrated keyboard, this affordable computer can be used to learn coding, build robots, and create all kinds of weird and wonderful projects. If you want to make games, build robots, or hack a variety of amazing projects, then this book is here to help you get started.

LanguageEnglish
Release dateOct 31, 2023
ISBN9781912047277
The Official Raspberry Pi Beginner's Guide: How to use your new computer
Author

Gareth Halfacree

Gareth Halfacree is a freelance technology journalist, writer, and former system administrator in the education sector. With a passion for open-source software and hardware, he was an early adopter of the Raspberry Pi platform and has written several publications on its capabilities and flexibility. He can be found on Mastodon as @ghalfacree@mastodon.social or via his website at freelance.halfacree.co.uk.

Related to The Official Raspberry Pi Beginner's Guide

Hardware For You

View More

Related articles

Reviews for The Official Raspberry Pi Beginner's Guide

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    The Official Raspberry Pi Beginner's Guide - Gareth Halfacree

    background

    The Official Raspberry Pi Beginner’s Guide, 5th Edition

    The Official Raspberry Pi Beginner’s Guide

    by Gareth Halfacree

    ISBN: 978-1-912047-26-0

    Copyright © 2024 Gareth Halfacree

    Printed in the United Kingdom

    Published by Raspberry Pi, Ltd., 194 Science Park, Cambridge, CB4 0AB

    Editors: Brian Jepson, Liz Upton

    Interior Designer: Sara Parodi

    Production: Nellie McKesson

    Photographer: Brian O’Halloran

    Illustrator: Sam Alder

    Graphics Editor: Natalie Turner

    Publishing Director: Brian Jepson

    Head of Design: Jack Willis

    CEO: Eben Upton

    October 2023: Fifth Edition

    November 2020: Fourth Edition

    November 2019: Third Edition

    June 2019: Second Edition

    December 2018: First Edition

    The publisher, and contributors accept no responsibility in respect of any omissions or errors relating to goods, products or services referred to or advertised in this book. Except where otherwise noted, the content of this book is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)

    Welcome to the Official Raspberry Pi Beginner’s Guide

    We think you’re going to love your Raspberry Pi. Whichever model you have — a standard Raspberry Pi board, the compact Raspberry Pi Zero 2 W, or the Raspberry Pi 400 with integrated keyboard — this affordable computer can be used to learn coding, build robots, and create all kinds of weird and wonderful projects.

    Raspberry Pi is capable of doing all the things you’d expect from a computer — everything from browsing the internet and playing games, to watching movies and listening to music. But your Raspberry Pi is much more than a modern computer.

    With a Raspberry Pi you can get right into the heart of a computer. You get to set up your own operating system, and can connect wires and circuits directly to its GPIO pins. It was designed to teach young people how to program in languages like Scratch and Python, and all the major programming languages are included with the official operating system. With Raspberry Pi Pico, you can create unobtrusive, low-power projects that interact with the physical world.

    The world needs programmers more than ever, and Raspberry Pi has ignited a love of computer science and technology in a new generation.

    People of all ages use Raspberry Pi to create exciting projects: everything from retro games consoles to internet-connected weather stations.

    So if you want to make games, build robots, or hack a variety of amazing projects, then this book is here to help you get started.

    You can find example code and other information about this book, including errata, in its GitHub repository at rptl.io/bg-resources. If you’ve found what you believe is a mistake or error in the book, please let us know by using our errata submission form at rptl.io/bg-errata.

    About the author

    Gareth Halfacree is a freelance technology journalist, writer, and former system administrator in the education sector. With a passion for open-source software and hardware, he was an early adopter of the Raspberry Pi platform and has written several publications on its capabilities and flexibility. He can be found on Mastodon as @ghalfacree@mastodon.social or via his website at freelance.halfacree.co.uk.

    Colophon

    Raspberry Pi is an affordable way to do something useful, or to do something fun.

    Democratising technology — providing access to tools — has been our motivation since the Raspberry Pi project began. By driving down the cost of general-purpose computing to below $5, we’ve opened up the ability for anybody to use computers in projects that used to require prohibitive amounts of capital. Today, with barriers to entry being removed, we see Raspberry Pi computers being used everywhere from interactive museum exhibits and schools to national postal sorting offices and government call centres. Kitchen table businesses all over the world have been able to scale and find success in a way that just wasn’t possible in a world where integrating technology meant spending large sums on laptops and PCs.

    Raspberry Pi removes the high entry cost to computing for people across all demographics: while children can benefit from a computing education that previously wasn’t open to them, many adults have also historically been priced out of using computers for enterprise, entertainment, and creativity. Raspberry Pi eliminates those barriers.

    Raspberry Pi Press

    store.rpipress.cc

    Raspberry Pi Press is your essential bookshelf for computing, gaming, and hands-on making. We are the publishing imprint of Raspberry Pi Ltd, part of the Raspberry Pi Foundation. From building a PC to building a cabinet, discover your passion, learn new skills, and make awesome stuff with our extensive range of books and magazines.

    The MagPi

    magpi.raspberrypi.com

    The MagPi is the official Raspberry Pi magazine. Written for the Raspberry Pi community, it is packed with Pi-themed projects, computing and electronics tutorials, how-to guides, and the latest community news and events.

    HackSpace

    hackspace.raspberrypi.com

    HackSpace magazine is filled with projects for fixers and tinkerers of all abilities. We’ll teach you new techniques and give you refreshers on familiar ones, from 3D printing, laser cutting, and woodworking to electronics and the Internet of Things. HackSpace will inspire you to dream bigger and build better.

    Chapter 1

    Get to know your Raspberry Pi

    Introducing your new credit-card-sized computer. Take a guided tour of the Raspberry Pi, find out how it works, and discover some of the amazing things you can do with it.

    Raspberry Pi is a remarkable device: a fully functional computer in a tiny, low-cost package. Whether you’re looking for a device you can use to browse the web or play games, are interested in learning how to write your own programs, or are looking to create your own circuits and physical devices, Raspberry Pi — and its amazing community — will support you every step of the way.

    Raspberry Pi is known as a single-board computer, which means exactly what it sounds like: it’s a computer, just like a desktop, laptop, or smartphone, but built on a single printed circuit board. Like most single-board computers, Raspberry Pi is small — it has roughly the same footprint as a credit card — but that doesn’t mean it’s not powerful: a Raspberry Pi can do anything a bigger and more power-hungry computer can do, from browsing the web and playing games to driving other devices.

    The Raspberry Pi family was born from a desire to encourage more hands-on computer education around the world. Its creators, who joined together to form the non-profit Raspberry Pi Foundation, had little idea that it would prove so popular: the few thousand built to test the waters in 2012 sold out immediately, and more than fifty million have been shipped all over the world in the years since. These boards have found their way into homes, classrooms, offices, data centres, factories, and even self-piloting boats and satellites.

    Various models of Raspberry Pi have been released since the original Model B, each bringing either improved specifications or features specific to a particular use-case. The Raspberry Pi Zero family, for example, is a tiny version of the full-size Raspberry Pi which drops a few features — in particular the multiple USB ports and wired network port — in favour of a significantly smaller layout and reduced power requirements.

    All Raspberry Pi models have one thing in common, though: they’re compatible, meaning that most software written for one model will run on any other model. It’s even possible to take the very latest version of Raspberry Pi’s operating system and run it on an original pre-launch Model B prototype. It will run more slowly, it’s true, but it will still run.

    Throughout this book you’ll learn about Raspberry Pi 4 Model B, Raspberry Pi 5, Raspberry Pi 400, and Raspberry Pi Zero 2 W: the latest and most powerful versions of Raspberry Pi. Everything you learn can be easily applied to other models in the Raspberry Pi family, so don’t worry if you’re using a different model or revision.

    RASPBERRY PI 400

    If you have a Raspberry Pi 400, the circuit board is built into the keyboard case. Read on to learn about all the components that make Raspberry Pi tick, or skip to Raspberry Pi 400 for a tour of your desktop device.

    RASPBERRY PI ZERO 2 W

    If you have a Raspberry Pi Zero 2 W, some of the ports and components look different when compared to the Raspberry Pi 5. Read on to learn about what each component does, or skip to Raspberry Pi Zero 2 W to learn more about your device.

    A guided tour of Raspberry Pi

    Unlike a traditional computer, which hides its inner workings in a case, a standard Raspberry Pi has all its components, ports, and features out on display — although you can buy a case to provide extra protection, if you’d prefer. This makes it a great tool for learning about what the various parts of a computer do, and also makes it easy to learn what goes where when it comes time to plug in the various other pieces of hardware — known as peripherals — you’ll need to get started.

    Figure 1-1 shows a Raspberry Pi 5 from above. When you’re using a Raspberry Pi with this book, try to keep it oriented the same way as in the pictures; otherwise it can get confusing when it comes to using things like the GPIO header (detailed in Chapter 6, Physical computing with Scratch and Python).

    Figure 1-1: Raspberry Pi 5

    GPIO header

    Wireless

    RAM

    RP1 I/O controller chip

    Connector for fan

    USB 2.0

    USB 3.0

    Ethernet port

    Power-over-Ethernet (PoE) pins

    CSI/DSI camera/display port 0

    CSI/DSI camera/display port 1

    Micro HDMI 1

    Connector for UART serial port

    System-on-chip

    Micro HDMI 0

    Real-time clock battery header

    USB Type-C power in

    Power button

    Connector for PCI Express (PCIe)

    While it may look like there’s an overwhelming amount packed into such a tiny board, a Raspberry Pi is very simple to understand — starting with its components, the inner workings that make the device tick.

    Raspberry Pi’s components

    Like any computer, Raspberry Pi is made up of many components, each of which has a role to play in making it work. The first, and arguably most important, of these can be found just to the left of the centre point of the board (Figure 1-2), covered in a metal cap: this is the system-on-chip (SoC).

    The name ‘system-on-chip’ is a great indicator of what you would find if you prised the metal cover off: a silicon chip, known as an integrated circuit, that contains the bulk of Raspberry Pi’s system. This integrated circuit includes a central processing unit (CPU), commonly thought of as the ‘brain’ of a computer, and a graphics processing unit (GPU), which handles the visual rendering and display output side of things.

    A brain is no good without memory, however, and just above the SoC you’ll find exactly that: a small, black, plastic-covered rectangular chip (Figure 1-3). This is Raspberry Pi’s random-access memory (RAM). When you’re working on Raspberry Pi, it’s the RAM that holds what you’re doing. Saving your work moves this data to the more permanent storage of the microSD card. Together, these components form Raspberry Pi’s volatile and non-volatile memory: the volatile RAM loses its contents whenever Raspberry Pi loses power, while the non-volatile memory in the microSD card keeps its contents.

    Figure 1-2: Raspberry Pi’s system-on-chip (SoC)

    Figure 1-3: Raspberry Pi’s random access memory (RAM)

    At the top left of the board you’ll find another metal lid (Figure 1-4) covering the radio, the component that Raspberry Pi the ability to communicate with devices wirelessly. In fact, the radio itself fills the role of two other common components: a WiFi radio that connects to computer networks; and a Bluetooth radio that connects to peripherals like mice and sends or receives data from nearby smart devices like sensors or smartphones.

    Another black, plastic-covered chip marked with the Raspberry Pi logo can be found on the right side of the board, near the USB ports (Figure 1-5). This is RP1, a custom I/O controller chip which communicates with the four USB ports, the Ethernet port, and most low-speed interfaces to other hardware.

    Figure 1-4: Raspberry Pi’s radio module

    Figure 1-5: Raspberry Pi’s RP1 controller chip

    Another black chip, smaller than the rest, can be found a little bit above the USB C power connector at the bottom left of the board (Figure 1-6). This is known as a power management integrated circuit (PMIC); it takes the power that comes in from the USB C port and turns it into the power your Raspberry Pi needs to run.

    The final black chip, below RP1 and positioned at a jaunty angle, helps the RP1 in handling Raspberry Pi’s Ethernet port. It provides what is known as an Ethernet PHY, providing the physical interface which sits between the Ethernet port itself and the Ethernet controller in the RP1 chip.

    Figure 1-6: Raspberry Pi’s power management integrated circuit (PMIC)

    Don’t worry if this seems like a lot to take in: you don’t need to know what each component is or where to find it on the board in order to use Raspberry Pi.

    Raspberry Pi’s ports

    Raspberry Pi has a range of ports, starting with four Universal Serial Bus (USB) ports (Figure 1-7) at the middle and top of its right-hand edge. These ports let you connect any USB-compatible peripheral — like keyboards, mice, digital cameras, and flash drives — to your Raspberry Pi. Speaking technically, there are two types of USB ports on Raspberry Pi, each relating to a different Universal Serial Bus standard: the ones with black plastic inside are USB 2.0 ports and the ones with blue plastic are newer and faster USB 3.0 ports.

    Next to the USB ports is an Ethernet port, also known as a network port (Figure 1-8). You can use this port to connect your Raspberry Pi to a wired computer network with a cable that uses what is known as an RJ45 connector. If you look closely at the Ethernet port, you’ll see two light-emitting diodes (LEDs) at the bottom. These are status lights which, when lit or blinking, let you know the connection is working.

    Figure 1-7: Raspberry Pi’s USB ports

    Figure 1-8: Raspberry Pi’s Ethernet port

    Just to the left of the Ethernet port, on the bottom edge of Raspberry Pi, is a Power-over-Ethernet (PoE) connector (Figure 1-9). This connector, when paired with the Raspberry Pi 5 PoE+ HAT Hardware Attached on Top, a special add-on board designed for Raspberry Pi — and a suitable PoE-capable network switch, lets you power Raspberry Pi from its Ethernet port without having to connect anything to the USB Type-C connector. The same connector is also available on Raspberry Pi 4, though in a different location; Raspberry Pi 4 and Raspberry Pi 5 use different HATs for PoE support.

    Directly to the left of the PoE connector are a pair of strange-looking connectors with plastic flaps you can pull up; these are the camera and display connectors, also known as the Camera Serial Interface (CSI) and Display Serial Interface(DSI) ports (Figure 1-10).

    Figure 1-9: Raspberry Pi’s Power-over-Ethernet connector

    Figure 1-10: Raspberry Pi’s camera and display connectors

    You can use these connectors to connect a DSI-compatible display like the Raspberry Pi Touchscreen Display or the specially designed Raspberry Pi Camera Module family (see Figure 1-11). You’ll learn more about camera modules in Chapter 8, Raspberry Pi Camera Modules. Either port can act as a camera input or display output so you can have two CSI cameras, two DSI displays, or one CSI camera and one DSI display running on a single Raspberry Pi 5.

    To the left of the camera and display connectors, still on the bottom edge of the board, are the micro High Definition Multimedia Interface (micro HDMI) ports, which are smaller versions of the connectors you can find on a games console, set-top box, or TV (Figure 1-12). The ‘multimedia’ part of its name means that it carries both audio and video signals, while ‘high-definition’ means you can expect excellent quality from both signals. You’ll use these micro HDMI ports to connect Raspberry Pi to one or two display devices, such as a computer monitor, TV, or projector.

    Figure 1-11: Raspberry Pi’s camera module

    Figure 1-12: Raspberry Pi’s micro HDMI ports

    Between the two micro HDMI ports is a small connector labelled ‘UART,’ which provides access to a Universal Asynchronous Receiver-Transmitter (UART) serial port. You won’t use that port in this book, but you may need it in the future for communicating with, or troubleshooting, more complex projects.

    To the left of the micro HDMI ports is another small connector labelled ‘BAT’, where you can connect a small battery to keep Raspberry Pi’s real-time clock (RTC) ticking, even when it’s disconnected from its power supply. You don’t need to connect a battery to use Raspberry Pi, though, since it will automatically update its clock when turned on, so long as it has access to the internet.

    At the bottom left of the board is a USB C power port (Figure 1-13), used to provide Raspberry Pi with power through a compatible USB C power supply. The USB C port is a common sight on smartphones, tablets, and other portable devices. While you could use a standard mobile charger to power your Raspberry Pi, for best results you should use the official Raspberry Pi USB-C Power Supply: it’s better at coping with the sudden changes in power requirements that can occur when your Raspberry Pi is working particularly hard.

    At the left edge of the board is a small button facing outwards. This is Raspberry Pi 5’s new power button, used to safely shut down your Raspberry Pi when you’re finished with it. This button is not available on Raspberry Pi 4, or older boards.

    Above the power button is another connector (Figure 1-14), which, at

    Enjoying the preview?
    Page 1 of 1