ebook img

Raspberry Pi PDF

403 Pages·2015·32.34 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Raspberry Pi

No one likes a know-it-all. Most of us realize there’s no such thing— About the Author how could there be? The world is far too complicated for someone to understand everything there is to know. So when you come across Thorin Klosowski is a lifelong DIYer who has taken apart more electronics a know-it-all, you smile to yourself as they ramble on because you than he’s put back together. Currently, he’s a full-time writer for the how-to know better. site Lifehacker (lifehacker.com), where he writes about various electronics projects, Apple software, productivity, and the merging of health with You understand that the quest for knowledge is a never-ending one, technology. Prior to that, his writing appeared in a variety of publications, and you’re okay with that. You have no desire to know everything, just including The Onion’s The A.V. Club and HowStuffWorks. His productivity the next thing. You know what you don’t know, you’re confident enough tips and articles have been featured on NBC News, NPR, Business Insider, to admit it, and you’re motivated to do something about it. The Huffington Post, and others. At Idiot’s Guides, we, too, know what we don’t know, and we make it our business to find out. We find really smart people who are experts in their fields and then we roll up our sleeves and get to work, asking lots of questions and thinking long and hard about how best to pass along their knowledge to you in the easiest, most-accessible way possible. After all, that’s our promise—to make whatever you want to learn “As Easy as It Gets.” That means giving you a well-organized design that seamlessly and effortlessly guides you from page to page, topic to topic. It means controlling the pace you’re asked to absorb new information— not too much at once but just what you need to know right now. It means giving you a clear progression from easy to more difficult. It means giving you more instructional steps wherever necessary to really explain the details. And it means giving you fewer words and more illustrations wherever it’s better to show rather than tell. So here you are, at the start of something new. The next chapter in your quest. It can be an intimidating place to be, but you’ve been here before and so have we. Clear your mind and turn the page. By the end of this book, you won’t be a know-it-all, but your world will be a little less complicated than it was before. And we’ll be sure your journey is as easy as it gets. Mike Sanders Publisher, Idiot’s Guides Raspberry Pi™ by Thorin Klosowski A member of Penguin Random House LLC ALPHA BOOKS IDIOT’S GUIDES and Design are trademarks of Penguin Random House LLC Published by Penguin Random House LLC International Standard Book Number: 978-1-61564-778-1 Penguin Random House LLC, 375 Hudson Street, New Library of Congress Catalog Card Number: 2014957361 York, New York 10014, USA · Penguin Random House LLC (Canada), 90 Eglinton Avenue East, Suite 700, Toronto, 17 16 15 8 7 6 5 4 3 2 1 Ontario M4P 2Y3, Canada (a division of Pearson Penguin Interpretation of the printing code: The rightmost number of Canada Inc.) · Penguin Books Ltd., 80 Strand, London the first series of numbers is the year of the book’s printing; WC2R 0RL, England · Penguin Ireland, 25 St. Stephen’s the rightmost number of the second series of numbers is the Green, Dublin 2, Ireland (a division of Penguin Books Ltd.) number of the book’s printing. For example, a printing code · Penguin Random House LLC (Australia), 250 Camberwell of 15-1 shows that the first printing occurred in 2015. Road, Camberwell, Victoria 3124, Australia (a division of Pearson Australia Group Pty. Ltd.) · Penguin Books India Printed in the United States of America Pvt. Ltd., 11 Community Centre, Panchsheel Park, New Delhi—110 017, India · Penguin Random House LLC (NZ), Note: This publication contains the opinions and ideas of 67 Apollo Drive, Rosedale, North Shore, Auckland 1311, its author. It is intended to provide helpful and informative New Zealand (a division of Pearson New Zealand Ltd.) · material on the subject matter covered. It is sold with Penguin Books (South Africa) (Pty.) Ltd., 24 Sturdee Avenue, the understanding that the author and publisher are not Rosebank, Johannesburg 2196, South Africa · Penguin Books engaged in rendering professional services in the book. If the Ltd., Registered Offices: 80 Strand, London WC2R 0RL, reader requires personal assistance or advice, a competent England professional should be consulted. The author and publisher specifically disclaim any responsibility for any liability, Copyright © 2015 by Penguin Random House loss, or risk, personal or otherwise, which is incurred LLC as a consequence, directly or indirectly, of the use and application of any of the contents of this book. All rights reserved. No part of this book may be reproduced, Most Alpha books are available at special quantity discounts scanned, or distributed in any printed or electronic form for bulk purchases for sales promotions, premiums, fund- without permission. Please do not participate in or encourage raising, or educational use. Special books, or book excerpts, piracy of copyrighted materials in violation of the author’s can also be created to fit specific needs. For details, write: rights. Purchase only authorized editions. No patent liability Special Markets, Alpha Books, 375 Hudson Street, New is assumed with respect to the use of the information York, NY 10014. contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of information contained herein. For information, address Alpha Books, 6081 E. 82nd Street, 4th Floor, Indianapolis, IN 46250. Publisher: Mike Sanders Cover Designer: Laura Merriman Associate Publisher: Billy Fields Book Designer: William Thomas Senior Acquisitions Editor: Brook Farling Indexer: Brad Herriman Development Editorial Supervisor: Christy Wagner Layout: Brian Massey Production Editor: Jana M. Stefanciosa Proofreader: Laura Caddell Contents Part 1 Getting Started with Your Raspberry Pi ...............................1 1 Introducing the Raspberry Pi ....................................................3 The Single-Board Computer ...................................................................................................................4 Raspberry Pi Hardware ..............................................................................................................................5 The Raspberry Pi Foundation ................................................................................................................6 How the Raspberry Pi Came to Be .....................................................................................................7 The Pi’s Original Purpose .........................................................................................................................8 Initial Technology and Design .................................................................................................................9 The Launch of the Raspberry Pi ...........................................................................................................10 What’s Next for the Raspberry Pi ......................................................................................................10 2 Choosing a Raspberry Pi ..........................................................13 The Different Models ................................................................................................................................14 The Model A+ ................................................................................................................................................16 Model A+ Hardware Specifications ....................................................................................................16 Model A+ Ports and Connectors ..........................................................................................................17 The Model B ....................................................................................................................................................18 Model B Hardware Specifications ........................................................................................................19 Model B Ports and Connectors ..............................................................................................................19 The Model B+ ................................................................................................................................................20 Model B+ Hardware Specifications ....................................................................................................20 Model B+ Ports and Connectors...........................................................................................................21 The Model 2 .....................................................................................................................................................22 Model 2 Hardware Specifications ........................................................................................................22 Model 2 Ports and Connectors ...............................................................................................................23 Which Model Is for You?..........................................................................................................................23 What Do You Want to Do? .....................................................................................................................23 Pros and Cons of Models B, B+, and 2 ..............................................................................................24 Price and Availability .................................................................................................................................25 3 Required Accessories ...............................................................27 Powering Your Raspberry Pi .................................................................................................................28 Amperage and Voltage Requirements....................................................................................................28 Finding a Power Adapter .........................................................................................................................28 SD Cards .............................................................................................................................................................29 The “Hard Drive” for Your Pi ..............................................................................................................29 Recommended SD Cards ...........................................................................................................................29 Composite and HDMI Options ..............................................................................................................30 Connecting to PC Monitors Versus HD TVs ...................................................................................31 iv Idiot’s Guides: Raspberry Pi Sound Output ..................................................................................................................................................31 Connecting to the Internet .....................................................................................................................32 On-Board Ethernet ....................................................................................................................................32 Wi-Fi Adapters ............................................................................................................................................33 4 Picking a Case ............................................................................35 Project-Based Cases ....................................................................................................................................36 The Best All-Purpose Cases ....................................................................................................................36 All-in-One Computer Cases ....................................................................................................................37 Cases for Outdoor Use ...............................................................................................................................38 DIY Cases ..........................................................................................................................................................38 LEGO Cases .................................................................................................................................................38 Wood Cases ....................................................................................................................................................39 Cardboard Cases ..........................................................................................................................................39 Part 2: Setting Up Your Raspberry Pi ..............................................41 5 What You Need for Setup .......................................................43 Personal Computer ......................................................................................................................................44 HDMI or Composite-Enabled Monitor or TV ..........................................................................44 USB Keyboard and Mouse ......................................................................................................................45 Internet Connectivity .................................................................................................................................45 SD Cards and Readers ...............................................................................................................................46 6 Ports, Pins, and Plug-Ins ..........................................................49 Ports and Pinouts ..........................................................................................................................................50 Raspberry Pi Ports .....................................................................................................................................50 Raspberry Pi Pinouts ................................................................................................................................51 GPIO Pin Locations ..................................................................................................................................52 Connecting Equipment .............................................................................................................................55 Adding Accessories ......................................................................................................................................55 Plugging In ...................................................................................................................................................56 Connecting the SD Card ..........................................................................................................................56 Powering On ................................................................................................................................................56 7 Selecting an Operating System .............................................59 An Introduction to Linux ........................................................................................................................60 Why the Raspberry Pi Uses Linux ....................................................................................................61 Open-Source Ideology................................................................................................................................61 Why Windows and OS X Don’t Work ...............................................................................................61 Contents v Linux Distributions for the Raspberry Pi .....................................................................................62 Raspbian .........................................................................................................................................................62 Arch Linux ....................................................................................................................................................63 Debian.............................................................................................................................................................63 Raspbmc, XBian, and OpenELEC ........................................................................................................64 Specialized Distributions.........................................................................................................................65 Why Raspbian Is Best ................................................................................................................................66 8 Installing Linux ...........................................................................69 Downloading Raspbian .............................................................................................................................70 Installing Raspbian on Your SD Card..............................................................................................70 Booting Up ........................................................................................................................................................72 Configuring Raspbian ................................................................................................................................73 Configuring Raspbian for Full Storage ...............................................................................................73 Configuring Raspbian for Full-Screen ................................................................................................73 Establishing Keyboard Layout ................................................................................................................73 Changing Your Password ........................................................................................................................73 Setting Your Time Zone ..........................................................................................................................73 Configuring Raspbian for Boot-to-Desktop .......................................................................................74 Logging In for the First Time ..............................................................................................................74 Accessing the Raspi-Config Tool ...........................................................................................................74 Launching Raspbian Manually ............................................................................................................74 Getting Acquainted with Raspbian ...................................................................................................75 Learning the Raspbian Interface ...........................................................................................................76 Preinstalled Applications .........................................................................................................................77 Desktop Utilities ..........................................................................................................................................78 Getting and Installing New Applications .....................................................................................78 Shopping the Pi Store ................................................................................................................................79 Finding Applications Manually ............................................................................................................80 9 Working with the Command Line .........................................83 Getting to Know the Command Line..............................................................................................84 The Command Line and Raspbian ......................................................................................................85 Accessing the Command Line in Raspbian ........................................................................................85 Basic Command Line Tools You Need to Know ......................................................................86 Sudo .................................................................................................................................................................86 Navigating Files and Folders from the Command Line ................................................................87 Downloading and Installing Programs from the Command Line .............................................88 Other Common Commands ......................................................................................................................89 vi Idiot’s Guides: Raspberry Pi Editing Text Files from the Command Line ..............................................................................90 Loading a Text File....................................................................................................................................90 Navigating, Editing, and Saving Files ...............................................................................................90 Part 3: Raspberry Pi Projects ...........................................................93 10 Building a Useable PC ..............................................................95 Making Raspbian More Windows-Like .........................................................................................96 Simple Adjustments ....................................................................................................................................97 Windows 7 or 8 ...........................................................................................................................................98 Changing the Wallpaper ...........................................................................................................................99 Popular Software You Need ................................................................................................................101 Web Browsers .............................................................................................................................................101 Office Productivity Tools .......................................................................................................................101 Video and Music Players .......................................................................................................................103 Antivirus Tools .........................................................................................................................................104 11 Adding Wi-Fi ............................................................................105 The Convenience of Wi-Fi ..................................................................................................................106 USB Wi-Fi Adapters ...............................................................................................................................106 Choosing the Right Adapter ...................................................................................................................108 Where to Buy Your Adapter..................................................................................................................108 Getting Online ............................................................................................................................................109 Setting Up Wi-Fi with Raspbian’s Graphical Interface .............................................................109 Setting Up Wi-Fi with the Command Line ....................................................................................110 Testing Your Connectivity ....................................................................................................................111 Troubleshooting ...........................................................................................................................................111 Manually Finding and Installing Drivers ......................................................................................112 Fixing Common Drop-Out Issues .......................................................................................................113 12 Making a Media Center.............................................................115 Raspberry Pi–Powered Media Center Capabilities ..............................................................116 Streaming Content from the Web ........................................................................................................116 Playing Movies and Music from Your Home Network ..............................................................116 Attaching External Storage to Your Pi .............................................................................................117 Raspberry Pi Media Center Limitations .........................................................................................117 Raspberry Pi Media Center Options..............................................................................................117 Raspbmc ........................................................................................................................................................118 OpenELEC ..................................................................................................................................................119 XBian ............................................................................................................................................................120 Media Center Operating System Pros and Cons...........................................................................121 Contents vii Installing Raspbmc ....................................................................................................................................122 Downloading and Installing Raspbmc ..............................................................................................122 The First Run ............................................................................................................................................124 Configuring Raspbmc .............................................................................................................................126 Adjusting Resolution ................................................................................................................................126 Setting Up Local Network Playback Options .................................................................................127 The Risks and Rewards of Overclocking ..........................................................................................128 XBMC Add-Ons and Repositories..................................................................................................129 Browsing the Add-On Repositories.....................................................................................................129 Installing Add-Ons ..................................................................................................................................130 Popular Plug-Ins ......................................................................................................................................132 Remote Controls .........................................................................................................................................132 Raspbmc-Supported Remotes.................................................................................................................132 Smartphone as Remote ............................................................................................................................133 13 Setting Up a Personal VPN ....................................................135 What Is a VPN? ............................................................................................................................................137 Security and Encryption ........................................................................................................................137 Why Use a VPN? ......................................................................................................................................138 An Introduction to OpenVPN ...........................................................................................................139 Setting Up Your At-Home VPN ......................................................................................................140 Changing Your Home Network for a VPN .....................................................................................140 Logging in to Your Home Router ........................................................................................................140 Assigning Your Raspberry Pi a Static Internal IP Address .....................................................142 Assigning Your Raspberry Pi a Static External IP Address via Dynamic DNS .............143 Other Dynamic DNS Options .............................................................................................................145 Preparing Your Raspberry Pi for OpenVPN ............................................................................146 Installing Raspbian ..................................................................................................................................146 Changing Your Default Password ......................................................................................................146 Installing SSH for Remote Connectivity...........................................................................................146 Connecting to Your Raspberry Pi Remotely ....................................................................................147 Installing OpenVPN on Your Raspberry Pi .............................................................................148 Downloading OpenVPN ........................................................................................................................148 Generating Your Security Keys ...........................................................................................................149 Generating Your Security Certificates .............................................................................................149 Building the Key Exchange ....................................................................................................................152 Writing the OpenVPN Configuration File ......................................................................................152 Setting Up Your Raspberry Pi’s Firewall ........................................................................................154 Configuring Keys for Each Client .......................................................................................................156 Terminal Commands to Start and Stop the VPN ........................................................................159 viii Idiot’s Guides: Raspberry Pi Installing OpenVPN on Your Computer ....................................................................................160 Setting Up Security Keys and Config Files...............................................................................161 Connecting to Your Pi VPN Remotely .......................................................................................162 Establishing a Connection .....................................................................................................................163 Accessing Files and Folders Remotely .................................................................................................163 14 Creating a Streaming Internet Radio ...................................165 What Can a Pi-Powered Internet Radio Do? ...........................................................................166 Internet Radio in Home Theater Setups ..........................................................................................166 Support for Pandora, Spotify, Google Music, and Others ..........................................................166 Installing Pi MusicBox ............................................................................................................................167 Preparing Your SD Card for a Pi MusicBox Image ...................................................................167 Changing Your Pi MusicBox Settings .............................................................................................168 Connecting to External Audio ..............................................................................................................169 Booting Pi MusicBox ..............................................................................................................................170 Using Pi MusicBox ..................................................................................................................................170 Playing Music Remotely from Your Smartphone or Computer ................................................171 Installing Pianobar for Pandora .........................................................................................................172 Downloading Pianobar to Your Pi ....................................................................................................172 Setting Up Pianobar and Logging in to Pandora .........................................................................174 Remote Control via SSH or the Command Line ...................................................................175 Setting Up a Static IP Address and SSH ........................................................................................175 Setting Up SSH .........................................................................................................................................176 Keyboard Controls for Pianobar ..........................................................................................................177 Adding Better-Quality Sound with a USB Sound Card ....................................................178 Choosing the Right USB Sound Card ................................................................................................179 Setting Up and Installing a USB Sound Card ..............................................................................179 15 Building a Private Minecraft Server ......................................181 What You Get with a Minecraft Server ......................................................................................182 Getting to Know Minecraft ...................................................................................................................182 Minecraft Versus a Server ....................................................................................................................184 Installing Raspbian....................................................................................................................................184 Configuring Raspbian with Optimal Minecraft Settings ..........................................................185 Setting Up SSH .........................................................................................................................................186 Installing Java ...............................................................................................................................................187 Why You Need Java ...............................................................................................................................187 Downloading and Installing Java .....................................................................................................188

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.