E-Book description:
Practical Raspberry Pi sounds more like a math book than something you voluntarily pick up to read for fun. Luckily for you, there will not be much math content and it will be fun. So what is Practical Raspberry Pi all about? It’s about simple day-to-day projects—ones that are fun, functional, and for everyone to do—for your Raspberry Pi. I would hope that you would have some idea of Linux; any distribution is okay and I will cover a few different operating systems in this book anyway. If you feel a little uncomfortable with Linux r the Raspberry Pi is your first Linux machine, I urge you to read over Peter Membrey’s Learn Raspberry Pi with Linux. I also hope you can tell the
hot end of a soldering iron from the cold end, even though you don’t need to be a soldering expert for the projects in this book. By now you should have at least one operating system installed on your Pi; if you don’t, not to worry because it will be one of your first tasks in this book. So what makes the Pi something you hunger for? Everyone loves cheap hardware and I love all hardware, no matter how old or obscure. The Pi is a very capable little machine; also for hardware projects, it’s not bad! You could get more on the hardware side out of an Arduino but the Pi offers something more than just hardware. It’s not just one slice of the computing world: it’s the whole pi. From hardware-level projects to software-level projects you have it all
in front of you with the Pi. So you have a world of opportunities. For example, you could carry around the Pi with you or set it up inside your house as an IP-enabled power switch. I have always liked to pull electronic things apart to see what’s inside them and how they work. Collecting assorted chips and other electronic junk seemed second nature to me; I had always pined for a computer of any sort as a child and when I finally did get one I just wanted to pull the case off it! Well, the Pi comes with no case so that’s not much of an issue. Even without a case to remove it’s a very exciting piece of hardware. Finally we have a cheap solution that can bridge the hardware and software gap that will take advantage of Linux. Given the Pi’s price, I hope you feel more willing to experiment with the software and hardware. Given this, I want to talk about how to approach the hardware and not feel worried about it. Don’t feel upset or
annoyed when things don’t work out. Hardware has a tendency not to work for the smallest reasons. You might have had a bad solder joint or soldered something in backward. You may think it sounds so silly, but it’s often the smallest things that trip you up. Here’s some personal experience to illustrate this point. Living in Hong Kong gives me access to cheap electronics and I’ve always wanted a Hakko soldering iron but back in Australia they are very expensive as they need to be imported from Japan. So recently I became the proud owner of a nice Hakko station and on that particular day I brought it home, unboxed it, and smiled at its majesty. I plugged it into the wall and broke out a test printed circuit board (PCB) I had lying around and waited for the unit to heat up. After some time I noticed it was not heating up. I tried everything to make it work: changing fuses and double checking everything, or so I thought. It was only when my wife walks in and asks why it was turned off that I glancedown at the small power switch on the unit to notice it was off. Sometimes it’s so simple you miss it! Take a step back and relax: your Pi will be fine. Most of the time things don’t work for me the first time; in fact I cannot recall when they ever do. This used to get on my nerves a lot and I would end up sitting there forcing myself to sort it out. I now know this is the wrong approach with electronics: you will make mistakes and you will let the magic smoke out!
E-Book Author:
Brendan Horan
E-Book Table of Contents:
About the Author…..xiii
About the Technical Reviewers…..xv
Acknowledgments…..xvii
Introduction…..xix
Chapter 1: Hardware Overview…..1
Pi In, Pi Out…..2
USB Port…..2
LAN Port…..3
CSI Header…..3
HDMI Port…..4
Power to the Pi!…..4
DSI Header…..4
SD Card Slot 5
GPIO Headers…..6
Analog Video Output…..8
JTAG Ports…..9
Audio Output…..9
LEDs…..9
Pi Brains…..9
Processor Pipeline…..11
Caches…..12
Memory Chips…..13
Power States…..13
Performance per Watt…..14
Pi Eyes…..14
What Happens at Power On?…..15
Pi on Your Face…..15
Summary…..16
Chapter 2: Installing Fedora…..17
Dissecting the Image…..18
Using the GUI Installer…..18
Using the Command Line…..19
Installing the Image on Windows…..20
Booting Your Pi…..21
Oh No, Goes Crash!…..21
Configure and Look Around…..22
Updating the Firmware and Operating System 26
Cutting Out the Fat…..28
Optimizing the SD Card…..28
Thinking About Swapping…..30
Optimizing CPU Cycles…..30
I/O Tuning…..31
Understanding the CFQ Scheduler…..32
Understanding the Noop Scheduler…..33
Changing the Scheduler…..34
Lighter Applications and Tools…..35
Summary…..35
Chapter 3: A Simple Temperature Sensor 37
Breadboards and GPIO Pins…..38
Sensors…..40
The Amazing 1-Wire Bus…..42
Building the Sensors…..44
Using the Little Black DS1820B…..45
Using the Big Blue DHT11…..51
Reading the DHT11 in Linux…..54
Scripting the Sensors…..58
Summary…..60
Chapter 4: Driving a Simple Character LCD 61
Pulling Apart the HD44780 and the Clones 62
Preparing the Hardware…..65
LCD Prep Work…..65
Shift Registers…..68
The I2C Bus…..68
Putting It All Together…..71
Finding Your I2C Device…..76
Software and LCD Clients…..78
Server Configuration…..79
Testing the Server 80
Running a Client…..81
Displaying Text…..82
Summary…..85
Chapter 5: Security Monitoring Device 87
Introduction to the PIR…..88
Introducing the Pressure Mat…..89
Assembling the Devices…..90
The Pressure Mat 91
Using the GPIO Pins…..93
A Script for Your Mat Status…..95
Connecting the PIR…..96
Bring Forth the WEBrick…..99
Welcome WEBrick…..99
The Security Application Code…..100
Running the Security Application…..102
Summary…..103
Chapter 6: Cross Compile Environment 105
Introducing Cross Compiling…..105
The Host…..107
Crosstool-NG…..107
Configuring crosstool-NG…..111
Your First Cross Compile 117
Cross Compiling with Dependencies 119
Optimization…..123
Summary…..124
Chapter 7: Mini Media Center 125
Why OpenELEC?…..126
Using the -Ofast Optimization…..126
Using the LTO…..126
Using Symbols as Needed…..127
Two Final Advantages…..127
Installing OpenELEC…..127
Decode Licenses…..130
The First Boot…..133
Setting the Date and Time…..135
Memory Allocation…..137
Screen Resolution and Display Settings…..137
Browser Access…..138
Remote Control Phone…..139
Summary…..143
Chapter 8: Adding an RTC…..145
The Beginning of the RTC in PCs…..146
The DS1338 RTC…..147
The Crystal…..147
Parts List and Assembly…..148
Soldering the Adapter Board 149
Making the Battery PCB…..151
Building the Circuit…..153
The Soft Side…..157
Summary…..162
Chapter 9: Serial Server…..163
What Exactly Is a Serial Console Anyway? 163
Serial Port, What Serial Port?…..164
Serially a Bit of a Letdown…..165
Finding the Pi’s Serial Port…..166
UARTs and Logic Shifters…..167
What Does a Logic-Level Shifter Do?…..167
Needed Hardware…..167
Building the Circuit…..168
The Power On…..171
Serial No Console…..174
Ser2net…..174
Summary…..177
Chapter 10: Controlling a Mains Device 179
Alternating Current…..180
Isolation Devices 180
The AC Mains Remote Control…..183
Putting the Circuit Together…..185
Dissecting the Remote Control…..185
Adding the Relays…..187
The Soft Side…..191
Using the GPIO Pins as Output…..191
Coding a Simulated Button Press…..192
Back to the WEBrick…..193
Summary…..199
Chapter 11: Other Operating Systems 201
Android…..202
A History of Android…..202
Android Considerations…..203
Installing Android…..203
Using Android…..204
RISC OS…..205
A History of RISC OS…..205
RISC OS Considerations…..205
Installing RISC OS…..207
Using RISC OS…..212
Plan 9…..215
A History of Plan 9…..215
Plan 9 Considerations…..215
Installing Plan9…..217
Using Plan 9…..220
Gentoo…..222
A History of Gentoo…..222
Gentoo Considerations…..222
Installing Gentoo…..224
Using Gentoo…..231
Summary…..231
Index…..233