Over the last year the Raspberry Pi, a cheap credit-card sized computer, has taken the computing and DIY world by storm. Read on as we guide you through everything from buying to powering to running the tiny dynamo.
What Is the Raspberry Pi?
The Raspberry Pi is a credit-card sized general purpose Linux computer designed and manufactured by the Raspberry Pi Foundation, a non-profit organization dedicated to making computers and programming instruction as accessible as possible to the widest number of people.
Although the original mission of the Raspberry Pi project was to get inexpensive computers with programming capabilities into the hands of students, the Pi has been embraced by a diverse audience. Tinkers, programmers, and DIYers across the globe have adopted the tiny platform for projects ranging from recreating retro arcade cabinets to controlling robots to setting up cheap but powerful home media devices.
The Pi features a system-on-a-chip setup built around the Broadcom BCM2835 processor (a tiny but fairly powerful mobile processor commonly used in cellphones) that includes a CPU, GPU, audio/video processing, and other functionality all on a low-power chip.
Although the Pi is an amazing little device, before we proceed it’s important to emphasize what the Raspberry Pi is not. The Raspberry Pi is not an outright replacement for your desktop computer or laptop. You cannot run Windows on it (its ARM-based processor doesn’t support x86/x64 code), although you can run many distributions of Linux—including distributions with desktop environments, web browsers, and other elements you would expect in a desktop computer.
The Raspberry Pi is, however, an astoundingly versatile device that packs a lot of hardware into a very inexpensive body and is perfect for hobby electronics, DIY projects, setting up an inexpensive computer for coding/programming lessons and experiments, and other projects.
What’s On The Raspberry Pi Board?
The Raspberry Pi comes in two versions, Model A ($25) and Model B ($35). As the Model B—seen above—is the most popular model we’ll start by outlining what you’ll find onboard and then highlight the differences between the Model B and Model A.
What’s the Difference?
The Model B ships with the following hardware/ports:
- 700 Mhz Systems-On-a-Chip (SoC) with integrated 512MB RAM.
- 1 HDMI port for digital audio/video output
- 1 RCA video port for analog video output.
- 1 3.5mm stereo headphone jack for analog audio output.
- 2 USB ports for connecting input devices and peripheral add-ons.
- 1 SD card reader for loading the operating system.
- 1 Ethernet LAN port.
- 1 microUSB power port.
- 1 GPIO (General Purpose Input/Output) interface.
The Model A is identical save for the following modifications:
- 1 USB port instead of 2 USB ports.
- No Ethernet port (users must add a USB Wi-Fi or Ethernet adapter if they need network connectivity)
- 256MB RAM instead of 512MB (chipset otherwise the same)
What the heck is a GPIO? While the majority of these hardware specs are familiar to most people, for those without previous hardware hacking experience the GPIO will be new. The Raspberry Pi comes with a set of 26 exposed vertical pins on the board. These pins are a General Purpose Input/Output interface that is purposely not linked to any specific native function on the Raspberry Pi board.
The GPIO pins are there explicitly for the end user to have low-level hardware access directly to the board for the purposes of attaching other hardware boards, peripherals, LCD display screens, and other hardware devices to the Pi. For example, if you wanted to take an old arcade controller and wire it directly to your Raspberry Pi to give your arcade a more authentic feel, you could do so using the GPIO interface.
Although we will not be using the GPIO header in today’s “getting started” tutorial, we’ll definitely be taking advantage of it in future Raspberry Pi hacking how-to guides.
Where Can I Buy the Raspberry Pi?
In the first few months after the Pi’s release it was nearly impossible to get your hands on one. The Raspberry Pi Foundation greatly underestimated how popular the little computer would end up being. They anticipated selling a few thousand of them world wide; they sold over a million units in the first 12 months. Fortunately they have ramped up production and expanded their supply chain which means long wait times and having to bid fiercely for units on eBay is behind us.
Where do I go? The current official distributors of Raspberry Pi hardware are:
We would strongly recommend against purchasing your Raspberry Pi boards from Amazon, eBay, or other locations where people are simply buying up boards and flipping them for a profit. Now that production levels have increased there is no need to pay a premium to get your Pi from a third party.
Which model should I buy? While there are definitely uses for the lighter weight Model A (applications where the Ethernet port is unnecessary and the extra RAM will go unused), if you’re just getting started with the Raspberry Pi it makes more sense to buy the Model B and be prepared for any project you may wish to undertake than it does to shell out $35 more to buy another board in the future.
What Else Do I Need?
Part of the keep-costs-low mission of the Raspberry Pi Foundation hinges on the end user purchasing pieces to round out their Raspberry Pi build (such as a case).
Aside from the specific-to-the-Pi case, the rest of the required parts are common, generic cables and peripherals that most people will likely have laying around the house—the Pi Foundation, for example, opted to use the ubiquitous microUSB charger as a power source. Let’s take a look at the hardware you need to get started.
A stable 5v 700mAh+ power source: The Raspberry Pi draws its power from a microUSB port and requires a microUSB charger. Because the Pi is a micro computer and not simply a cellphone getting a battery topped off, you need to use a high quality charger with stable power delivery that provides a consistent 5v with at least 700mAh of output. Using a low-quality/under-powered charger is the number one source of system instability problems and frustration with the Raspberry Pi.
Using a power source rated for over 700mAh won’t hurt your Pi but it won’t necessarily provide any benefit either. The reason that many people recommend 1000mAh chargers is that 1000mAh is so far above the required 700mAh that even if your charger is slightly out of spec it won’t come close to dropping below the Pi’s required power threshold.
There are plenty of different microUSB chargers out there but we have been very pleased with the Motorola microUSB (SPN5504) and use it for all our Pi projects— for the curious, it outputs 850mAh.
Feel free to try out chargers you may have laying around the house but, should you run into any issues with uptime stability or peripherals attached to the Pi not working as expected, the first thing you should upgrade is the power source.
A case: The Pi ships naked; you are going to need a proper case to enclose it. You can pick up an acrylic/plastic case for around $10-25 or go the more creative route and craft your own case (as many did shortly after the Pi was released and it was nay impossible to get a commercial case). Here are several suggestions for your consideration:
- Built-to-Spec’s Acrylic Cases ($12.50): We’re big fans of the Built-to-Spec cases and have all of our current Pi projects enclosed in one. You can order a case or, if you have access to a laser cutter at work, can even download the design files and cut your own case.
- Adafruit Pi Box ($14.95): Also made from laser-cut acrylic, this compact little case snaps together with no additional tools or standoffs.
- SB Components Pi Case ($13.90): Another snap-together acrylic case, offers plenty of large cut-outs for access to the Pi board. Good choice for a Pi setup intended for use with DIY electronics projects.
A 4GB+ SD card: Per the Raspberry Pi Foundation the minimum card recommended is a 4GB Class 4 card (the class speed indicates how fast it can read/write). Since SD cards are cheap these days, we recommend going for at least an 8GB Class 10 card.
Audio/Visual cables: If you are connecting the Pi to an SD/analog television set you will need an RCA cable for the video and a 3.5mm stereo cable for the sound. You don’t need to purchase a specific RCA cable for the task, you could even use a yellow-red-white tri-cable you have laying around—just make sure to match up the colors on both ends of the cable when you plug it in.
For digital video/audio output to an HDTV or monitor with HDMI support, you will need an HDMI cable.
For digital video to a standard computer monitor that lacks an HDMI port, you will need an HDMI to DVI cable for the video signal and a 3.5mm stereo cable for the sound (as you’ll lose the sound in the HDMI to DVI conversion).
Mouse/Keyboard: Even if your ultimate goal is to build a headless file server or other no-input-peripherals/monitor device, you will still need input devices to get your Pi up and running.
Any standard wired USB keyboard and mouse should work without any problems with your Raspberry Pi. There is one caveat to that statement, however. Per USB design specifications USB-based keyboards and mice should draw less than 100mAh of power but many models disregard that specification and draw more. If you find that your peripherals are drawing more than 100mAh each, you will need to use a powered USB hub.
You may find it useful to check out this large list of verified Pi-compatible peripherals maintained by eLinux.org.
Ethernet cable/Wi-Fi adapter: Network connectivity isn’t an absolute necessity for the Pi but it makes updating (and downloading) software so much easier and gives you access to a wide variety of network-dependent applications.
You can either hook your Pi up to a hardwired LAN via Ethernet or buy one of the many micro Wi-Fi adapters compatible with the Pi. We have had great success with the tiny Edimax EW-7811Un adapter.
(Optional) powered USB hub: If your peripherals are out of spec or you need to attach more than two devices (such as a keyboard, mouse, and USB Wi-Fi adapter), you will need a powered external USB hub.
We tested all the powered hubs we had laying around the office with the Pi—from nice brand-name Belkin powered hubs to no-name hubs—and had no problems with any of them. That said, we would recommend checking your existing hub or potential purchase against the hub section of the aforementioned eLinux peripheral list. Definitely check out the notes on the various hubs in the eLinux list, as some users report the ability to power the Pi itself off the port of high-quality USB hubs—such as the D-Link DUB-H7—which is a rather handy trick.
Creating a Bootable OS Image
Now that we have assembled all the requisite hardware, Pi and peripherals alike, it’s time to get down to the business of loading an operating system onto your Pi.
Unlike a traditional computer where you have a BIOS, a drive that supports removable media (such as a DVD drive), and a hard drive inside the computer, the Raspberry Pi simply has a small solid state drive (provided via the SD card and the SD card reader). As such you are not going to follow the traditional computer-setup route of inserting a boot disk and installing your operating system to an internal storage device. instead, we are going to prepare the SD card on a traditional computer and load it into the Raspberry Pi for further unpacking/tweaking.
Selecting the Distribution: While there are a wide variety of Linux distributions and variations available for Raspberry Pi, the distribution we are going to use today is the best-supported and most stable: Raspbian—a Debian distribution optimized for the Raspberry Pi.
Once you get your Raspberry Pi up and running it will be a completely independent machine, but in order to start the process you will need another computer to create the operating system image on the SD card.
First, let’s start by grabbing a copy of Rasbian from the Raspberry Pi Foundation. The image you want is Raspbian “Wheezy”.
Selecting the Disk Imaging tool: Once you have finished downloading the disk image it’s time to extract the image onto the SD card. For this tutorial we’ll be using a Windows machine to extract the image but it’s easy to perform the same action on Linux and OS X machines. Here are our recommended tools for all three operating systems:
Note: You can always use the DD command on both Linux and OS X to write your image. Given how powerful DD is (and how terribly wrong things can go if it is used incorrectly) we’re leaving it at the discretion of the users whether they are comfortable using the DD command to image their Raspberry Pi SD card under Linux/OS X. The GUI-driven disk image tools supplied here are much safer for those unversed in DD.
Imaging the SD Card: Now that we have a copy of the Raspberry Pi Raspbian distribution and Win32 Disk Imager we can get started creating our operating system disk.
Insert the SD card you wish to use for the project into your SD card reader. We recommend double checking the drive letter at this time in Windows Explorer. It’s wise to remove any flash media, thumb drives, or tethered smart phones/devices before continuing—Win32 Disk Imager won’t hurt any hard drives attached to your system but it will offer up any flash-based media connected to your PC as a viable target for installation.
Extract the .IMG file from the Raspian .ZIP file you downloaded. Note the location you extracted the file to. Win32 Disk Imager is a portable application, so extract the contents of the .ZIP you downloaded from the link above and run Win32DiskImager.exe.
From within Win32 Disk Imager, select the image file and the appropriate drive letter, like so:
Press the Write button to write the contents of the Raspbian image to your SD card. Win32 Disk Imager will ask you to confirm the overwrite, click Yes. The actual write process should take only a few minutes. Once the application indicates the write has been successful you can safely eject the SD card from your system.
Next, we’ll teach you how to configure Raspbian on your Pi.
Configuring Raspbian on Your Pi
Now that we have all the hardware and a properly flashed SD card, it’s time to boot the whole thing up for the first time. Attach all the cables and peripherals to your Raspberry Pi except for the power cable—this includes the HDMI or RCA cable, the USB hub, the Ethernet cable/Wi-Fi adapter, etc.
Once you have all the cables attached to both the Pi and their respective destinations, insert the SD card. After the SD card is seated firmly, insert the microUSB power cable to begin booting up the Pi.
Almost immediately you will see the boot sequence go scrolling rapidly by—seen in the screenshot above. After a moment or two your Raspberry Pi will kick over into the Raspi-config utility like so:
Here we can complete some basic configuration tasks and enhance the functionality of our Pi unit. Although you can run the Raspi-config tool at any time, it’s ideal to do the bulk of your tweaking and customization right from the start as later changes you make to the system may conflict with some of the configurations tasks.
Expand_rootfs: Our first task is to run expand_rootfs. By default Raspbian is only using as much of your SD card as the core operating system requires. We want to access the entire SD card so we have plenty of storage for future projects.
Use the arrow keys on your keyboard to click down to expand_rootfs and hit enter—a burst of text will scroll by and then you’ll receive the message “Boot partition has been resized. The filesystem will be enlarged upon next reboot.” Click OK.
Overscan: Not every user will need to configure the overscan. If you notice that there is significant black space around the edges of the display (the Pi is using the middle portion of the screen and not the full screen) you may wish to enable overscan to increase the amount of screen real estate the Pi is using. Click on overscan, and then select enable.
Change_timezone: You want your Pi to keep accurate time. Select the change_timezone option and then select the appropriate geographic region (such as US), followed by the appropriate time zone within that region (such as Eastern). A small script will run, seen as several lines at the bottom of the screen, and then return you to the main menu.
SSH: The ability to remotely connect into your Raspberry Pi over your network using SSH is really handy. Take a moment to turn on the SSH server now by selecting ssh. Select enable. Select OK after Raspi-config indicates the server has been enabled.
Boot_behavior: Here we can indicate whether we want Raspbian to boot to the command line or the desktop environment when the Raspberry Pi boots up. Let’s switch it to boot to the desktop by selecting boot_behavior, then Yes in response to “Should we boot straight to the desktop?”
While these basic tweaks should cover most users’ needs, there are a few additional settings worth noting.
Configure_keyboard: Use this command to configure non-US keyboards and enable their character sets/layouts.
Change_pass: Allows you to changet he default password from ‘pi’ to whatever you wish.
Change_locale: Enable locales for the operating system; necessary for non-English speakers.
Memory_split: Change how the system allocates the shared memory for the GPU and the main processor. We suggest leaving this alone unless you, later on in your experimenting with the Pi, discover a pressing need to alter it.
Overclock: The Pi has a 700Mhz ARM processor. The Raspberry Pi Foundation actually supports overclocking the Pi up to 1000Mhz (1Ghz) but we recommend leaving it at the default for now. This way, should any issues arise in your initial setup, you won’t have to rule out overclocking tweaks as a cause.
Update: This is just a simple update script for the actual Raspi-config tool. Since you just downloaded a fresh Rasbian image there isn’t much use for this one yet—keep it in mind should you hop into the Raspi-config tool down the road, however.
When you are all done setting your configuration options, arrow down and select Finish. When prompted to reboot the device, select Yes. Hang tight while the boot sequence scrolls by.
At this point you will be booted into the Rasbian desktop—or, more technically, LXDE, Lightweight X11 Desktop Environment—where we will need to do a few last configuration tweaks.
Configuring network connectivity: Once you are at the desktop, you will need to configure the Wi-Fi adapter (for those using a direct Ethernet cable, go ahead and skip to the next step).
From the desktop, double click on the WiFi Config icon. This will open the wpa_config tool, as seen above. Click the scan button in the lower right corner of the window.
Once the application has scanned the available Wi-Fi networks, double click on the network you wish to connect to.
In the detailed view for that network, enter your network password in the PSK slot. Click Add at the bottom of the window. You’ll be returned to scan results window, go ahead and close both the scan results window and the original wpa_gui window.
Testing the network: Now that we have configured the Wi-Fi connection (or jumped right to this section because we’re using Ethernet) it’s time to test our connection. What better way to test the connection than to fire up the browser and visit How-To Geek?
From the desktop, click on the Midori icon—Midori is an ultra-lightweight web browser—and type in www.howtogeek.com:
Success! Not only do we have network connectivity, but Midori’s WebKit rendering engine makes How-To Geek look just as good on the lightweight Pi as it does on a full-fledged desktop. This will likely be the first of many times you are surprised and pleased with just how capable your new little microcomputer is.
Updating the Software: Before you start digging into your Pi, it’s a good idea to do a basic software update. We have setup the network, we have tested the connection, and now is a perfect time to do a system wide software update.
Close out Midori and, from the desktop, double click on the LXTerminal to open up the command line. Type in the following command:
sudo apt-get update && sudo apt-get upgrade
This combination command instructs Raspbian to search available software repositories for system and software updates and upgrades. As any such updates are discovered, you will be prompted to approve or disapprove the changes with the Y/N keys:
Be patient, especially if you’re updating over Wi-Fi, as there will be periods of time where the whole process appears to hang for a few seconds. Once you have waited for the Y/N prompt, go grab a cup of coffee while it unpacks and installs all your updates. After the updates are finished and you are returned to the prompt, go ahead and close the terminal window.
Click on the power icon in the lower right hand corner of the desktop and select Reboot from the available options.
You will cycle through the boot sequence again and then get dumped back into the LXDE desktop. At this point you have successfully configured your Raspberry Pi to run Raspbian, linked it to the network, updated your software, and you are ready to start playing with your Pi.
Additional Raspberry Pi Resources and Projects
Although we’re busily writing more Raspberry Pi how-to guides and tutorials for your future enjoyment, we understand how exciting it is to have a new tech toy (especially one like the Pi that begs for hands-on involvement and customization). With that in mind, here are a variety of resources we recommend you check out.
The Official Raspbian Documentation—From tweaking your config.txt to installing media players, Raspbian’s user documentation is a handy reference.
The Official Raspberry Pi Blog—If you keep an eye on nothing else Raspberry Pi related, keep an eye on the official blog. They’re constantly posting updates on new Pi developments, fun projects Pi fans have sent in, and other pieces of interest to Pi enthusiasts. While you are checking out the blog, don’t forget to make a stop at the Official Forums.
MagPi: The Unofficial Raspberry Pi Magazine—Published around eight times a year, MapPi is a free and polished electronic magazine for Pi hobbyists.
Raspberry Pi Disk Images—Experimenting with Raspberry Pi distributions is as simple as grabbing another cheap SD card and loading it up with a fresh image. Raspberry Pi Disk Images is a handy index of current Pi-friendly Linux and Android distributions.
eLinux.org’s Verified Peripheral List—Although we mentioned this one earlier in our tutorial, it’s worth mentioning again. If you are trying to figure out why an existing piece of hardware won’t work with the Pi or would like confirmation that a piece of hardware you’re looking at will likely work with your Pi, it’s an invaluable resource.
Have a Raspberry Pi project to share? Have a request for a Pi-oriented tutorial? Shoot us an email at firstname.lastname@example.org or sound off in the comments.