Book Image

Learning Raspberry Pi

By : Samarth Shah, Serge Schneider
Book Image

Learning Raspberry Pi

By: Samarth Shah, Serge Schneider

Overview of this book

Table of Contents (14 chapters)
Learning Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The Raspberry Pi is an affordable, credit card-sized computer developed by the Raspberry Pi Foundation as a response to the decline in the number of applicants for computer science courses at the University of Cambridge. Eben Upton, the founder of the Raspberry Pi Foundation, believes that the current generation of children do not have as many opportunities to discover their interests in programming as his did. His generation grew up with computers such as the BBC Micro, Commodore 64, and the ZX Spectrum, all of which booted into a programming environment. The current generation of devices, on the other hand, is geared towards consuming content, rather than creating it. Although the Raspberry Pi makes an excellent home theater computer and retro gaming device, it is primarily designed to be a tool to learn programming. For this reason, the Foundation provides a version of the Raspbian operating system with preinstalled development tools and learning material, making it easy to get started.

When the Raspberry Pi was launched, it showed itself to be more popular than the designers could have imagined as the ten thousand units that were manufactured were sold out within minutes and the distributor websites were brought down by the unexpected load on their servers. In the first year, the Raspberry Pi Foundation has sold over a million units and attracted a community of hackers and makers passionate about teaching and learning. This includes the official forum (accessible at http://www.raspberrypi.org/forums/), where you can ask questions or share your project; the IRC channel on Freenode, where you can chat and get live support; the wiki hosted by eLinux (accessible at http://elinux.org/RPi_Hub), where you can find tutorials; and all the information you need to get started and the plethora of other websites dedicated to add-ons and accessories for the Raspberry Pi.

The Raspberry Pi may seem like a replacement for a low-end desktop, and the powerful GPU makes it a handy media center capable of playing HD videos. However, its true value comes from its flexibility. The General Purpose Input/Output (GPIO) pins allow the Raspberry Pi to be used for a wide variety of applications. Home automation, weather stations, industrial control, robotics, arcade gaming cabinets, and quadcopters are just some of the possibilities.

As a constant stream of exciting projects built around the Raspberry Pi surfaces all over the Internet, you may find yourself getting interested in seeing what you can do with your Raspberry Pi. This book aims to provide all of the tools you will need to turn an idea into a working prototype.

What this book covers

Chapter 1, Getting Started with Raspberry Pi, teaches you about different operating systems, alternative installation methods, and how to set up your own web server running WordPress.

Chapter 2, Developing Web Applications, takes you into HTML, CSS, JavaScript, and Python and teaches you to develop your own web application to stream music from your Raspberry Pi anywhere in the world.

Chapter 3, Introduction to Electronics, teaches everything you need to get started with electronics, even if you have not touched a soldering iron before. This chapter provides an introduction to the laws of electronics to basic components, common circuits, and prototyping methods. In this chapter, you will learn how to build a math alarm clock with an e-mail notification.

Chapter 4, Getting into Robotics, introduces you to building a remote-controlled rover, capable of driving around within the Wi-Fi coverage and streaming back videos and sensor data.

Chapter 5, Introduction to Image Processing, takes you into the world of image processing, understand the basics. After developing a time-lapse video using the Raspberry Pi camera, you will learn to build a Twitter-controlled Raspberry Pi camera.

Chapter 6, Image Processing Algorithms, introduces you to image processing algorithms. This chapter will also teach you to build and run widely run machine learning examples such as object detection and face detection.

Chapter 7, Troubleshooting, Tips/Tricks, and Resources for Advanced Users, solves common problems and shows ways the Raspberry Pi can be modified to make it more robust and stable. Find out why some SD cards do not work and how to make them work, why the Raspberry Pi resets when certain USB devices are plugged in, and how to make it an issue of the past.

What you need for this book

Throughout this book, it is assumed that you have a Raspberry Pi with the required peripherals and that you are able to install and boot an operating system using NOOBS or RAW images. Additionally, you should have some exposure to Linux and familiarity with general programming concepts. The later chapters deal with electronics, and to get the most out of them, you will need to acquire some common components.

Who this book is for

This book is written for computer literate adults coming from a Linux, PC, or Mac desktop and wishing to learn how to create things with the Raspberry Pi. The book does not dwell on easily accessible information, but does not assume expert knowledge in any particular field either. Thus, it is accessible and engaging to anyone interested in the Raspberry Pi.

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: "Now, type startx to load the familiar UI."

A block of code is set as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Hello world</title>
</head>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

def fileclick(req):
  if 'id' not in req.form:
return listloc(session['currdir'])
  clickedfile = safe_join(session['currdir'], req.form['id'])
if path.isfile(clickedfile):
    clickedfile = url_for('static',
    filename = clickedfile.replace(app.static_folder+'/',''))
return clickedfile
return 0

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

# dd if=file.img of=/dev/mmcblk0 bs=4M

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: "Finally, click Write and remove the card."

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 , 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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

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/2820OS_GraphicBundle.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 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 , and we will do our best to address the problem.