June 18, 2013 | Raspberry Pi |
This is a short post on setting up the Raspberry Pi (RPi) for development for the first time.
Being that the RPi is a full-fledged mini computer, it seems prudent to get a case rather than sticking wires all over it. Here's a case that I picked up from ebay:
It's also very helpful to get a power adapter. This one's from Samsung (5V, 700 mA) and connects to the micro USB port:
Next, you need to install an Operating System for your RPi. What you do is to download the latest "Wheezy" from the RPi official site, and write that image on to an SD card. Here is a nice video that will help you with this part:
For the first-time setup, it is nice to have a keyboard and mouse. I got this wireless keyboard with built-in trackpad for this purpose, and it was plug & play installation with Wheezy.
Internet is the next priority, and this USB WiFi adapter works great:
You can use your TV as the RPi monitor, as long as it has an HDMI cable. Here's the my RPi connected to the TV:
The first thing I need for RPi development is to have remote access to it. I don't want to sit in front of my TV and use a miniature keyboard to do coding. So the next thing is to set up ssh on the Pi so I can remote login. For this, we need to get a static IP setup for the Pi. You can read more about this here:
Here is what my network configuration file looks like:
pi@raspberrypi /etc/network $ cat interfaces
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet manual
iface default inet static
Now, you can login from your machine (in my case, a Mac) as follows:
$ ssh email@example.com
Note that the default password for the user "pi" is "raspberry".
You can also display GUI from the RPi on to your machine as long as you have an X-server running. Start the session with:
$ ssh -X firstname.lastname@example.org
Now, if you type:
The RPi browser window will popup on your remote machine, if you have the X-server setup correctly. But this is painfully slow, which is why I stick to ssh and the command line.
Python comes pre-installed with the RPi, which is great. But to use the GPIO pins with Python, you still need to get the appropriate library. Here is how you can do it:
$sudo apt-get update
$sudo apt-get install python-dev
Now download the Python GPIO library from:
Download, unzip, untar, cd into the directory and do:
$sudo python setup.py install
Now you are all set to talk to external hardware with Python!
As a simple test of the GPIO, I am hooking up an LED to pin 18 (GPIO5) of the RPi.
Here is the code to make this LED blink:
Your RPi is all set. Just power it on, and since the WiFi adapter puts it on your network, you can remote login any time from your machine and work on your project.
Checking your Raspberry Pi Hardware Version
There are several flavors of Pi. ;-)
Here is how you can check your version.
pi@raspberrypi ~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 2.00
Features : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2708
Revision : 000f
Serial : 00000000364a6f1c
To understand the revision number, refer to the hardware revision history table at this link. In my case, I have the Model B, with PCB Rev 2.0, made in Q4 2012.
Plugging in an HDMI cable
config.txt in the SD Card as follows, to ensure that your Pi recognizes the HDMI cable of your monitor.
Need help with a hardware project or product? Drop us an email at email@example.com. We offer consulting services on AVR and Nordic nRF BLE - hardware design, firmware development, prototyping, PCB design/assembly, sourcing and manufacturing. We can help you bring your product to market!
We love hearing from our readers. Email us at firstname.lastname@example.org for questions or comments on this article. If you found this article useful, please support us by buying some of our hardware products.