For Christmas I was gifted a Raspberry Pi and here are various information, commands, and links I used to understand it’s full potential and get it up and running.

I detail not only setting up a Raspberry Pi but also getting it working with a $10 USB wifi adapter so it’s free to be put anywhere in your house while still being online.

What is a Raspberry Pi?

For those that don’t know a Raspberry Pi (RPi for short) is a small computer about the size of a deck of cards that uses around a low 3.5 watts of power. Several years ago I once tried to build a low powered computer for a desert project and was only able to get it down to 40 watts so you can imagine how great this is for low power projects or just saving energy. To compare, a Macbook Pro consumes up to 50 watts and your iPhone can consumes up to 6 watts.



There are just about an infinite amount of uses for a Raspberry Pi. From a home file or backup server, personal web server, home media center for streaming content to your TV, bitrorrent server, mame arcade for old school games, dropbox clone, computer system for your car/boat/RV, and much more.



For a little history on how the Raspberry Pi came to be check out the “about us” from the Raspberry Pi foundation here.

How’s it work?

The Raspberry Pi’s operating system is contained on a SD card and powers itself through a single micro USB port (it also has 2 powered USB ports in the front which you can use for anything else). Though it’s not the most powerful computer it has a 700mhz processor capable of doing most things. A CAT 5 network port allows you to connect it up to your network / the internet. RPi uses HDMI out for video to your TV. Not sure why they went with HDMI but my guess is that they built this device for the largest audience possible and not everyone has a computer monitor but most everyone has a TV. This also makes it extremely easy to set up RPi as a media center for your home entertainment system which I’m sure a good percentage of people use it for. If you don’t have a TV You can use an HDMI-to-DVI adapter to connect to a regular computer monitor.

Pricing

You can buy an unbuilt RiP kit starting at around $45 (the newest series B) but mine is a prebuilt kit for around $65 from Canakit on Amazon as I’m more interested in the software capabilities than the hardware. If you factor in that you will need to buy an SD card, case, and a bunch of other stuff that the unbuilt kit doesn’t include, it’s actually a decent deal especially if you have Amazon Prime.

Setting up the OS

At this point of this article I go into setting up a Raspberry Pi out of the box.

My kit came with an 8GB SD card preinstalled with NOOBs: an installer program that lets you pick between five different operating systems to install. If your SD card is new or doesn’t have it just download NOOBs and save it to your SD card by following the steps here. Then just plug the HDMI to your video source, plug in your USB mouse and keyboard, and lastly plug in the USB power and you’ll get the menu in the screenshot above.

When on the NOOBs installer screen, you’re going to be presented with a lot of operating system options to install. If you are building a streaming media server or media center then just go with RaspBMC which installs a media-oriented operating system good for your TV or projector. Otherwise I recommend just going with Raspbian, a Linux operating system based on Debian and optimized for RP. It even comes with a graphical user interface like Mac OS X and Windows if you want to use it. After installing it’ll boot to command line and just type `startx` to launch the GUI. From there you’re all set up to start whatever project you want. If you’re comfortable with command line and don’t need a monitor because you’re going to be running a headless server the first thing I do is setup SSH at this point so we can also do away with the mouse and keyboard, too.

Command line dictionary

If you’re going to be sticking to the command line here are a list of helpful commands to get you started. Some are specific to Raspbian while the rest are the same for most Linux OS’s:

// Start the Raspbian configuration wizard

sudo raspi-config // launch graphical interface

startx // see how much memory is free in megabytes

free -m // see how much disk is used / free

df -h / // see ip address (also accessible via `ip addr`)

hostname -I // see what’s plugged into the USB ports

lsusb // Reboot the system

sudo shutdown -r now // See network (wired and wireless details)

ifconfig // See wireless card details including SSID

iwconfig // Restart the network

sudo /etc/init.d/networking restart

Guide to apt-get:

apt-get is the package manager for Raspbian. You can use it to install popular programs such as a web server or your favorite text editor.

