August 8, 2012

Raspberry Pi: Installing OS, WebCam, Wifi module



I've ordered Raspberry Pi in March, received in June, then something came up and couldn't do much for a while.  Finally I set it up properly and ready.

I'm thinking of a project using this device with wifi and webcam -- with Javelin (product link) to control servos and interface with various sensors -- the wifi module and the webcam are verified to be working with Raspberry Pi without any problems, and external USB hub with power is not required:
I didn't want any devices that requires external HUB with power -- and I had the web cam already lying around, and I purchased the Wifi USB module for only $8.99.  I also didn't want to spend too much time on setting up the device, so did some googling to find which OS image is the easiest one to use -- and tried Arch Linux, but that didn't work for a few reasons.  Wheezy version (7/15/2012 version) worked without much effort.

For the usb wifi module, read this thread -- and get the automatic install script from here, and the driver from here.  For the webcam, it worked out of the box.  My wireless router is set to use WEP with MAC filtering, but if you use WPA, please read other tutorial to configure it.

There are other advantages of using Wheezy over Arch Linux -- I did not attach monitor keyboard to the device, but ssh to it -- Wheezy lets you resize the SD card and configure other things with simple rasp-config command.  I didn't really measure the performance, but actually, I felt that Arch Linux performance is some what better than Wheezy.  For Arch Linux, the automatic wifi script or driver did not work, and resizing SD card is not possible on the raspberry pi while the OS is running. (adding partition is possible).

Conclusion
Use Wheezy and get verified H/W -- and save time.

To Do
  • Write more about S/W and H/W on Raspberry Pi.
  • Hook up Javelin with Raspberry Pi via GPIO/Serial/TTL.
Javelin Stamp
Why am I using Javelin instead of the popular Arduino?  It's only because I purchased the Javelin stamp development kit and other parts when it first came out (2001).  The product is discontinued, but still sold and its price is much cheaper than 2001 price.  The hardware is pretty good in today's standard -- compare with Arduino Uno: see here and here.  And you can program it in Java!  The Javelin IDE runs on Windows OS -- I tested up to Vista, and read that it works on Windows 7 as well.  The IDE comes with Jike Java compiler, so Sun's (oops), Oracle's Java SDK is not necessary.

(My) Environments
  • MacBook, Snow Leopard, with Parallax+WinXP (For Javelin IDE)
  • Use USB-to-Serial device to program Javelin.  Remember to install the device driver on Mac and add that device to the VM, and install WinXP driver.  The one I have uses Prolific PL-2303 chipset -- get drivers from here.
  • For Raspberry Pi, I had the web cam already, bought the wifi module, had this power adapter with micro USB from old phone.  Since no monitor or keyboard is attached, first install the OS image on the SD, use Ethernet to connect to the router, and turn it on.  Check the router setting and get the IP (it's first configured to use dynamic IP).  Then set it up to use wifi, rasp-config, etc.  I configured it to use static IP.
Misc Tips, Resources
  • Helpful wifi related Linux commands: 
    • iwconfig, lsusb, lsmod, ifconfig, iwlist wlan0 scan
  • Install ISO image onto SD card from Mac for Raspberry Pi:
    • example:
      sudo dd bs=1m if=~/Downloads/OS_image.img of=/dev/rdisk1 (replace 'rdisk1' with your device.)
  • Back up SD image
      1. unmount) $ diskutil unmount /dev/disk1s1
      2. backup) $ dd if=/dev/rdisk1 of=/Users/kkim/Desktop/raspberry_backup.img bs=1m
      3. eject) diskutil eject /dev/rdisk1 
    • Restore SD image
      1. unmount) $ diskutil unmount /dev/disk1s1
      2. Restore) $ dd if=./raspberry_backup.img of=/dev/rdisk1 bs=1m
      3. eject) diskutil eject /dev/rdisk1
    • Javelin: manual/IDE/files, some codes, sensors.

    S/W
    For WebCam, get followings (google yourself to find out what they are and how to use them):

    • sudo apt-get install motion
    • sudo apt-get install fswebcam
    • sudo apt-get install vlc