Raspberry Pi 5 Essentials
Program, build, and master over 60 projects with Python
Table of Contents
Preface
Chapter 1 • The Raspberry Pi 5
1.1 Overview
1.2 The Raspberry Pi 5
Chapter 2 • Installing the Raspberry Pi 5 Operating System
2.1 Overview
2.2 Using a pre-installed SD card
2.3 Larger font in Console mode
2.4 Accessing your Raspberry Pi 5 Console from your PC – the Putty program
2.4.1 Configuring Putty
2.5 Accessing the Desktop GUI from your PC
2.6 Assigning a static IP address to your Raspberry Pi 5
2.7 Enabling Bluetooth
2.8 Connecting the Raspberry Pi 5 to a wired network
2.8.1 Unable to connect to a wired network
2.9 Installing the Raspberry Pi 5 Bookworm operating system on a blank microSD card
Chapter 3 • Using The Console Commands
3.1 Overview
3.2 The Command Prompt
3.3 Useful Console commands
3.3.1 System and user information
3.3.2 The Raspberry Pi 5 directory structure
3.3.3 Resource monitoring on the Raspberry Pi 5
3.3.4 Shutting Down
3.3.5 Networking
3.3.6 System information and other useful commands
Chapter 4 • Desktop GUI – Desktop Applications
4.1 Overview
4.2 Desktop GUI Applications
4.2.1 Applications Menu
4.2.2 Web browser
4.2.3 File manager
4.2.4 Terminal
4.2.5 Manage Bluetooth devices
4.2.6 Wi-Fi
4.2.7 Volume control
4.2.8 Date and time
Chapter 5 • Using a Text Editor in Console Mode
5.1 nano text editor
5.2 vi text editor
Chapter 6 • Creating and Running a Python Program
6.1 Overview
6.2 Method 1 – Interactively from command prompt in console mode
6.3 Method 2 – Create a Python file in console mode
6.4 Method 3 – Create a Python file in Desktop GUI mode
6.5 Which method?
Chapter 7 • Python Programming and Simple Programs
7.1 Overview
7.2 Variable names
7.3 Reserved words
7.4 Comments
7.5 Line continuation
7.6 Blank lines
7.7 More than one statement on a line
7.8 Indentation
7.9 Python data types
7.10 Numbers
7.11 Strings
7.11.1 String functions
7.11.2 Escape sequences
7.12 Print statement
7.13 List variables
7.13.1 List functions
7.14 Tuple variables
7.15 Dictionary variables
7.15.1 Dictionary functions
7.16 Keyboard input
7.17 Comparison operators
7.18 Logical operators
7.19 Assignment operators
7.20 Control of flow
7.20.1 if, if...else, and elif
7.20.2 for statement
7.20.3 while statement
7.20.4 continue statement
7.20.5 break statement
7.20.6 pass statement
7.21 Example 1 – 4-Band resistor colour code identifier
7.22 Example 2 – Series or parallel resistors
7.23 Example 3 – Resistive potential divider
7.24 Trigonometric functions
7.25 User-defined functions
7.26 Examples
7.27 Recursive functions
7.28 Exceptions
7.29 try/final exceptions
7.31 Creating your own modules
Chapter 8 • Raspberry Pi 5 LED Projects
8.1 Overview
8.2 Raspberry Pi 5 GPIO pin definitions
8.3 Project 1 – Flashing an LED
8.4 Project 2 – Alternately flashing LEDs
8.5 Project 3 – Binary counting with 8 LEDs
8.6 Project 4 – Christmas lights (random flashing 8 LEDs)
8.7 Project 5 – Chasing LEDs
8.8 Project 6 – Rotating LEDs with push-button switch
8.9 Project 7 – Morse Code exerciser with LED or buzzer
8.10 Project 8 – Electronic dice
Chapter 9 • Using an I²C LCD
9.1 Overview
9.2 The I2C Bus
9.3 I2C pins of Raspberry Pi 5
9.4 Project 1 – Using an I2C LCD – Seconds counter
9.5 Project 2 – Using an I2C LCD – Display time
9.6 Project 3 – Using an I2C LCD – Display IP address of Raspberry Pi 5
9.7 Project 4 – Voltmeter – Output to the screen
9.8 Project 5 – Voltmeter – Output to LCD
9.9 Project 6 – Analog temperature sensor thermometer – output to the screen
9.10 Project 7 – Analog temperature sensor thermometer – output on LCD
9.11 Project 8 – Reaction timer – output to screen
9.12 Project 9 – Reaction timer – output to LCD
9.13 Project 10 – Automatic dusk lights
9.14 Project 11 – Ultrasonic distance measurement
9.15 Project 12 – Car parking sensors
9.16 Project 13 – Fading LED
9.17 Project 14 – Melody maker
Chapter 10 • Plotting Graphs with Python and Raspberry Pi 5
10.1 Overview
10.2 The Matplotlib graph plotting library
10.3 Project 1 – RC transient circuit analysis - Charging
10.4 Project 2 – RC transient circuit analysis - Discharging
10.5 Transient RL circuits
10.6 Project 3 – RCL transient circuit analysis
10.7 Project 4 – Temperature, pressure and humidity measurement – Display on the screen
10.8 Project 5 – Temperature, pressure and humidity measurement – Plotting the data
Chapter 11 • Waveform Generation Using the Digital-to-Analog Converter (DAC)
11.1 Overview
11.2 The MCP4921 DAC
11.3 Project 1 – Generating a square wave signal with any peak voltage up to +3.3 V
11.4 Project 2 – Generating a sawtooth wave signal
11.5 Project 3 – Generating a triangle wave signal
11.6 Project 4 – Generating an arbitrary wave signal
11.7 Project 5 – Generating a sine wave signal
Chapter 12 • Using the Sense HAT
12.1 Overview
12.2 The Sense HAT interface
12.3 Programming the Sense HAT
12.4 Project 1 – Displaying text on Sense HAT
12.5 Project 2 – Test your math skills - multiplication
12.6 Project 3 – Learning the times tables
12.7 Project 4 – Display the temperature, humidity, and pressure
12.8 Project 5 – ON-OFF temperature controller
12.9 Project 6 – Generate two dice numbers
12.10 Project 7 – Display the current time
12.11 Project 8 – Displaying two-digit integer numbers
12.12 Project 9 – Up counter
12.13 The inertial measurement sensor
12.13.1 Project 10 – Reading the acceleration
12.13.2 Project 11 – Accelerometer-based dice
12.13.3 Project 12 – Accelerometer-based LED shapes
Chapter 13 • Using a 4×4 Keypad
13.1 Overview
13.2 Project 1 – Using a 4×4 keypad
Chapter 14 • Communication over Wi-Fi
14.1 Overview
14.2 UDP and TCP
14.2.1 UDP communication
14.2.2 TCP communication
14.3 Project 1 – Sending a text message to a smartphone using TCP/IP
14.4 Project 2 – Two-way communication with the smartphone using TCP/IP
14.5 Project 3 – Communicating with a PC using TCP/IP
14.6 Project 4 – Controlling an LED connected to Raspberry Pi 5 from a smartphone using TCP/IP
14.7 Project 5 – Sending a text message to a smartphone using UDP
14.8 Project 6 – Controlling an LED connected to Raspberry Pi 5 from a smartphone using UDP
14.9 Communicating with the Raspberry Pi Pico W over Wi-Fi
14.9.1 Project 7 – Raspberry Pi 5 and Raspberry Pi Pico W communication – controlling a relay over Wi-Fi
14.10 Project 8 – Storing ambient temperature and atmospheric pressure data in the Cloud
Chapter 15 • Communication over Bluetooth
15.1 Overview
15.2 Project 1 – Exchanging text with a smartphone
15.3 Project 2 – Bluetooth control of LED from a smartphone
15.4 Arduino UNO Raspberry Pi 5 Bluetooth communication
15.4.1 Project 3 – Communicating with an Arduino UNO over Bluetooth
15.4.2 Project 4 – Play audio (e.g. music) on Bluetooth speaker via Raspberry Pi 5
Chapter 16 • Raspberry Pi 5 Camera Projects
16.1 Overview
16.2 Installing the Camera
16.3 Project 1 – Still camera commands
16.3.1 libcamera
16.4 Project 2 – Building a time-lapse camera – Who is in my parking place?
16.5 Project 3 – Video camera commands
16.6 Project 4 – Who is ringing my doorbell?
Index
About the Publication
This is an Elektor Publication. Elektor is the media brand of Elektor International Media B.V.
PO Box 11, NL-6114-ZG Susteren, The Netherlands
Phone: +31 46 4389444
All rights reserved. No part of this book may be reproduced in any material form, including photocopying, or storing in any medium by electronic means and whether or not transiently or incidentally to some other use of this publication, without the written permission of the copyright holder except in accordance with the provisions of the Copyright Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licencing Agency Ltd., 90 Tottenham Court Road, London, England W1P 9HE. Applications for the copyright holder's permission to reproduce any part of the publication should be addressed to the publishers.
Declaration
The author, editor, and publisher have used their best efforts in ensuring the correctness of the information contained in this book. They do not assume, and hereby disclaim, any liability to any party for any loss or damage caused by errors or omissions in this book, whether such errors or omissions result from negligence, accident or any other cause. All the programs given in the book are Copyright of the Author and Elektor International Media. These programs may only be used for educational purposes. Written permission from the Author or Elektor must be obtained before any of these programs can be used for commercial purposes.
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
ISBN 978-3-89576-586-5 Print
ISBN 978-3-89576-587-2 eBook
Copyright 2023: Elektor International Media B.V.
Editor: Clemens Valens
Prepress Production: D-Vision, Julian van den Berg
Print: Ipskamp Printing, Enschede (NL)
Elektor is the world's leading source of essential technical information and electronics products for pro engineers, electronics designers, and the companies seeking to engage them. Each day, our international team develops and delivers high-quality content - via a variety of media channels (including magazines, video, digital media, and social media) in several languages - relating to electronics design and DIY electronics. www.elektormagazine.com
Introduction to Raspberry Pi 5 Essentials
This book, "Raspberry Pi 5 Essentials," serves as a comprehensive guide for users looking to program, build, and master projects using the Raspberry Pi 5 with Python. It covers a wide range of topics, from the basic overview of the Raspberry Pi 5 to advanced project implementations.
The content is structured into 16 chapters, detailing:
- The Raspberry Pi 5 hardware and its features.
- Installation of the operating system and accessing the console and desktop GUI.
- Utilizing console commands for system management and networking.
- Exploring desktop applications like web browsers, file managers, and terminals.
- Working with text editors in the console mode (nano and vi).
- Creating and running Python programs, covering fundamental programming concepts, data types, control flow, and examples.
- Implementing various LED projects, including flashing LEDs, counting, and creating light effects.
- Interfacing with I2C LCD displays for various applications such as counters, time displays, and sensor readings.
- Generating waveforms using the Digital-to-Analog Converter (DAC).
- Utilizing the Sense HAT for projects involving text display, math skills, temperature, humidity, pressure, and games.
- Working with a 4x4 keypad for input.
- Establishing communication over Wi-Fi and Bluetooth, including smartphone integration and Arduino UNO communication.
- Developing camera projects for still images, time-lapses, and video.
The book aims to provide practical, hands-on experience with the Raspberry Pi 5, enabling users to build over 60 diverse projects.
Key Features and Projects
The Raspberry Pi 5 is a powerful single-board computer that offers extensive capabilities for learning and experimentation in electronics and programming. This guide focuses on leveraging its potential through Python programming.
Chapter 1: The Raspberry Pi 5
An overview of the Raspberry Pi 5 hardware, its specifications, and connectivity options.
Chapter 2: Installing the Raspberry Pi 5 Operating System
Guidance on setting up the Raspberry Pi OS, including SD card preparation, accessing the console via programs like PuTTY, and configuring network settings like static IP addresses and wired network connections.
Chapter 3: Using The Console Commands
An introduction to essential command-line interface (CLI) commands for managing the Raspberry Pi 5, including system information, directory navigation, resource monitoring, and networking commands.
Chapter 4: Desktop GUI – Desktop Applications
An exploration of the graphical user interface (GUI) and its applications, such as web browsing, file management, terminal usage, and managing Bluetooth and Wi-Fi connections.
Chapter 5: Using a Text Editor in Console Mode
Instructions on using text editors like `nano` and `vi` within the Raspberry Pi's console environment for editing code and configuration files.
Chapter 6: Creating and Running a Python Program
Methods for developing and executing Python scripts on the Raspberry Pi 5, covering interactive execution, creating Python files in both console and GUI modes.
Chapter 7: Python Programming and Simple Programs
A detailed dive into Python programming, including variable types, operators, control flow statements (if, for, while), functions, and handling exceptions. Several practical examples are provided.
Chapter 8: Raspberry Pi 5 LED Projects
Hands-on projects involving Light Emitting Diodes (LEDs), such as creating flashing patterns, binary counters, and decorative light sequences. This chapter also covers interfacing with push-button switches and buzzers.
Chapter 9: Using an I2C LCD
Projects focused on integrating I2C LCD displays with the Raspberry Pi 5 to show information like seconds counters, time, IP addresses, and sensor data (temperature, humidity, pressure). It also includes projects for creating voltmeters and reaction timers.
Chapter 10: Plotting Graphs with Python and Raspberry Pi 5
Utilizing the Matplotlib library to create various graphs and visualizations, including projects for analyzing RC and RCL circuits, and displaying environmental sensor data.
Chapter 11: Waveform Generation Using the Digital-to-Analog Converter (DAC)
Projects demonstrating the use of the MCP4921 DAC to generate different types of waveforms, such as square, sawtooth, triangle, and sine waves.
Chapter 12: Using the Sense HAT
Projects that leverage the Sense HAT, a versatile add-on board, for applications like displaying text, testing math skills, learning times tables, controlling temperature, and creating games using its sensors and joystick.
Chapter 13: Using a 4x4 Keypad
A project focused on integrating a 4x4 keypad with the Raspberry Pi 5 for user input.
Chapter 14: Communication over Wi-Fi
Projects exploring wireless communication, including sending messages to smartphones via TCP/IP and UDP, controlling LEDs remotely, and communicating with the Raspberry Pi Pico W.
Chapter 15: Communication over Bluetooth
Projects involving Bluetooth connectivity, such as exchanging text with smartphones, controlling LEDs remotely, and communicating with Arduino UNO boards.
Chapter 16: Raspberry Pi 5 Camera Projects
Projects utilizing the Raspberry Pi 5 camera module for capturing still images, creating time-lapse sequences, and recording video. This includes an introduction to the `libcamera` tool.
Elektor International Media B.V.
Elektor International Media B.V. is a global media company specializing in electronics. They provide essential technical information and products for engineers, designers, and hobbyists through various channels, including magazines, videos, and digital content. Their website is www.elektormagazine.com.
File Info : application/pdf, 9 Pages, 1.46MB
DocumentDocumentReferences
Your Store for Raspberry Pi, Arduino & ESP32 | Elektor
Elektor Magazine: Media & Learning | Elektor Magazine
Related Documents
![]() |
Raspberry Pi 5 Essentials: Program, Build, and Master Over 60 Projects with Python A comprehensive guide to the Raspberry Pi 5, covering setup, operating system installation, console commands, GUI applications, and over 60 hands-on Python projects. Learn to program, build, and master various applications with this powerful mini-computer. |
![]() |
The Official Raspberry Pi Beginner's Guide - Contents Explore the table of contents for The Official Raspberry Pi Beginner's Guide, covering essential topics from basic setup and programming in Scratch and Python to advanced hardware integration with Sense HAT and camera modules. |
![]() |
The MagPi Magazine Issue 140: Coding, Projects, and Raspberry Pi Guides Explore the latest issue of The MagPi magazine, featuring articles on coding with Raspberry Pi, DIY projects, tutorials for Python and MicroPython, hardware reviews, and success stories from the Raspberry Pi community. Learn about Raspberry Pi 5, Pico, and more. |
![]() |
Raspberry Pi Pico: Mehr als 50 Grundlagenprojekte mit MicroPython und dem RP2040-Mikrocontroller Ein umfassender Leitfaden für den Raspberry Pi Pico Mikrocontroller, der über 50 praktische Projekte mit MicroPython und dem RP2040-Chip vorstellt. Behandelt Hardware-Grundlagen, Programmierung, Sensoren, Kommunikationsprotokolle wie UART, I2C, SPI, sowie Wi-Fi- und Bluetooth-Anwendungen. |
![]() |
Das offizielle Raspberry Pi Handbuch: Projekte, Anleitungen und Reviews Entdecken Sie das Raspberry Pi 5 und Pico W mit diesem offiziellen Handbuch. Enthält detaillierte Projekte, praktische Anleitungen für MicroPython und KI, sowie Produkt-Reviews. |
![]() |
Raspberry Pi: Discover 45 Electronics Projects A comprehensive guide to exploring 45 electronics projects using the Raspberry Pi, covering hardware setup, software installation, programming, and various electronic components and protocols. Published by Elektor. |
![]() |
Raspberry Pi User Guide, 4th Edition by Eben Upton and Gareth Halfacree The Raspberry Pi User Guide, 4th Edition by Eben Upton and Gareth Halfacree provides comprehensive instructions for getting started with the Raspberry Pi, covering software installation, Linux basics, programming with Scratch and Python, hardware hacking, and customization. |
![]() |
The Official Raspberry Pi Handbook: Projects, Guides, and Reviews Explore the world of Raspberry Pi with this comprehensive handbook. Discover projects, tutorials, and reviews covering the Raspberry Pi 5, Pico W, and various accessories. Learn electronics, build handheld devices, and delve into AI applications. |