Greetings. Thank you for purchasing this book Raspberry Pi 2: Raspberry Pi 2 Programming Made Easy. If you're reading this book then most likely you are here to learn about his nifty new little computer called the Raspberry Pi. In this book, we'll teach you everything that you need to know to get up and running with this little, but powerful computer.
We'll teach you about its parts, its specifications, setting up the operating system, its capabilities and limitations, and ultimately how to do basic programming. We'll discuss the best programming language that works best with the Raspberry Pi and create your first program with it. Without further ado, let's start your Raspberry Pi journey.
Chapter 1: Raspberry Pi The Basics
What is a Raspberry Pi?
So what is it exactly? We'll its a small credit-card sized single board computer that is intended to help people learn more about programming, how the computer works, etc. The CPU or Central Processing Unit is basically a system-on-a-chip. What that means is it pairs an ARM processor that is used by a lot of embedded systems and cellular phones with a Broadcom GPU (Graphics Processing Unit), which is a fairly powerful graphics processor that's capable of displaying full resolution 1080p HD video.
The amount of RAM (Random Access Memory) that the Raspberry Pi 2 has is 1 Gigabyte. Its previous iteration, the Raspberry Pi 1 Model A+ and Raspberry Pi 1 Model B has 256MB and 512MB RAM respectively. The RAM is shared by both the CPU and the GPU.
The Raspberry Pi 2 starts at $39.00 and that includes just the board. On the board there are 4 USB ports, 40 General Purpose Input/Output (GPIO) pins, a full 1080p HDMI port, a Network/Ethernet port, a 3.5mm audio and composite video jack, a Raspberry Pi (CSI) Camera interface, a Video (DSI) Display interface, a Micro SD card slot, and a VideoCore 3D graphics core. The GPIO is basically for more advanced users who are going to be adding Arduino accessory boards, ribbon cables for communication with other hardware devices, and major electronics projects; robotics, sensors, etc.
Why Is it Cool to Have a Raspberry Pi?
Most people think the Raspberry Pi is cool because it's a fairly complete computer, it runs on very little power, it's small, and it will not burn a hole through your wallet; it's $39.00, which is less than the cost that you would pay for a dinner with a friend or a loved one. The Raspberry Pi also helps people that are new to computer hardware get into it and get their hands dirty without the cost and risk associated with more expensive standard hardware.
Another thing that's cool about it is that the Graphics Processing Unit is pretty powerful. It can play 1080p HD video, which makes it really attractive to a lot of people as a Media Center PC. In fact, most people buy the Raspberry Pi 2 for that specific reason because it is a cheap multimedia PC.
What Can You Do With a Raspberry Pi?
So what can you do with this thing? Well, just like what was previously mentioned, if you're really new to computer hardware, the Pi can help you learn about those individual components of most modern computers. And if you want to learn how to do programming, the Raspbian operating system that comes with the Raspberry Pi 2 comes with a lot of tools for programming to help you get started.
So you might be asking, why wouldn't you start learning how to program with the computer that you already have? Well, you can. And that's perfectly fine. However, you can think of the Raspberry Pi as your little playground and your test computer that you don't have to worry about breaking if you screw something up. Even if you do break it, you'll only be losing $39.00.
But if you don't care about all that and you don't care about programming or about learning the hardware and so forth, the Raspberry Pi 2 also makes a really great little Media PC. You can get a small case for it, hook it up to the network, install another operating system that's based on Linux called OpenELEC, which is basically a back-end for XBMC (Xbox Media Center), plug it into your TV, and youre ready to start streaming video and audio content on your high-definition TV.
Chapter 2: Hardware Accessories
In this chapter, we're going to talk about some of the hardware and accessories that you're going to need to get started with the Raspberry Pi 2. First, let's start out with the bare necessities. The two things that you'll definitely need are power and an SD card.
Power Requirement
Let's take a moment here and talk about power because it's important. The Raspberry Pi is a little picky about its power source. Learning about what you need here for power could save you a lot of headache later down the road. The Raspberry Pi needs 5 volts. That should be anywhere between 4.75 volts minimum and a maximum of 5.25 volts. It should be at least 700 mAh, but the recommended is 1000 mAh.
The reason for the 1000 mAh recommended power is because when you start plugging in a keyboard, mouse, network cable, and other peripherals, these all pull power away from the system. This is also why some Raspberry Pi 2 users say that 1500 mAh to 2000 mAh is even better. Of course, if you're only doing projects close to your desktop computer and you don't really plan to run the Raspberry Pi 24/7, you could just run it off of your desktop system's power with just a USB cable if you want.
SD Card Storage
There is not on-board storage on the Raspberry Pi. So you need an SD card to run the operating system from and also to store any files. Get at least the Class 4 SD storage. It is recommended that you get the Class 6 or Class 10 if you don't mind spending a little bit more.
However, if it's not available, just get the best one that you can. The cost difference honestly isn't that much, and SD cards are getting cheaper all the time. You'll also need a card reader to transfer the operating system image that you're going to download off of Raspberry Pi's website from your desktop computer to the SD card. You can also buy SD cards with the operating system pre-installed from whosoever your Raspberry Pi vendor is if ever you want to skip the operating system installation on the Pi.
If you want to try out multiple operating systems, you can do that with a single card. However, just keep in mind that you'll overwrite any of your settings that you've played around with in the operating system.
Interacting With the Raspberry Pi
You'll need to decide on how you want to interact with your Raspberry Pi. You can either do it headless over a network, with a keyboard, mouse and monitor, or you can do a combination of both. For network access, you're going to need a network cable; either a CAT5e or CAT6 to connect to your router. There's also a USB WiFi option, which allows you to connect to your router wirelessly.
If you're going headless, you don't really need a USB keyboard and mouse. They are both optional. It just depends on what you want to use the Raspberry Pi for. Just like what was previously mentioned, if you don't want to use the desktop interface, you can skip using a mouse and just plug in a keyboard. If you're using it as a media center and navigate XBMC, a wireless Bluetooth keyboard is a fantastic option if you want to sit on your couch and navigate your media center.
If you're only planning to login remotely using SSH, you can skip the keyboard entirely, or if you want you can just borrow a keyboard and mouse from another machine for the initial setup before you actually go headless over the network. Raspberry Pi should automatically get an IP address from your router. After your router gives an IP address to your Pi, you can just log in to your router to see the exact IP address that was assigned. You can then connect via SSH using that IP address.