Raspberry Pi + Processing + CT UNO (Part 1)

Raspberry Pi + Processing + CT UNO (Part 1)

Credit to Stewart C. Russell for the tutorial PROCESSING 2.1 + ORACLE JAVA + RASPBERRY PI + SERIAL + ARDUINO = :).

 

About this tutorial:
– Re-writing the original tutorial from Stewart C. Russell with some modification.
– Raspberry Pi + Processing 2.2.1 + Oracle Java 1.7.0 + jSSC 2.8.0 + CT UNO (Arduino Uno compatible).

HARDWARE

1

PREPARATION

1. Write the latest Raspbian image 2014-09-09 (link) into 8GB SD card using Win32DiskImager.
2. Slot into RPi (short form for Raspberry Pi), connect all the cables (HDMI, LAN, Mouse + Keyboard, CT UNO) and power it up.
3. It is recommended to Expand Filesystem. Press Enter to select.

2

Then reboot your RPi. Press escape and write the following command.

sudo reboot

 

4. Default keyboard layout is UK, so you need to change to US layout.

3

Then select the options below:
– Change Keyboard Layout
– Generic 105-key (Intl) PC – No changes
– Other
– English (US)
– English (US)
– The default for the keyboard layout
– No compose key
– No
Again, you need to reboot.

sudo reboot

 

5. Ok to proceed to your desktop, press escape, then write

startx

 

6. Open LXTerminal, you need to write all the command here. So, keep playing with this. :)

LXTerminal

First, it is better to update and upgrade your RPi.

sudo apt-get update
sudo apt-get dist-upgrade

JAVA

7. Install Java 7

sudo apt-get install oracle-java7-jdk

 

8. Then you need to check your RPi java version

java -version

 

My LXTerminal response as follow,

java version “1.8.0”
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) client VM (build 25.0.b70, mixed mode)

 

Opps, I want java version 7 as default.
9. Write following command to choose java version.

sudo update-alternatives –config java

 

Then select “…/jdk-7-oracle…” as default.
Check again java version

java version “1.7.0_40”
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)

Yeah!

PROCESSING

10. You need to download the Processing IDE from web browser, and I like to use Chromium as web browser.

sudo apt-get install chromium

 

11. Open Chromium, go to processing website to download (https://www.processing.org/download/). Choose Linux 32-bit.
*It will takes some time since the size is ~100MB. However it is depend on your internet speed.
**By default the download file will be in the Downloads folder, I recommend to install processing at home directory, so the command will be much easier. To do that just simply cut file from /home/pi/Downloads and paste to /home/pi.

HomeDirectory

12. Extract processing download file

tar xvzf processing-2.2.1-linux32.tgz

 

13. Now you have to remove the included x86 Java runtime, and replace it with the RPi’s armhf.

rm -rf ~/processing-2.2.1/java
ln -s /usr/lib/jvm/jdk-7-oracle-armhf ~/processing-2.2.1/java

You should now have a Processing installation that will run, but there’s some more we need to get serial and Arduino support.

 

JAVA SIMPLE SERIAL CONNECTOR

14. Download the latest Java Simple Serial Connector at https://github.com/scream3r/java-simple-serial-connector/releases. After download is finished, cut and paste to home directory, and extract it.

unzip jSSC-2.8.0-Release.zip

 

15. Overwrite the jssc.jar that ships with Processing with the one you just download.

mv jSSC-2.8.0-Release/jssc.jar ~/processing-2.2.1/modes/java/libraries/serial/library/

 

16. Now, time to test the serial for Processing. Before that make sure CT UNO is connected to RPi. Then, open Processing.

~/processing-2.2.1/processing

Processing

Write this code and run it

import processing.serial.*;
Serial myPort; // The serial port
println(Serial.list()); // List all the available serial ports

 

It will takes some time (quite slow). As a result, you should get a single line of output.

/dev/ttyUSB0

TestProcessingSerial

Done! Your Processing work perfectly! Ok, close your Processing, get some rest, we will continue in Part 2. :)

Questions

Why not using the latest Java version 1.8.0?
I have try this version and got error during running the Processing. So currently Java 1.7.0 is compatible.