1. Why This Book?
This book developed out of a need for an in-depth work about the Raspberry Pi that just didnt seem to exist. If I had found one, I would have gladly purchased it. A quick survey revealed a large number of how to get started books. But I pined for something with the kind of meat that appeals to engineering types. Give me numbers, formulas, and design procedures.
Almost all of that information is available out there on the Internet somewhere . But I discovered that some questions take considerable time to research. If you know exactly where to look, the answer is right there. But if youre just starting out with the Raspberry Pi, you have several online Easter-egg hunts ahead of you. How much is your time worth?
Heres a short sample of some of the questions answered in this book:
How much current can a general purpose input/output (GPIO) port source or sink?
What is the resistance of the GPIO internal pull-up/pull-down resistor?
Which GPIO does the 1-Wire interface use?
What is the GPIO voltage range for a 0 bit or 1 bit?
How do you budget the GPIO power?
Some of these questions have simple answers, while others require an it depends explanation. You might be wondering why you need to know the internal GPIO pull-up resistance. discusses this in connection with motor driver interfaces and what happens at boot time. A number of questions arise when you start designing interfaces to the outside world. While you may not aspire to be an electronics engineer, it helps to think like one.
Who Needs This Book?
This is an important question and the answer, of course, depends on what you are looking for. So lets cut to the chase. This book is
Not an easy how to get started book (These are plentiful.)
Not a book about Scratch, Python, or Ruby programming
Not a download package X, configure it, and install it thusly book
Not a media server or retro games console handbook
Not a book on how to use or administer Linux
This book is targeted to those who have the following:
A college/university level or hobbyist interest
Some exposure to Linux (Raspbian Linux)
Some exposure to the C programming language
Some exposure to digital electronics
This Book Is Primarily About
In very broad terms, this book can be described primarily as follows:
A Raspberry Pi hardware reference, with software exploration
An electronics interfacing projects book, exploring the hardware and software to drive it
In a nutshell, it is a reference and projects book for the Raspberry Pi. The reference coverage is extensive compared to other offerings. A considerable section of the book is also dedicated to projects. I believe that this combination makes it one of the best choices for a book investment.
An ever-increasing number of interface boards can be purchased for the Pi, and the choices increase with each passing month. However, this book takes a bare metal approach and does not use any additional extender/adapter board solutions. You can, of course, use them, but they are not required.
This text also uses a poor student approach, using cheap solutions that can be purchased as Buy It Now sales on eBay. These then are directly interfaced to the GPIO pins, and I discuss the challenges and safety precautions as required. This approach should also meet the needs of the hobbyist on a limited budget.
You should have a beginning understanding of the C programming language to get the most out of the software presented. Since the projects involve electronic interfacing, a beginning understanding of digital electronics is also assumed. The book isnt designed to teach electronics, but some formulas and design procedures are presented.
Even those with no interest in programming or electronics will find the wealth of reference material in this book worth owning. The back of the book contains a bibliography for those who want to research topics further.
Learning Approach
Many times a construction article in a magazine or a book will focus on providing the reader with a virtual kit . By this, I mean that every tool, nut and bolt, component, and raw material is laid out, which if properly assembled, will achieve the projects end purpose. This is fine for those who have no subject area knowledge but want to achieve that end result.
However, this book does not use that approach. The goal of this book is to help you learn how to design solutions for your Rasbperry Pi. You cannot learn design if youre not allowed to think for yourself! For this reason, I encourage the substitution of parts and design changes. Considerable effort is expended in design procedure. This book avoids a here is exactly how you do it approach that many online projects use.
I explain the challenges that must be reviewed, and how they are evaluated and overcome. One simple example is the 2N2222A transistor driver (see ), where the design procedure is provided. If you choose to use a different junk box transistor, you can calculate the base resistor needed, knowing its H FE (or measured on a digital multimeter). I provide a recipe of sorts, but you are not required to use the exact same ingredients.
In some cases, a project is presented using a purchased assembled PCB driver. One example (in ) is the ULN2003A stepper motor driver PCB that can be purchased from eBay for less than $5 (free shipping). The use of the PCB is entirely optional, since this single-chip solution can be breadboarded. The PCB, however, offers a cheap, ready-made solution with LED indicators that can be helpful in developing the solution. In many cases, the assembled PCB can be purchased for about the same price as the components themselves. Yet these PCB solutions dont rob you of the interface design challenge that remains. They simply save you time.
It is intended that you, the reader, not use the presented projects as exact recipes to be followed. Use them as guidelines . Explore them as presented first if you like, but do not be afraid to substitute or alter them in some way. By the time you read this book, some PCBs used here may no longer be available. Clever eBay searches for chip numbers may turn up other manufactured PCB solutions. The text identifies the kind of things to watch out for, like unwanted pull-up resistors and how to locate them.
By all means, change the presented software! It costs nothing to customize software. Experiment with it. The programs are purposely provided in a raw form. They are not meant to be deployed as finished solutions. They are boiled down as much as possible to be easily read and understood. In some cases, error checking was removed to make the code more readable. All software provided in this book is placed in the public domain with no restrictions. Mold it to your needs.
If you follow the projects presentedor better, try them allyoull be in a good position to develop new interface projects of your own design. Youll know what questions to ask and how to research solutions. Youll know how to interface 3-volt logic to 5-volt logic systems. Youll know how to plan for the state of the GPIO outputs as the Raspberry Pi boots up, when driving external circuits. Experience is the best teacher.