官术网_书友最值得收藏!

Preface

Thank you for picking the Raspberry Pi Zero Cookbook! In this book, we explore the awesome potential of what this $5 computer can deliver. With a Raspberry Pi Zero and a few accessories, you have your hands on a miniature computer that has the same functionality, applications, and connectivity that you would get with a system costing hundreds or thousands of dollars.

The cookbook starts with introducing the Raspberry Pi Zero and its operating system and shows ways that make the Raspberry Pi Zero unique in the Raspberry Pi family, aside from being the only one that will fit in a mint tin. From there, we move right into operating system control and simple programming, predominantly in Python. For many, this will be a revisit, though I did make every recipe as useful as possible, and almost everything in the first few chapters will be possible with just a Raspberry Pi Zero and typical accessories you would need for a computer. I've truly made every attempt not to Hello World you to death, with a few scripts you can sink your teeth into.

Once we get through installation, configuration, and some basic programming, we will begin to learn the Raspberry Pi Zero’s GPIO Interface and how you would get it to interact with the physical world. Here is where you’ll play with sensors, motors, and controllers so you can ultimately monitor or alert anything to anyone, wherever they are.

As a cookbook, it is intended to have each recipe possible to create without anything else. There are some recipes that are helpful or provide prerequisites to later recipes, but for the most part, with the ingredients listed, you can get right to creating whatever interests you the most. If you are more of a beginner, the recipes should be iterative, in that each recipe is similar but a bit more challenging that the last. In the end, you'll see that there are some very common patterns, and even the more seemingly complex solutions use the same simple concepts consistently with respect to the GPIO Interface.

Electronics, sensors, and motors can add up in cost rather quickly. Some of the recipes do have specific boards I’ve used for the recipe, but in the hardware and software section, I’ve also found some kits with most of what the cookbook uses, and only for the cost of about maybe 10 Raspberry Pi Zeroes.

I hope you enjoy the book and have enough fun that you end up with Raspberry Pi Zeroes to share; for friends and kids, just starting with computers is the most inspiring part of the $5 computer. If every kid can get their hands on one, we will soon see the days of flying cars and Star Trek replicators. I hope this book introduces enough concepts to open the doors to immensely more creative and interesting ideas than any recipe in this book.

What this book covers

Chapter 1, Kick-Start Your Raspberry Pi Zero, starts right out of the box and covers what you’ll need to get your Raspberry Pi running. Then we install and configure the operating system.

Chapter 2, Setting Up Physical and Wireless Connections , covers the many ways you can communicate with your Raspberry Pi Zero, how to get it on your home network, and USB configurations that make the Raspberry Pi Zero unique to its siblings.

Chapter 3, Programming with Linux, goes over some of the useful things to know when using a Linux operating system. From basic filesystem operation to application installation and upgrades, this will provide a set of tools you will find necessary for using your Raspberry Pi Zero.

Chapter 4, Programming with Python, begins with a brief introduction of Python and its major versions, and must-have libraries when using Python and a Raspberry Pi. From there, we move on to creating a solution that monitors, graphs, and notifies Raspberry Pi Zero board temperatures over time.

Chapter 5, Getting Your Hands Dirty Using the GPIO Header, gets into some basic hardware and usage of the versatile General Purpose Input Output (GPIO) interface. We’ll explore the different GPIO modes and methods of communication, using a variety of languages and tools.

Chapter 6, Controlling the LEDs and Displays, starts with more advanced LED exercises and moves on to the control and operation of LED matrices, LCD displays, and controllers for operating several LEDs inpidually.

Chapter 7, Controlling the Hardware, shows how easy it is to control motors, relays, and buzzers. It also touches on more advanced circuitry to control high-voltage systems from your Raspberry Pi. More advanced electrical experience is needed for some of these recipes.

Chapter 8, Taking Digital Inputs to the RPZ, moves into receiving inputs from external devices for the Raspberry Pi Zero to detect. We also cover receiving triggers and data from devices: RFID scanners, GPS boards, and more!

Chapter 9, Interfacing Sensors with RPZ, pes deeper into the options for receiving sensor data on the Raspberry Pi Zero. At this point, there shouldn’t be a device available that you can’t have your Raspberry Pi Zero talk to.

Chapter 10, Cooking Up Projects to Amaze the World!, wraps up with bringing home automation and monitoring to your Raspberry Pi Zero to centralize all of the sensor inputs and monitors to one place.

If you go through the chapters completely, my hope is that you will have ideas for dozens of projects where these recipes are only a component of your larger solution. I also hope that it will get you more involved in the Raspberry Pi community and its immense wealth of shared ideas and that you’ll be telling your friends about how they need to get their hands on one (and an extra for your birthday!).

What you need for this book

