Posts Tagged ‘bluej’

Raspberry Pi

16 juli 2012

Since a few days I’m the proud owner of a Raspberry Pi. It’s a simple, but complete computer that allows -or rather encourages- tweaking. Since I ordered it (months ago), I have been thinking about what to do with it. There are some features that make the Pi special:

  • Cheap, got mine for €35 including shipping.
  • Small, a bit bigger than a credit card.
  • Runs popular Linux distros, notably Debian and Arch Linux, with Fedora expected soon.
  • It has good connectivity options: USB, Ethernet and open pins that allow you to use low-level protocols such as GPIO, I2C and SPI.
  • It uses little power, somewhat like 4W.

Application

Some people got XBMC running on it, or use it for educational software like Scratch. To me that does not utilize the benefits of the Pi, as these can be run (faster) on any other computer. Instead, its low power consumption and small form factor make it particularly portable. So much so, that one was sent almost into space! Add a smallish solar panel and a battery, and you can place a running computer anywhere! Instead of the solar panel, you can hook it to the cigarette lighter socket of your car. You can program it to do all kinds of measurements and take decisions by controlling motors. With its network interface, you can read its measurements from a distance or manually trigger its controls.

Smartdust

The Raspberry Pi brings the concept of smartdust closer. Instead of one, you can have many Pis communicating with each other. The only state they have in between restarts is the SD card they boot from. Copy that to another Pi, and you have two identical machines.

Where to start

The distro I chose was Debian. It is widely used and supported, and comes with a lot of software that you assume to be running on a Linux machine. I got myself a starter kit, that gives me a simple but nicely finished housing, some basic components and a breadboard to stick them in to. I installed the wiringPi library to allow communication with the GPIO port through virtual files on the file system. Then I wrote some Java code that uses these files to actually communicate through GPIO. You can download the project from GitHub. If you have the same starter kit, you can wire up the LEDs and run the algorithms that light them up in different patterns. If you don’t, then you can still use it as a basis to communicate to the GPIO ports from Java.

From an educating view, I hope to take the program to a state where it could be used to introduce people (children) to programming in general and OOP and Java in particular, and provide a framework to try their own algorithms. But for that, the feedback cycle would need to be shorter. BlueJ seems to be a good IDE to compile and run directly on the Pi. For now, I do a mvn install on another PC, scp it to the Pi and launch it over ssh.

If you want a a quick start, just install a copy of my SD card image. It’s the Debian image with wiringPi and OpenJDK 6. Credentials are the same as for the clean Debian distro: pi/raspberry. It’s a 4G image, so you’ll need at least a 4G SD card. From another Linux machine, download the file, bunzip2 it, and write it to your SD card with the correct character for your SD drive:

dd if=./debian4G_20120716.img of=/dev/sd[character] bs=1M