Skip to main content

Welcome to Geoff Hayward's Weblog

Commenting on Java, JavaFX, Java EE, Joomla, and IoT.

I have been keen to use Java on the Intel Edison since hearing that the Edison supports Java. At the time of writing this, I could not find much information on how to use Java with the Edison. So I decided to try and get a simple LED blink program going. While a blink program is very simple, the hello world of hardware, it thought me the important bits about using the Edison with Java.

Here is the blink program in action:

And here is the blink program's code:

import mraa.Gpio;

public class EdisonTest {

    static {
        try {
        } catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load.");

    public static void main(String[] args) throws InterruptedException {
        Gpio gpio = new Gpio(11);
        int state = 1;

        while (true){
            state = (state==1?0:1); 


The command to run the program is java -Djava.library.path=/usr/lib/java/ -jar EdisonTest.jar. I used WinSCP to put the EdisonTest.jar and its lib folder into /home/root/ (where I ran the program from).

If you get any problems check that your manifest file includes the lib folder. And that the lib folder includes the mraa.jar. You can download the mraa.jar and UPM jars from Intel.


In this post I will describe how you can make a 4 wheel drive robot car that can be controlled by HTTP GET requests. HTTP GET requests are what you use to request webpages. The types of requests will be 'stop', 'forward', 'left', etc..

This post outlines how to make the car itself. You can send HTTP GET request via any web browser using the browser's address bar. Or, you can even make a simple webpage if you like. I will be keen to hear about the controllers you make.

I made the car for the local FabLab Edison and BlueMix Hackathon. During the Hackathon the car's controller I made was with JavaFX and is a voice controller. The voice controller uses BlueMix's Watson voice-to-text service. The car controller I made is outside the scope of this post. But you can see it in action in the video bellow.

To Build the Robot Car You Will Need

Step 1 Build the Car Kit

​The Car Kit will arrive in a bag. The bag contains 4 wheels, 8 wires (4 red and 4 black), 4 motors, the chassis, and the fittings. The instructions that I received were in Chinese (I assume Chinese). I cannot read Chinese, but the diagrams on the instructions were very easy to follow.

Begin by stripping the paper off of the chassis.This took me about 20 minutes to do as it was quite fiddly.

Next attach the motors using the fixings that are provided in the kit. Then attach the wheels to the motor shafts. Attaching the motors did not take very long, there are 2 bolts per motor.

Slide a wheel onto the shaft of each of the motors.

Once the motors are attached, you can solder the wires to the motors (1 black negative wire and 1 red positive wire per motor).

Before fitting the top of the chassis; fit the h-bridges (Step 2). Once the h-bridges are fitted and wired up you can fit the top of the chassis.

Step 2 Attach the H-bridges

The h-bridges are not supplied in the car chassis kit; they have to be purchased separately.

First you will need to wire the 4 motors to the 2 L298N H-bridges, one motor per h-bridge output A & B respectively.

Then for each L298N H-bridges connect one 4 AA battery holder. Connect the positive wire from the battery holder to the 5+ vault h-bridge in. As well as connecting the battery holder's negative wire to the h-bridge's ground you will need a second ground wire. The second ground wire will take a common ground out from the Edison's breakout board.

I found the following video from LessonStudio to be very helpful (this car, we are making, does not use pulse width modulation - leave the jumpers in place):

Step 3 Set up the Edison

First Connect your Edison to your PC. If you have not connected your Edison to a PC before, I recommend watching this 'step-by-step guide to windows' by Carlos Montesionos.

Next connect your Edison to your local WiFi (if you haven't already). The WiFi will let you send commands to the car wireless. SSH into the Edison and run configure_edison --wifi; then follow the prompt. If you get stuck, I can recommend Connecting your Intel Edison board using Wi-Fi by Intel (the Edison's maker).

Next add Node-RED to the Edison. Node-RED will give you the functionality to receive the boundary HTTP GET requests. Node-RED can then take these requests to signal to the h-bridges to drive the motors. In other words Node-RED will manage the car's business logic.

To set-up Node-RED, SSH into the Edison and issues the following commands:

npm install -g --unsafe-perm node-red 
npm install -g --unsafe-perm pm2
npm install node-red-node-intel-gpio 
pm2 start /usr/bin/node-red --node-args="--max-old-space-size=256"
pm2 save
pm2 startup

Step 4 Wire the Edison to the Car

Once you have wired the car's power and h-bridges and set up the Edison, it's time to attach the Edison to the car. The Edison Arduino breakout board comes with legs. I attached the legs so that the breakout board stands over the top of the 4 AA battery holders.

Begin by wiring jumper cables from the Edison Arduino breakout board's digital outs to the h-bridge's ins. There are 2 jumper cables per motor. This means you will need to use 8 digital outputs in total.

Next, from each h-bridge take the common ground and wire it into one of the spare grounds on the Edison Arduino breakout board. The grounds are marked 'GND'. An Edison Arduino breakout board has 3 grounds available.

Connect the 9 volt battery once you have programmed Node-RED. In the meantime, power the Edison Arduino breakout board from the mains. I found the 9 volt battery only lasted 3-4 hours before the Edison could no longer boot.

Step 5 Program Node-RED to Handle the HTTP requests

Begin by navigation to Node-RED. Node-RED has a web browser based user interface. You may find the following address works; if it doesn't work, change 'edison.local' to the IP address. 1880 is Node-RED's default port.


Next, drag an 'HTTP' input onto the Node-RED canvas. It is important to send an 'HTTP' response back to whatever sent the request (otherwise the request will block the client). Therefore, drag a 'HTTP' output onto the canvas. Join the 'HTTP' input to the 'HTTP' output. Double click the input and set the address to /forwared. Then, using the address bar of your browser, send http://edison.local:1880/forwared. If everything works, you will see { } printed inside your web browser.

Next, drag 2 functions onto the canvas. Name one function 'low' and the other one 'high'. In each function set msg.payload = 0 and msg.payload = 1 respectively (0 being low, 1 being high).

// example high
msg.payload = 1;
return msg;

Next, drag 8 GPIO digital outputs onto the canvas. You will need to work through each GPIO digital output to match up with the motors. For each motor there are 2 GPIO outputs and 2 h-bridge inputs. Once you have each motor GPIO connected, you can send the highs and lows functions respectively.

You will need to repeat these steps until /left, /left, /back, and /stop can be processed by Node-red. Tip, don't try and reuse the high/low funciton blocks add 2 more for each command.

Here is a video of me testing what I had programmed (wired) Node-RED correctly .

Would you like to take a short cut? Just import this Node-RED Edison Car Configuration Node-RED via its import option. The file is a JSON array that I exported from my own configuration (The configuration is mostly as it was when tested in the video above).

Step 6 Have fun

That's it. If you follow the steps closely, you will have created a working HTTP controlled Edison Car. Good luck and I hope you enjoy making it. You can, also, find more fun project to do with the Edison over at Intel's Instructables page.


During this coming Thursday's Edison Hackathon, at the FabLab, I am hoping to control a robot car by voice. In preparation I have made a JavaFX voice controller UI. And I have put together a 4-wheel drive robot car chassis kit.

The voice controller uses the IBM Watson Speech to Text service. Since recording the video below I have tried commands with context such as "turn left", "reverse the car ". This has had better results. Using phrases, I added regex (word matching) to pull out the commanding verb from the phrase. The commands are then sent as HTTP GET request to whatever IP address and port is given. The Edison will be on the car processing the GET requests via WIFI and acting upon them.

The video below is the running 4-wheel drive robot car chassis kit. To get it working I used an Arduino. I will, of course, swap the Arduino for the Edison before Thursday. The motors are powered by battery, I think the Edison will still be powered by mains (but I am going to seek advice on the day).

As you can see I am all set ready for the FabLab Edison Hackathon: very excited.


This week's post is short; I ran out of time before the next session.

At last week's session we where given a 5 minute challenge. The challenge was to make an LED light up when a button is pressed down. Here is the outcome of the 5 minute challenge.

And here is the code I came up with during the challenge.

var groveSensor = require('jsupm_grove');

var button = new groveSensor.GroveButton(5); 
var led = new groveSensor.GroveLed(2); 

function doLight(){         


As you can see the button is plugged into D5 of the Seeed Base Shield. And the LED is plugged into D2. 'D' for digital.

In tonight's session we are going to be shown how to send data up to IBM's BlueMix. It going to be fun.


In last week's 2nd session of the Edison board class a lot of the time was spent making sure everyone was set-up ready to start making stuff. We were also introduced to the Grove Starter Kit Plus for the Intel IoT Edison Board.

The Grove Starter Kit Plus for the Edison Board is an interesting collection of sensors. The box includes many sensors, many LEDs, a buzzer, the base shield for Arduino and a stepper motor. Here is the full list of what's in the box:

  • Base Shield v2
  • Grove LCD RGB Backlight
  • Grove Buzzer
  • Grove Sound Sensor
  • Grove Touch Sensor
  • Grove Temperature
  • Grove Light Sensor
  • Grove Rotary Angle Sensor
  • Grove Button
  • Grove LED Socket with 3mm Red LED
  • Grove LED Socket with 3mm Green LED
  • Grove LED Socket with 3mm Blue LED
  • Grove 3-Axis Digital Accelerometer(±1.5g)
  • Grove Piezo Vibration Sensor
  • micro-USB cable

Our homework; get something working with the starter kit. I thought I would have a play with the LCD RGB backlight screen and the temperature sensor. This is what I made:

 Edison Board with the Grove Starter Kit set up to show the temperature on the screen.

The code that I wrote for this is:

var jsUpmI2cLcd  = require ('jsupm_i2clcd');
var groveSensor = require('jsupm_grove');

var lcd = new jsUpmI2cLcd.Jhd1313m1(6, 0x3E, 0x62); // Initialize the LCD
var temp = new groveSensor.GroveTemp(0);
function doTemperature(){
    var value = temp.value();

function doPrint(value){
    lcd.write(value.toPrecision(2) + "C");

function doColour(value){
    if(value <= 17){
           lcd.setColor(0, 0, 250);    
    if(value > 17 && value < 25){
           lcd.setColor(0, 225, 0);    
    if(value >= 25){
           lcd.setColor(225, 0, 0);    

setInterval( doTemperature, 3000);

I found the Seeed Wiki to be a very good resource for getting going with the sensor and LED RBG screen.

That's it for this week. The next session is tomorrow. I will have an update soon.

Tags: Edison


Mailing List

Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.