The operating system used in this book is the open source Raspbian, designed specifically for the Raspberry Pi family of computers.

Pretty much any part in this book, outside of common components such as resistors and capacitors, is available through Adafruit. Adafruit sells high-quality components and boards that are great for all kinds of Internet of Things and maker projects. Purchasing each piece inpidually can add up fast; fortunately, sites such as Amazon offer some great kits that are perfect for beginners. The Elegoo Most Complete Ultimate Starter Kit is the one I used. It costs around $60 US and includes most of the sensors, displays, and motors used in this cookbook as well as common components, such as a breadboard, jumper wires, power supplies, LEDs, resistors, and capacitors. It is a great way to get started! Everything marked with an asterisk (*) is something that is included in the Elegoo kit. In the specific recipes, I will reference the equivalent Adafruit part if available.

Hardware requirements

  • Raspberry Pi Zero
  • 5V/1.2 A micro USB power supply
  • Micro USB–OTG adapter
  • 4-port powered USB hub
  • Micro HDMI to standard HDMI adapter and a standard HDMI cable; alternatively, a standard HDMI to micro HDMI cable
  • Micro SD card, 4 GB or greater (8 GB recommended)
  • USB keyboard and mouse: I used the Logitech MK270, a wireless keyboard/mouse combo that uses a single USB port.
  • HDMI-compatible monitor
  • Another computer and slot or adapter to write SD card images
  • Raspberry Pi Cobbler and a breadboard: Adafruit has a great one, though there are a few alternatives
  • Jumper cables
  • USB-to-serial port adapter
  • USB Wi-Fi adapter
  • Standard-to-micro USB cable
  • Standard LEDs, various colors*
  • RGB 4-lead LED*
  • Two 4xAA battery packs and batteries
  • Adafruit SI4713 FM radio transmitter
  • Adafruit ESP8266 Wi-Fi module
  • Seven-segment LED display*
  • 8X8 LED matrix display*
  • 16x2 LCD display*
  • 74HC595N shift register*
  • Various resistors*
  • Various electrolytic and ceramic capacitors*
  • P222N transistors*
  • 5V mechanical (“sugar cube”) relay*
  • Stepper motor*
  • DC motor*
  • Piezo buzzer*
  • Adafruit bidirectional level shifter
  • PiFace Digital Revision 2 shield
  • Push switches*
  • Toggle switches
  • Sixteen-digit keypad*
  • Real-time clock board with battery*
  • RFID scanner board*
  • Adafruit Ultimate GPS breakout board
  • Photoresistor*
  • Ultrasonic sensor*
  • Adafruit MCP3008 8-channel 10-bit analog-to-digital convertor
  • Infrared receiver and remote*
  • Motion sensor*
  • Temperature and humidity sensor*
  • Gyroscope/accelerometer*
  • Heart rate/pulse sensor (via Adafruit or www.pulsesensor.com, which I used)

Who this book is for

This book is for programmers and hobbyists who are eager to pe deep into the Raspberry Pi Zero. If you have basic or zero knowledge of the Raspberry Pi Zero or if you're looking for examples of ways to utilize the Raspberry Pi’s GPIO interface, then this book is ideal for you. Basic knowledge of Python will be beneficial, and experience with circuitry and electronics will be needed for the later chapters in the book.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "As you can see, /dev/disk2s6 and /dev/disk2s1 were added. This creates two partitions on disk2 -- most SD cards will only have one, but however many there are mounted, you need to unmount them with diskutil."

A block of code is set as follows:

@app.route('/update_pin', methods=['POST'])
def update_pin():
        #Read in form entry. Since they are all buttons, you should only get

Any command-line input or output is written as follows:

$ sudo diskutil eject /dev/rdisk2 
Disk /dev/rdisk2 ejected

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Just click on Download ZIP from a browser, and it will automatically begin."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail feedback@packtpub.com, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors .

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Raspberry-Pi-Zero-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/ . Check them out!

Downloading the color images of this book 

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/RaspberryPiZeroCookbook_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at questions@packtpub.com, and we will do our best to address the problem.

主站蜘蛛池模板: 浦北县| 青神县| 黄冈市| 大竹县| 竹溪县| 永宁县| 高阳县| 吴川市| 噶尔县| 天祝| 安图县| 太保市| 建始县| 五指山市| 衡南县| 巴中市| 古浪县| 白城市| 甘南县| 简阳市| 叶城县| 嘉祥县| 宕昌县| 冕宁县| 嘉黎县| 宁安市| 界首市| 平潭县| 泗水县| 布尔津县| 福建省| 安仁县| 和硕县| 墨脱县| 武川县| 南丹县| 渭南市| 民权县| 罗城| 南溪县| 雷州市|