Connecting mbed to Processing over Network

This is a tutorial to connect mbed from Processing.

You will be able to control the mbed easily from Processing over network.

/media/uploads/nyatla/--_7.png

What do we need?

It needs three software modules.

  • Processing2
  • mbedJS
  • mbedJS Processing API

Processing2

Processing2 can be download here. https://www.processing.org/

mbedJS

Import programmbedJS

This is a Json-RPC/2.0 server with websocket and httpd. You can control mbed(s) by Javascript, processing, Java. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

mbedJS is firmware to control mbed via websocket RPC.

It works on mbed1768,LPCXpresso1769,LPC4088 QBS bord,ArchPro(LPC1768),FRDM-K64F

mbedJS Processing API

https://github.com/nyatla/mbedJS-Processing-API

This is a library to call mbedSDK functions from Processing. IIt has an API that was very similar to mbedSDK.

Direct link is here. https://github.com/nyatla/mbedJS-Processing-API/raw/master/release/mbedJsPsgApi-1.zip

And, mbedJS works on Ethernet. Ethernet cables and router may be required.

How to setup

First of all, We need setup mbedJS firmware.

  1. Compile the firmware of mbedJS in mbed.org.
  2. Download bin file and write to the mbed.
  3. Make configuration file for mbedJS on mbed drive. It is named "mimic.cfg". The name is "mimic.cfg" which is text file. You can access mbedJS by specified IP address here.
  4. Connect to mbed to network, restart mbed board.
  5. Access to mbedJS with specified IP address by web browser. If successful, MiMic webpage is shown.

Next, setup processing library.

  1. Unzip mbedJsPsgApi-1.zip
  2. Copy unziped files to Processing sketch book directory.
  3. Open a sample sketch in "example/LEDBlink.pde".

Reference


1 comment on Connecting mbed to Processing over Network:

10 Oct 2014

K64F mbed processor running mbedjs,

Using Processing 2.1.1 on Windows 8.1 running MCUTest as follows received numerous java errors see below.

any suggestions welcome! How do you know web server is working, is there a debug switch somewhere? what is the syntax for the mimic.cfg file I have ip address with no other symbols

<import jp.nyatla.mimic.mbedjs.psgapi.*;

Mcu mcu=new Mcu(this,"192.168.1.20");

void setup() { Mcu.GetInfoResult r=mcu.getInfo(); println(r.mcu_eth); println(r.mcu_name); println(r.platform); println(r.version);

} void draw() { }>

java.lang.RuntimeException: java.lang.RuntimeException: jp.nyatla.mimic.mbedjs.MbedJsException at processing.core.PApplet.runSketch(PApplet.java:10573) at processing.core.PApplet.main(PApplet.java:10377) Caused by: java.lang.RuntimeException: jp.nyatla.mimic.mbedjs.MbedJsException at jp.nyatla.mimic.mbedjs.psgapi.Mcu.<init>(Unknown Source) at McuTest.<init>(McuTest.java:21) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) <at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at processing.core.PApplet.runSketch(PApplet.java:10571) ... 1 more Caused by: jp.nyatla.mimic.mbedjs.MbedJsException at jp.nyatla.mimic.mbedjs.JsonRpc.<init>(JsonRpc.java:32) at jp.nyatla.mimic.mbedjs.javaapi.Mcu.<init>(Mcu.java:52) ... 9 more>

Please log in to post comments.