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:

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:

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.

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 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.

I have already developed application like GSM and Loadcell through wiringPi. Another person is developing GUI based on Java. I need to merge the embedded c code based on wiringPI to the Java application.

we tried through JNI method from the following link with the blinck.c file from wiringpi:-

Just desire to say your article is as surprising.
The clearness in your post is just cool and i could assume you’re
an expert on this subject. Well with your permission let me to grab your RSS feed
to keep updated with forthcoming post. Thanks a million and please continue the gratifying work.