Muutke küpsiste eelistusi

Raspberry Pi Cookbook, 4E: Software and Hardware Problems and Solutions 4th edition [Pehme köide]

  • Formaat: Paperback / softback, 650 pages
  • Ilmumisaeg: 31-Dec-2022
  • Kirjastus: O'Reilly Media
  • ISBN-10: 1098130928
  • ISBN-13: 9781098130923
  • Pehme köide
  • Hind: 63,19 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Tavahind: 74,34 €
  • Säästad 15%
  • Raamatu kohalejõudmiseks kirjastusest kulub orienteeruvalt 2-4 nädalat
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Tellimisaeg 2-4 nädalat
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 650 pages
  • Ilmumisaeg: 31-Dec-2022
  • Kirjastus: O'Reilly Media
  • ISBN-10: 1098130928
  • ISBN-13: 9781098130923

If you've started to work with Raspberry Pi, you know that Raspberry Pi's capabilities are continually expanding. The fourth edition of this popular cookbook provides more than 200 hands-on recipes (complete with code) that show you how to run this tiny low-cost computer with Linux, program it with Python, hook it up to sensors and motors, and use it with the internet of things (IoT). This new edition includes new chapters on the Raspberry Pi Pico and machine learning with the Raspberry Pi.

These easy-to-use recipes will show you, step-by-step, how to:

  • Set up your Raspberry Pi and connect to a network
  • Work with its Linux-based operating system
  • Program your Raspberry Pi with Python
  • Give your Pi "eyes" with computer vision
  • Recognize objects from video and sounds using machine learning
  • Control hardware through the GPIO connector
  • Use your Raspberry Pi to run different types of motors
  • Work with switches, keypads, and other digital inputs
  • Use sensors to measure temperature, light, and distance
  • Connect to IoT devices in various ways and automate your home
  • Use the Raspberry Pi Pico microcontroller board with your Raspberry Pi