// install

apt-get install <name of software>

// search

apt-cache search <key word for search>

// update software repository

apt-get update

// uninstall

apt-get remove <name of software to remove>

// upgrade all current packages with latest

apt-get upgrade

Other helpful tips:

Out of the box Raspbien has one unix user set up named pi. Her password is “raspberry”. Change this right away especially if the Raspberry Pi will be connected to the internet.

Also, if you’re going to be enabling SSH on your RP and it’s going to be accessible to the outside world, I’m a big fan of changing the SSH port to something less common to minimize random log in attempts. Pairing that with passwordless SSH helps but I assume you know about these things since you’re using the command line.

// setup open-ssh so you can SSH in

rm /etc/ssh/ssh_host_* && dpkg-reconfigure openssh-server

Setting up Avahi:

Avahi is Linux’s implementation of 0-conf also known as Bonjour or Rendezvous on a Mac. It allows computers to broadcast services to each other. Whether you’re on a PC, Mac, or Linux all your other computers are probably already using this and broadcasting stuff. This is totally helpful because computers get assigned different local ip addresses when connecting to a network and sometimes they change.

Real world example: In my house I have poked a hole in my router so that I can connect to my Raspberry Pi from the outside world. As a security measure none of my other machines are accessible from the outside world. However, I can SSH into my RP and then access the other machines from there. Using Avahi I can even query the IP address of my printer and do or set up things I hadn’t planned to do.

Additionally a lot of computer, even my Macbook Pro has a setting called “Wake on Lan” (called “Wake for Network Access” on the Mac). This means I can let my electricity guzzling machines sleep when I don’t need access to them, but I can still SSH into them via RaspberryPi and setup a bittorrent download or some other process.

//Install Avahi

sudo apt-get install avahi-daemon // daemon

sudo apt-get install avahi-utils // search tools

Once avahi is installed other computers on the network can reach it as raspberrypi.local. If you set up a web server on your RP you can even type raspberrypi.local in your other computer’s web browser and it will work. If you’re SSH’d remotely into your RP and want to get the ip addresses of the other broadcasting computers in your network just type the following:

// Search for services in your network

avahi-browse -a

Unchain your Rasberry Pi with a wireless connection

The RPi’s small size is awesome. It can fit just about anywhere you can put a deck of cards. Unfortunately that hard wired network cable limits its mobility. I found the cheapest and smallest USB wifi adapter ($10 bucks!) and now the only limitation is an electric outlet or USB port for power. Here’s how:

Buy the Edimax EW-7811Un USB Adapter and plug it in.

run: sudo nano /etc/network/interfaces

Replace the content with the following replacing <SSID> with your wifi name and <PASSWORD> with your password.

auto lo

auto wlan0 iface lo inet loopback

iface eth0 inet dhcp allow-hotplug wlan0

#iface wlan0 inet manual

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

#iface default inet dhcp

iface wlan0 inet dhcp



wpa-ssid <SSID>

wpa-psk <PASSWORD>

Showdown the system with `sudo shutdown -r now` and disconnect the cat-5 network cable.

When switching from network cable to wifi your RP’s ip address will definitely change. If you have avahi installed you may be able to find it but I’m not sure how avahi caches its findings for. Your best bet is to just to connect to your wifi and see what ip address is associated with your RPi.

Troubleshooting: If you for sure know your RPi didn’t connect to your wifi double check all your settings and make sure your password is correct by logging out of a current machine and logging on the wifi again. If nothing works, put the network cable in and run `ifconfig wlan0` and `iwconfig` to see if the wifi card has an ip address and other details.

That concludes this guide. I have a lot of cool experiments to do with my `pi. Hope this article has been helpful! The Raspberry Pi is a super awesome device and they made it a breeze to setup and use. A lot of the information above is from my own experience setting up my RPi but I also had a super easy time time thanks to Google and these helpful guides:

Other helpful guides: