| Friday July 25th 2014

Feedburner

Subscribe by email:

We promise not to spam/sell you.


Search Amazon deals:

Raspberry Pi purchase and setup guide for developers


Raspberry Pi

The following are the steps I took to get my raspberry pi set up for development. I like to keep wires to a minimum, so by the end of this you should be able to plug your rPi into an outlet somewhere and connect to it remotely via ssh.


1- Ordering parts
Lets start from the beginning. The following is a minimal list of parts you’ll need.

A Raspberry Pi Model B – $35 – here
Shipping times can vary wildly due to high demand. Mine took 4 months(!) to ship (although I think its down to a couple of weeks now). You can pay more to get it sooner from re-sellers on Amazon/eBay but this  goes against the principles of the raspberry pi foundation.

A micro-usb cable – $4 – here
Used to power the device. It’s very important to make sure you use a High powered = 1.5A+ micro USB adapter with this board. It will spontaneously disconnect the Mouse, Keyboard, randomly freeze if you don’t.

A compatible flash card >2GB  - $5 – here
Stores the operating system

Edimax EW-7811Un wireless adapter - $10 – here
Internet & local wan connection.

A low amperage keyboard – $12 – here
Only needed for setup

HDMI cable – $5 – here
Only needed for setup

You probably have some of these parts lying around the house. Its important to check that parts are compatible beforehand; if they draw too much power, they will simply not work with the rPi. For a list of verified peripherals, see this wiki from elinux.org.

2- OS installation
So you received all the parts, now its time to put things together. This section outlines the process for geting an rPi image installed onto an sd card. I’m assuming you’re running on a mac (OSX). If you’re running linux or unix, steps should be pretty much similar. If you’re a windows user, check out this guide.

  1. Stick the flash card into your computer
  2. Download the Raspbian “wheezy” image here and Unzip the image. This will produce a .img file:
    • (From terminal)> unzip ~/Downloads/2012-10-28-wheezy-raspbian.zip
  3. Get the name of your sdcard by running dh command (Ex: /dev/disk3):
    • > df -h
  4. Unmount the sd card so that you will be allowed to overwrite the disk:
    • > sudo diskutil unmount /dev/disk3
  5. Install dcfldd
    • > brew install dcfldd
    • dcfldd is a fancy version of the older dd. You can use either tool(I tested both), but the flashing process takes ~30 minutes and dd does not print any status information. If you have trouble installing dcfldd, dd will suffice for the next step.
  6. Flash the image using dcfldd. This will take ~30 minutes.
    • > sudo dcfldd if=~/Downloads/2012-10-28-wheezy-raspbian.img of=/dev/disk3 bs=1m
    • if = Path to .img file
    • of = Path to sdcard disk
    • Setting ‘of’ ot the wrong path will do verry bad things to your computer. Be careful.

If you run into any problems, follow this more detailed guide which I abridged here.

3- Device configuration
Once the flashing process is complete, its time to boot the rPi for the first time and configure things. In this section, we’ll enlarge the sdcard partition to make use of all available space and modify boot behavior.

1- Take the sdcard out of your computer and plug it into the rPi. In the two USB slots, place the wireless adapter and the keyboard. Hook the hdmi cable up to a monitor/tv.When you plug the micro-usb cable into the device (from your computer), it will start to boot for the first time. You should see lights start to flash red and green.

2- Once the initial boot sequence is complete, you’ll be able to enter raspi-config. This is a configuration utility that allows you to change the settings on the rPi. If prompted for a password, use user: pi, password: raspberry (defaults for wheezy image).

See here for a full details about each of these options

3- Select “expand-rootfs” and follow the instructions here to enlarge your main partition to take up the entire sdcard. If you don’t do this, you’ll only have ~200MB of free space to play arround with (regardless of how big your sdcard is). This change will take effect on the next device boot.

4- Select “ssh” and enable the ssh server on the device. We’ll need this active so we can later connect to the device remotely.

5- (optional) Select “boot_behaviour” and then select “command line”. This will ensure that we always boot into the command line. You can skip this if you want to use the desktop.

6- Once back in the main menu, press the right arrow twice (to select “Finish”) and hit eneter. When you get back to the command line, restart your device using “sudo halt” or unplug/re-plug your device.

4- Wi-fi setup
Ok, we’re almost done. Its time to get the wifi working on the EW-7811Un wireless adapter. The OS image we installed already comes with the drivers for this device, so this saves us some headache. Follow these steps (borrowed from savagehomeautomation.com) to complete setup.

1- Check that the wireless adapter is hooked up properly and recognized by the operating system. Execute the following command:
>lsusb

2- Next check that the driver is properly installed & loaded. Execute the following command
>lsmod

3- Edit the network interface configuration file for the operating system. You can edit the file with the following command:
> sudo nano /etc/network/interfaces

Modify the file to look like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

4- Next, lets add the login information for your wireless network. Run the following:
> sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Edit the file to look like this (replace ‘__SSID__’ with your wireless network ssid and ‘__PASSWORD__’ with your password):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="__SSID__"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="__PASSWORD__"
}

5- Restart your network interface:
> sudo ifup wlan0
6- Restart your device. Once you log back in, you should be able to see the wireless adapter connected to your network:
> ifconfig wlan0

7- You can test things out by running:
> curl “www.google.com”
You should see a bunch of html and javascript pop up on your screen if you’re connected to the internet.

5- Connect & start developing!
Now that you have a network connection, you shouldn’t need the keyboard or hdmi. You can connect to the rPi through ssh and work remotely.

You can also send files to/from you rPi using scp.

Related Posts: On this day...

Leave a Reply

You must be logged in to post a comment.