Preface to the Fourth Edition xv
1 Setup and Management
1(40)
1.0 Introduction
1(1)
1.1 Selecting a Model of Raspberry Pi
1(5)
1.2 Connecting the System
6(2)
1.3 Enclosing a Raspberry Pi
8(3)
1.4 Selecting a Power Supply
11(3)
1.5 Selecting an Operating System
14(1)
1.6 Installing an Operating System Using Raspberry Pi Imager
14(3)
1.7 Booting Up Your Raspberry Pi for the First Time
17(2)
1.8 Setting Up a Headless Raspberry Pi
19(3)
1.9 Booting from a Real Hard Disk or USB Flash Drive
22(2)
1.10 Connecting a DVI or VGA Monitor
24(1)
1.11 Using a Composite Video Monitor/TV
24(2)
1.12 Adjusting the Picture Size on Your Monitor
26(3)
1.13 Maximizing Performance
29(2)
1.14 Changing Your Password
31(1)
1.15 Shutting Down Your Raspberry Pi
32(2)
1.16 Installing the Raspberry Pi Camera Module
34(3)
1.17 Using Bluetooth
37(4)
2 Networking
41(26)
2.0 Introduction
41(1)
2.1 Connecting to a Wired Network
41(2)
2.2 Finding Your IP Address
43(2)
2.3 Setting a Static IP Address
45(2)
2.4 Setting the Network Name of a Raspberry Pi
47(3)
2.5 Setting Up a Wireless Connection
50(2)
2.6 Connecting with a Console Lead
52(4)
2.7 Controlling the Pi Remotely with SSH
56(2)
2.8 Controlling the Pi Remotely with VNC
58(3)
2.9 Using a Raspberry Pi for Network-Attached Storage
61(3)
2.10 Setting Up a Network Printer
64(3)
3 Operating System
67(50)
3.0 Introduction
67(1)
3.1 Browsing Files Graphically
67(2)
3.2 Copying Files onto a USB Flash Drive
69(2)
3.3 Starting a Terminal Session
71(2)
3.4 Navigating the Filesystem Using a Terminal
73(3)
3.5 Copying a File or Folder
76(2)
3.6 Renaming a File or Folder
78(1)
3.7 Editing a File
78(2)
3.8 Viewing the Contents of a File
80(1)
3.9 Creating a File Without Using an Editor
81(1)
3.10 Creating a Directory
82(1)
3.11 Deleting a File or Directory
82(2)
3.12 Performing Tasks with Superuser Privileges
84(1)
3.13 Understanding File Permissions
85(1)
3.14 Changing File Permissions
86(2)
3.15 Changing File Ownership
88(1)
3.16 Making a Screen Capture
89(1)
3.17 Installing Software with apt
90(1)
3.18 Removing Software Installed with apt
91(1)
3.19 Installing Python Packages with pip3
92(1)
3.20 Fetching Files from the Command Line
93(1)
3.21 Fetching Source Code with Git
94(2)
3.22 Fetching This Book's Accompanying Code
96(2)
3.23 Running a Program Automatically on Startup
98(1)
3.24 Running a Program Automatically as a Service
99(2)
3.25 Running a Program Automatically at Regular Intervals
101(1)
3.26 Finding a File
102(1)
3.27 Using the Command-Line History
103(1)
3.28 Monitoring Processor Activity
104(3)
3.29 Working with File Archives
107(1)
3.30 Listing Connected USB Devices
108(1)
3.31 Redirecting Output from the Command Line to a File
108(1)
3.32 Concatenating Files
109(1)
3.33 Using Pipes
109(1)
3.34 Hiding Output to the Terminal
110(1)
3.35 Running Programs in the Background
111(1)
3.36 Creating Command Aliases
112(1)
3.37 Setting the Date and Time
112(1)
3.38 Finding Out How Much Room You Have on the SD Card
113(1)
3.39 Finding Out What Operating System Version You Are Running
114(1)
3.40 Updating Raspberry Pi OS
115(2)
4 Using Ready-Made Software
117(22)
4.0 Introduction
117(1)
4.1 Making a Media Center
117(2)
4.2 Installing Recommended Software
119(2)
4.3 Using Office Software
121(2)
4.4 Running a Vintage Game Console Emulator
123(2)
4.5 Turning Your Raspberry Pi into a Radio Transmitter
125(2)
4.6 Editing Bitmap Images
127(1)
4.7 Editing Vector Images
128(1)
4.8 Using Bookshelf
129(2)
4.9 Playing Internet Radio
131(1)
4.10 Using Visual Studio Code
132(1)
4.11 Controlling a Laser Cutter
133(6)
5 Python Basic
139(34)
5.0 Introduction
139(1)
5.1 Deciding Between Python 2 and Python 3
139(1)
5.2 Choosing a Python Editor
140(1)
5.3 Editing Python Programs with Thonny
141(1)
5.4 Editing Python Programs with Mu
142(6)
5.5 Using the Python Console
148(2)
5.6 Running Python Programs from the Terminal
150(1)
5.7 Assigning Names to Values (Variables)
151(1)
5.8 Displaying Output
152(1)
5.9 Reading User Input
153(1)
5.10 Using Arithmetic Operators
154(1)
5.11 Creating Strings
155(1)
5.12 Concatenating (Joining) Strings
156(1)
5.13 Converting Numbers into Strings
157(1)
5.14 Converting Strings into Numbers
157(1)
5.15 Finding the Length of a String
158(1)
5.16 Finding the Position of One String Within Another
159(1)
5.17 Extracting Part of a String
160(1)
5.18 Replacing One String of Characters with Another Within a String
161(1)
5.19 Converting a String to Uppercase or Lowercase
161(1)
5.20 Running Commands Conditionally (if)
162(2)
5.21 Comparing Values
164(1)
5.22 Using Logical Operators
165(1)
5.23 Repeating Instructions an Exact Number of Times
166(1)
5.24 Repeating Instructions Until Some Condition Changes
167(1)
5.25 Breaking Out of a Loop
167(1)
5.26 Defining a Function in Python
168(5)
6 Python Lists and Dictionaries
173(16)
6.0 Introduction
173(1)
6.1 Creating a List
173(1)
6.2 Accessing Elements of a List
174(1)
6.3 Finding the Length of a List
175(1)
6.4 Adding Elements to a List
175(1)
6.5 Removing Elements from a List
176(1)
6.6 Creating a List by Parsing a String
177(1)
6.7 Iterating Over a List
178(1)
6.8 Enumerating a List
179(1)
6.9 Testing if Something Is in a List
180(1)
6.10 Sorting a List
180(1)
6.11 Cutting Up a List
181(1)
6.12 Using Comprehensions
182(2)
6.13 Creating a Dictionary
184(1)
6.14 Accessing a Dictionary
185(1)
6.15 Removing Entries from a Dictionary
186(1)
6.16 Iterating Over Dictionaries
187(2)
7 Advanced Python
189(36)
7.0 Introduction
189(1)
7.1 Formatting Numbers
189(2)
7.2 Formatting Dates and Times
191(1)
7.3 Returning More Than One Value
192(1)
7.4 Defining a Class
193(2)
7.5 Defining a Method
195(1)
7.6 Inheritance
196(1)
7.7 Writing to a File
197(1)
7.8 Reading from a File
198(1)
7.9 Using Pickling to Save and Load Data in a File
199(1)
7.10 Handling Exceptions
200(2)
7.11 Using Modules
202(1)
7.12 Generating Random Numbers
203(1)
7.13 Making Web Requests from Python
204(1)
7.14 Specifying Command-Line Arguments in Python
205(1)
7.15 Running Linux Commands from Python
206(1)
7.16 Sending Email from Python
207(3)
7.17 Writing a Simple Web Server in Python
210(2)
7.18 Doing Nothing in Python
212(1)
7.19 Doing More Than One Thing at a Time
213(1)
7.20 Parsing JSON Data
214(2)
7.21 Saving Dictionaries as JSON Files
216(1)
7.22 Creating User Interfaces
217(2)
7.23 Using Regular Expressions to Search for Patterns in Text
219(2)
7.24 Using Regular Expressions to Validate Data Entry
221(1)
7.25 Using Regular Expressions for Web Scraping
222(3)
8 Computer Vision
225(14)
8.0 Introduction
225(1)
8.1 Installing OpenCV
225(1)
8.2 Setting Up a USB Camera for Computer Vision
226(2)
8.3 Using a Raspberry Pi Camera Module for Computer Vision
228(1)
8.4 Counting Coins
229(3)
8.5 Face Detection
232(3)
8.6 Motion Detection
235(3)
8.7 Extracting Text from an Image
238(1)
9 Machine Learning
239(20)
9.0 Introduction
239(1)
9.1 Identifying Objects in Video with TensorFlow Lite
240(2)
9.2 Reacting to Objects in Video with TensorFlow Lite
242(2)
9.3 Identifying Sounds with TensorFlow Lite
244(2)
9.4 Reacting to a Whistle with TensorFlow Lite
246(2)
9.5 Installing Edge Impulse
248(1)
9.6 Recognizing a Spoken Command (in the Cloud)
249(5)
9.7 Recognizing a Spoken Command (Locally)
254(3)
9.8 Responding to a Spoken Command in Python
257(2)
10 Hardware Basics
259(32)
10.0 Introduction
259(1)
10.1 Finding Your Way Around the GPIO Connector
259(3)
10.2 Using the GPIO Connector on a Raspberry Pi 400
262(2)
10.3 Keeping Your Raspberry Pi Safe When Using the GPIO Connector
264(1)
10.4 Setting Up I2C
265(2)
10.5 Using I2C Tools
267(2)
10.6 Setting Up SPI
269(1)
10.7 Installing pySerial for Access to the Serial Port from Python
270(1)
10.8 Installing Minicom to Test the Serial Port
271(2)
10.9 Using a Breadboard with Jumper Leads
273(1)
10.10 Using a Raspberry Squid
274(2)
10.11 Using a Raspberry Squid Button
276(2)
10.12 Converting 5V Signals to 3.3V with Two Resistors
278(1)
10.13 Converting 5V Signals to 3.3V with a Level Converter Module
279(1)
10.14 Powering a Raspberry Pi with a LiPo Battery
280(2)
10.15 Getting Started with the Sense HAT
282(1)
10.16 Getting Started with the Explorer HAT Pro
283(2)
10.17 Making a HAT
285(3)
10.18 Using the Raspberry Pi Zero 2 and Pi Zero 2 W
288(3)
11 Controlling Hardware
291(26)
11.0 Introduction
291(1)
11.1 Connecting an LED
291(3)
11.2 Leaving the GPIO Pins in a Safe State
294(1)
11.3 Controlling the Brightness of an LED
295(3)
11.4 Switching a High-Power DC Device Using a Transistor
298(2)
11.5 Switching a High-Power Device Using a Relay
300(3)
11.6 Switching Using a Solid-State Relay
303(1)
11.7 Controlling High-Voltage AC Devices
304(2)
11.8 Controlling Hardware with Android and Bluetooth
306(3)
11.9 Making a User Interface to Turn Things On and Off
309(1)
11.10 Making a User Interface to Control PWM Power for LEDs and Motors
310(1)
11.11 Making a User Interface to Change the Color of an RGB LED
311(3)
11.12 Using an Analog Meter as a Display
314(3)
12 Motors
317(26)
12.0 Introduction
317(1)
12.1 Controlling Servomotors
318(4)
12.2 Controlling Servomotors Precisely
322(3)
12.3 Controlling Multiple Servomotors Precisely
325(2)
12.4 Controlling the Speed of a DC Motor
327(2)
12.5 Controlling the Direction of a DC Motor
329(4)
12.6 Using a Unipolar Stepper Motor
333(4)
12.7 Using a Bipolar Stepper Motor
337(2)
12.8 Using a Stepper Motor HAT to Drive a Bipolar Stepper Motor
339(4)
13 Digital Inputs
343(32)
13.0 Introduction
343(1)
13.1 Connecting a Push Switch
343(4)
13.2 Toggling with a Push Switch
347(1)
13.3 Using a Two-Position Toggle or Slide Switch
348(2)
13.4 Using a Center-Off Toggle or Slide Switch
350(3)
13.5 Debouncing a Button Press
353(1)
13.6 Using an External Pull-Up Resistor
354(2)
13.7 Using a Rotary (Quadrature) Encoder
356(3)
13.8 Using a Keypad
359(3)
13.9 Detecting Movement
362(2)
13.10 Adding GPS to the Raspberry Pi
364(3)
13.11 Intercepting Keypresses
367(1)
13.12 Intercepting Mouse Movements
368(2)
13.13 Giving the Raspberry Pi a Reset Button
370(5)
14 Sensors
375(56)
14.0 Introduction
375(1)
14.1 Using Resistive Sensors
375(4)
14.2 Measuring Light
379(2)
14.3 Measuring Temperature with a Thermistor
381(2)
14.4 Detecting Methane
383(3)
14.5 Measuring Air Quality (C02)
386(3)
14.6 Measuring Soil Moisture
389(2)
14.7 Measuring a Voltage
391(3)
14.8 Reducing Voltages for Measurement
394(3)
14.9 Using Resistive Sensors with an ADC
397(2)
14.10 Measuring Temperature with an ADC
399(2)
14.11 Measuring the Raspberry Pi CPU Temperature
401(1)
14.12 Measuring Temperature, Humidity, and Pressure with a Sense HAT
402(2)
14.13 Measuring Temperature Using a Digital Sensor
404(3)
14.14 Measuring Acceleration with an MMA8452Q Module
407(4)
14.15 Finding Magnetic North with the Sense HAT
411(1)
14.16 Using the Inertial Measurement Unit of the Sense HAT
412(2)
14.17 Sensing a Magnet with a Reed Switch
414(1)
14.18 Sensing a Magnet with the Sense HAT
415(1)
14.19 Measuring Distance Using Ultrasound
416(3)
14.20 Measuring Distance Using a Time-of-Flight Sensor
419(2)
14.21 Adding Touch Sensing to Your Raspberry Pi
421(2)
14.22 Reading Smart Cards with an RFID Reader/Writer
423(4)
14.23 Displaying Sensor Values
427(1)
14.24 Logging to a USB Flash Drive
428(3)
15 Displays
431(18)
15.0 Introduction
431(1)
15.1 Using a Four-Digit LED Display
431(3)
15.2 Displaying Graphics on an I2C LED Matrix
434(2)
15.3 Using the Sense HAT LED Matrix Display
436(2)
15.4 Using an OLED Graphical Display
438(3)
15.5 Using Addressable RGB LED Strips
441(3)
15.6 Using the Pimoroni Unicorn HAT
444(2)
15.7 Using an ePaper Display
446(3)
16 Sound
449(12)
16.0 Introduction
449(1)
16.1 Connecting a Loudspeaker
449(3)
16.2 Controlling Where Sound Is Output
452(1)
16.3 Playing Audio on a Raspberry Pi Without an Audio Socket
453(2)
16.4 Playing Sound from the Command Line
455(1)
16.5 Playing Sound from Python
456(1)
16.6 Using a USB Microphone
457(2)
16.7 Making a Buzzing Sound
459(2)
17 The Internet of Things
461(28)
17.0 Introduction
461(1)
17.1 Controlling GPIO Outputs Using a Web Interface
461(5)
17.2 Displaying Sensor Readings on a Web Page
466(4)
17.3 Getting Started with Node-RED
470(3)
17.4 Sending Email and Other Notifications with IFTTT
473(5)
17.5 Sending Tweets Using ThingSpeak
478(2)
17.6 Changing LED Color Using CheerLights
480(2)
17.7 Sending Sensor Data to ThingSpeak
482(3)
17.8 Responding to Tweets Using Dweet and IFTTT
485(4)
18 Home Automation
489(38)
18.0 Introduction
489(1)
18.1 Making a Raspberry Pi into a Message Broker with Mosquitto
489(3)
18.2 Using Node-RED with an MQTT Server
492(6)
18.3 Flashing a Sonoff WiFi Smart Switch for MQTT Use
498(5)
18.4 Configuring a Sonoff WiFi Smart Switch
503(3)
18.5 Using Sonoff Web Switches with MQTT
506(3)
18.6 Using Flashed Sonoff Switches with Node-RED
509(4)
18.7 Turning Things On and Off Using the Node-RED Dashboard
513(6)
18.8 Scheduling Events with Node-RED
519(2)
18.9 Publishing MQTT Messages from a Wemos D1
521(3)
18.10 Using a Wemos Dl with Node-RED
524(3)
19 Raspberry Pi Pico and Pico W
527(36)
19.0 Introduction
527(2)
19.1 Connecting a Pico or Pico W to a Computer
529(3)
19.2 Using the Python Shell on a Pico
532(2)
19.3 Using a Pico with a Breadboard
534(4)
19.4 Using Digital Outputs on a Pico
538(3)
19.5 Using Digital Inputs on a Pico
541(3)
19.6 Using Analog (PWM) Outputs on a Pico
544(1)
19.7 Using Analog Inputs on a Pico
545(3)
19.8 Controlling a Servomotor from a Pico
548(3)
19.9 Using the Pico and Pico W's Filesystem
551(2)
19.10 Making Use of the Second Core
553(2)
19.11 Running a WiFi Web Server on the Pico W
555(4)
19.12 Using Pico-Compatible Boards
559(2)
19.13 Using the Pico on Batteries
561(2)
A Parts and Suppliers 563(6)
B Raspberry Pi Pinouts 569(4)
Index 573
Simon Monk has a degree in Cybernetics and Computer Science and a PhD in Software Engineering. After spending many years in software and co-founding the mobile software company Momote, he now divides his time between writing books about electronics and programming and helping to run MonkMakes (monkmakes.com), a business he started with his wife Linda, designing electronic kits and accessories for the Raspberry Pi, BBC micro:bit and general electronics.