6 Nov 2013 shimniok   » (Journeyer)

JavaOne: Raspberry Pi Embedded Challenge


After a couple late night hours at JavaOne Java Embedded Challenge, Bruno and I had written a field sobriety tester on a Raspberry Pi using JavaFX and Java Embedded Suite. It's an example of how easy it is to build embedded solutions when all the hard work is already done for you :) Here's what we put together...

A few weeks ago I was fortunate enough to attend the JavaOne conference. I was there for purposes other than blog fodder but by happy coincidence, I stumbled across the Raspberry Pi Embedded Challenge in one of the first presentations of the event.

In the evenings, on personal time, a handful of us committed to hacking up some code on Raspberry Pi using Java Embedded Suite, Arduino, a big board of sensors, and a slick RPi-Arduino interface API (
things-api) written by Vinicius Senger.

Bruno P. and I teamed to create a Field Sobriety Tester that incorporates an alcohol sensor and a "drunk swaying" sensor, that is, a Ping))) distance sensor. The distance sensor is graphed and value displayed, the alcohol monitor value is also displayed.

That's me talking about the JavaFX display
Our source code is posted on github.

Overview

The basic architecture begins with a JavaFX client running on our laptops. The client could just as easily run on the Raspberry Pi. In fact, JavaFX can directly write to the RPi's frame buffer hardware, bypassing X.


The Raspberry Pi is running Oracle Java Embedded Suite, basically like a lightweight, embedded J2EE.

The Embedded Suite is running things-api code, exposing Arduino sensors as REST web services. The RPi's things-api web services talk to Arduino's things-api code over serial. The Arduino in turn interfaces with sensors in the standard fashion.

Things-API Arduino

On the Arduino side, defining sensors is beautifully simple. Declar a Device object, then add things to it, defining the pin type and pin number, e.g., Analog pin 2. Then just loop calling loop functions.