Raspberry Pi

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.


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.


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

About these ads

Tags: , , , , , , , , ,

12 Reacties to “Raspberry Pi”

  1. Rick Fincher Says:

    Hi Jeronen,

    I’ve been using the framboos package you wrrote for a few days on the Pi. Very nice work!

    I can’t seem to get the PWM working, though.

    I have it running on a Pi with a wireless Ethernet as a Facelets Web Application under Tomcat.

    Any idea what’s going on with PWM? The commands seem to run without error, but nothing happens.

    • jkransen Says:

      Hi Rick, I’m glad you find it useful. I remember I also had trouble with PWM just before I left on holidays. I’ll look more into it soon after I’m back.

      • Rick Fincher Says:

        Hi Jeronen,

        I’m advising a group of kids who are forming a robotics club at their school. hey are very excited about using the Raspberry Pi. They are using your code and WiringPi for their GPIO programming.

        We re in he USA, forgot about Augus being holiday month in Europe.

        Enjoy your holidays and thanks again!


      • Jeroen Kransen Says:

        Rick, I looked at it again, and it turns out I’m using a driver that does not seem to support PWM. If this changes in the future, I’ll cover it in my code as well. For now I removed the PWM code. If you really need PWM, you’ll probably need to take a different, more low-level approach.


  2. Rick Fincher Says:

    Forgot to mention- when running as a web application I can control the ports with the browser in an iPhone (or any other phone with a good browser). Thanks again for your work!

    • Jeroen Kransen Says:

      Looks good, I also want to do something like that. Is there anything you can show online?

      • Rick Fincher Says:

        Yes, this was someting I helped the kids in the robot club with, so it’s not the best code in the world but it’s very simple.

        They ended up using Tomcat 6 with no problems for their small web app. I was a little worried about memory, but it worked OK. If memory becomes a problem we can switch to Winstone or Jetty for a smaller footprint.

        We did it as a NetBeans project. We modified your code to add a debugging flag so they could run the program on their Windows or Mac machines with the NetBeans IDE, without throwing exceptions. We also put in a print trace flag so that so that a text message gets written out to the console when GPIO methods are called.

        This lets them see what their code will do on the NetBeans side so they can debug before putting the code on the Pi.

        To run the code on the Pi they just recompile with the debugging flag set to false, then copy the .war file to the Tomcat webapps directory.

        I’ll set up a git hub for it and get back to you.

  3. Rick Fincher Says:


    The GitHub for the project is at: https://github.com/rfincher/WebGPIO2

    The readme file has a lot of info. I still need to push the compiled .war file, but it should be up soon.


  4. Rick Fincher Says:

    I got the war file up in the dist directory on:

    You can install WiringPi, Java, Tomcat, and WebGPIO2 on the Pi and run without coding.

    Very simple but you can get the idea.


  5. krishnak Says:

    Just wondering whether you managed to get SPI working from Java

    • jkransen Says:

      I have not tried SPI, but other people have. Under the hood, my Java wrapper library uses the GPIO driver under /sys/class/gpio which does not support SPI. I think Java could not do without a low-level driver, to handle the realtime low-level timing synchronization.

  6. Rick Fincher Says:

    Take a look at the Pi4J (Pi for Java) project: http://pi4j.com/

    They also use Gordon Henderson’s Wiring Pi tools to make a Java library with JNA. https://projects.drogon.net/raspberry-pi/wiringpi/

    Gordon has a good tutorial on SPI on his site.

    I got the I2C bus working with the Adafruit PWM 16 board for 16 Pulse Width Modulation channels to run servos and motor controllers using Peter’s code.

    You can modify the code for SPI: http://simonp.uw.hu/linuxi2c/linuxi2c_java_v0_1.zip

    Peter’s entry on the RPi site is:

    Good Luck!


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )


Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s


Ontvang elk nieuw bericht direct in je inbox.

%d bloggers like this: