Sunday, 29 July 2012

Raspberry Pi...the basics

After playing for a day with my Raspberry Pi, here I'm compiling a list of tools that would help you setting RPi up correctly. As I'm testing everything under Python and I want to control it using my laptop (Windows 7), I need different ways to be more productive and faster when developing on it. In my case I'll need a Python editor like geany, GPIO library and remote desktop using Xming and PuTTY via SSH. As stated in my previous post I'll build a small robot using the following mechanical and electronic parts (All of them bought from HobbyTronics) expending less than £50:
Update the system first:
root@raspberrypi:~# apt-get update
Installing Geany:
root@raspberrypi:~# apt-get install python geany xterm
Downloading GPIO RPi Python from Google code:
root@raspberrypi:~# wget
--2012-07-29 10:20:19--
Connecting to
HTTP request sent, awaiting response... 200 OK
Length: 10824 (11K) [application/x-debian-package]
Saving to: `python-rpi.gpio_0.3.1a-1_armhf.deb'

100%[======================================] 10,824      --.-K/s   in 0.1s

2012-07-29 10:20:27 (71.2 KB/s) - `python-rpi.gpio_0.3.1a-1_armhf.deb'
saved [10824/10824]
Installing the package GPIO RPi:
root@raspberrypi:~# sudo dpkg -i
python-rpi.gpio_0.3.1a-1_armhf.debSelecting previously unselected
package python-rpi.gpio.
(Reading database ... 54876 files and directories currently installed.)
Unpacking python-rpi.gpio (from python-rpi.gpio_0.3.1a-1_armhf.deb) ...
Setting up python-rpi.gpio (0.3.1a-1) ...
Testing the GPIO Rpi library:
Just open Geany and paste the following source code:

import RPi.GPIO as GPIO
import time


GPIO.setup(11, GPIO.IN)
GPIO.setup(12, GPIO.OUT)

#set up output 12 as true.

GPIO.output(12, GPIO.HIGH)

while True:
        input_11 = GPIO.input(11)
        print "%s %r" % ("Input 11 value is", input_11)

Compile it and run it. It should display the value of Pin 11. If you can change the state of that input, the display will show the change.

Starting up the SSH server:
root@raspberrypi:~# service ssh start

Download PuTTY and Xming and install them:
Once installed, run PuTTY and under Session options, use the IP of the RPi. (to get the IP just run the ifconfig command):

And enable the option X11 forwarding under connection options:

Once done, open the connection and use your credential to login (by default user: pi password: raspberry).

As soon as you are in, type startlxde and Xming will take over and it will display the RPi desktop on your local machine.

Check out the parameters for Xming as the short-cut should call: "...Xming.exe" -clipboard -rootless.

Related links:

Taking a bite of my Raspberry Pi!

Lots of thinks are going on, new interesting projects, new ideas but no time to post. I've just got my new Raspberry Pi and I'm planning to build a small robot with it using the GPIO. I'll use all the tools available from the internet and I'll see if I can write something using Pascal/Delphi and share it with the community (I've seen GPIO libraries for C# and Java). I'm really excited about it because it opens a set of possibilities, not only for Developers but also for students who will be hooked on to this beautiful board. In this post and the following ones you'll find my progress with my RPi and all the source code. I'm still building up the idea and I'm waiting for different parts of the robot to arrive. At least I've got the Raspberry Pi model B board, the keyboard, HDMI cable, an SD with Raspbian "weezy" distribution OS and loads of patience. 

Quick steps (Instructions working under Windows OS):

1. Download Raspbian.
2. Download Image writer for windows (to burn the OS into the SD Card).
3. Once installed, plug all necessary things to the board and turn it on!.
4. Configure the different options (SSH Server, Keyboard layout, Date&Time, etc)
5. run startx command and off you go!.

Running my "Hello world" using python:

Now I need to tinker with GPIO and get used to it. I'll use the GPIO.RPi python module to control the Input/Output signals.

Stay tuned for my forthcoming articles!.

Related links: