Tuesday, August 26, 2014

Arduino IDE on Raspberry Pi

Updated@2019-02-19:
Please check the updated post: Install Arduino IDE 1.8.8 on Raspberry Pi/Raspbian Stretch release 2018-11-13.

To install Arduino IDE on Raspberry Pi, enter the command:

$ sudo apt-get install arduino

After installed, run it with command:

$ arduino

This video show how to, and also show how Raspberry Pi connected Arduino Uno run.



Cross post with Arduino-er.

Shell script to check Raspberry Pi temperature

The following command print the Raspberry Pi CPU temperature:

$ cat /sys/class/thermal/thermal_zone0/temp

Shell script, chktemp.sh, with the following content print the CPU temperature:

temp=$(cat /sys/class/thermal/thermal_zone0/temp)
echo CPU Temp.= $(($temp/1000)) C

To make it executable:

$ sudo chmod +x chktemp.sh

Run it:

$ ./chktemp.sh

Shell script to check Raspberry Pi CPU frequency

The following command show the CPU current frequency:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Create a shell script, chkspeed.sh, with content:

cur_freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
echo Current CPU Freq.= $(($cur_freq/1000)) "(Mhz)"

To make it executable:

$ sudo chmod +x chkspeed.sh

Run it:

$ ./chkspeed.sh

Make shell script executable

To make shell scripts executable, enter the command:

sudo chmod +x <your shell script>


Monday, August 25, 2014

How much current Raspberry Pi draw

Shown in the video is a low cost USB Voltage Current Multimeter, it show the voltage and current at USB port alternatively. Maybe it's not a professional equipment, I can use it to monitor monitor and estimate power consumption on my RPi.

In order to eliminate the extra power draw by accessories, the Raspberry Pi connect USB power cable and network cable only, for sure with SD Card also.

Sunday, August 10, 2014

Cross compile Java/Swing program for Raspberry Pi, with Netbeans 8

This video show how to cross compile Java/Swing program for Raspberry Pi, on PC running Netbeans.



Currently, I cannot remote run the Java/Swing program on Raspberry Pi within Netbeans IDE, caused by "No X11 DISPLAY variable was set, but this program performed an operation which requires it". But it can create the runnable jar in Raspberry Pi. You can login Raspberry Pi and run the jar locally.

You need to:
Install JDK 8 on Raspberry Pi
Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi
- and know how to Run/Build JavaFX application on Raspberry Pi remotely from Netbeans 8

Code of this example:
package helloworldswing;

import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class HelloWorldSwing {

    private static void createAndShowGUI() {

        JFrame frame = new JFrame("Hello Swing@Raspberry Pi");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setPreferredSize(new Dimension(400, 300));

        JLabel label = new JLabel();
        label.setText(
            "Hello: " 
            + System.getProperty("os.arch") + "/"
            + System.getProperty("os.name"));
        
        frame.getContentPane().add(label);

        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
    
}



Updated@2015-12-06: Solution of "No X11 DISPLAY variable was set, but this program performed an operation which requires it":

Refer to karczas' comment in YouTube video, The solution of 0:50 error (No X11 DISPLAY variable was set, but this program performed an operation which requires it) which will allow you to run and debug GUI application directly from NetBeans and display their content on your RaspPi (or BeagleBone Black): 
https://mkarczewski.wordpress.com/2015/12/05/netbeans-remote-java-arm-debugging-with-gui



Remote debug Java program on Raspberry Pi using Netbeans 8

With JDK 8 installed on Raspberry Pi, and Set up Java SE 8 Remote Platform on Netbeans 8, you can Run JavaFX application on Raspberry Pi remotely from Netbeans 8, and also debug Java/JavaFX program running on Raspberry Pi remotely on PC with Netbeans 8.

This video show how to debug the last example "Java/JavaFX Client run on Raspberry Pi, link with Android Server" remotely with Netbeans 8.

Java/JavaFX Client run on Raspberry Pi, link with Android Server

It's the Java/JavaFX version of Android client run on Raspberry Pi (via Netbeans 8 Remote Platform), to link with Android Server.

In the video, the VLC Media Player display is the Raspberry Pi RCA video captured with USB Video Adapter.

The program code can be found here:
Java/JavaFX version of Android client
- Android Server

To know how to:
Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi
Run JavaFX application on Raspberry Pi remotely from Netbeans 8


Wednesday, August 6, 2014

Try demo of Java SE 8 for ARM on Raspberry Pi

After Install JDK 8 on Raspberry Pi, you can try the Java SE Development Kit 8 Update 6 Demos and Samples for ARM on Raspberry Pi.

JDK 8 for ARM Downloads (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-arm-downloads-2187472.html) provide download of Java SE Development Kit 8 Update 6 Demos and Samples for ARM.

The video below show the demo of Java2Demo run on Raspberry Pi.
  • This Java2D demo consists of a set of demos housed in one GUI framework that uses a JTabbedPane.  You can access different groups of demos by clicking the tabs at the top of the pane. There are demo groups for Arcs_Curves, Clipping, Colors, Composite, Fonts, Images, Lines, Mix, Paint, Paths and Transforms.  On the right-hand side of the pane, the GUI framework features individual and global controls for changing graphics attributes. There's also a memory-usage monitor, and a monitor for tracking the performance, in frames per second, of animation demos.

Download and unpack the Java SE Development Kit 8 Update 6 Demos and Samples for ARM, copy file /demo/jfc/Java2D/Java2Demo.jar to Raspberry Pi, run the command on Raspberry Pi in Terminal (under X-window environment).

java -jar Java2Demo.jar

Direct run on Raspberry Pi, output to HDMI:

Monday, August 4, 2014

VLC Media Player on Linux to capture Raspberry Pi RCA video output

The post "Capture Raspberry Pi RCA video output with USB Video Adapter" show how to run on Windows. On Linux platform, we can do the same thing to capture video from Easy CAPture USB Video Adapter with VLC Media Player.

Install and install VLC Media Player on Ubuntu, search vlc in Ubuntu Software Center.


Start VLC media player (Sound & Video -> VLC media player)

Media -> Open Capture Device...

- Select Video camera in Capture mode.
- Try select Video and Audio device name.
- Select NTSC in Video standard.
- Play.



Sunday, August 3, 2014

Run JavaFX application on Raspberry Pi remotely from Netbeans 8

With Remote Platform set up on Netbeans 8, we can also develop JavaFX application on host computer running Netbeans, run the application remotely on Raspberry Pi. In case of Java FX application running on Raspberry Pi, it will display on Raspberry Pi monitor, instead of console.

Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi

With Netbeans 8 installed on host computer and Java SE 8 on Raspberry Pi, we can set up remote platform on Netbeans 8. Such that we can develop Java application using Netbeans on host and deploy on Raspberry Pi remotely, all within Netbeans IDE.

It's assumed Java SE 8 have been installed on your Raspberry Pi as in last post "Install JDK 8 on Raspberry Pi and set JAVA_HOME and PATH".

In host PC (Ubuntu in my case) start Netbeans 8.

Click Tools -> Java Platforms

Click Add Platform...


Select Remote Java Standard Edition and click Next >


Name your new Remote Platform, and enter other information:
- 192.168.1.104 is the IP address of your remote Raspberry Pi.
- pi, the user in Raspberry Pi, and also enter password.
- /opt/jdk1.8.0_06 in Remote JRE Path is the JDK 8 installed location on Raspberry Pi, in last post.

(Updated@2014-09-17) for New Raspbian (2014-09-09) come with Java 8, set Remote JRE Path to default location /usr. ~ Setup Netbeans Remote Platform for default Java 8 in new Raspbian

Then finish.



This video show the steps:


Deploy Java application on Raspberry Pi remotely from Netbeans 8

Create Java Application in Netbeans as normal case. To Run it using the Remote Platform (created in previous steps):

Right click on Project -> Propertiers.

Select Run tab. Select the new created Remote Platform in Runtime Platform, and name the new Configuration.


Then you can run the application on remote Raspberry Pi by running it in this new configuration.



Once Remote Platform setup in your Netbeans IDE, you can also
development JavaFX application on Nerbeans 8, and run it remotely on Raspberry Pi
- remote debug Java program on Raspberry Pi
Cross compile Java/Swing program for Raspberry Pi



Install JDK 8 on Raspberry Pi and set JAVA_HOME and PATH


Updated@2015-03-24:
The new Raspbian come with java 1.8.0 with path set, but no JAVA_HOME.
If you need set JAVA_HOME for the preload java in new Raspbian, refer to my updated post "Set JAVA_HOME for Raspbian pre-loaded java 1.8.0".



This post show how to download JDK 8 on a host computer running Ubuntu Linux (not on Raspberry Pi), then copy to Raspberry Pi, ssh to Pi to setup JDK 8 and set JAVA_HOME and PATH in .bashrc.



To download JDK 8 on a host computer, visit: http://www.oracle.com/technetwork/java/javase/downloads/index.html, follow the steps to download Java SE Development Kit (JDK) for ARM.

In the following steps,
  • jdk-8u6-linux-arm-vfp-hflt.tar.gz is the downloaded file
  • 192.168.1.104 is the IP address of Raspberry Pi
  • pi is the user in Raspberry Pi
Open Terminal, switch to the download folder.

Run the command to copy the downloaded file to Raspberry Pi:
$ scp jdk-8u6-linux-arm-vfp-hflt.tar.gz pi@192.168.1.104:

Log-in Raspberry Pi via ssh:
$ ssh -X 192.168.1.104 -l pi
(-X is option)

Un-pack the file to /opt
$ sudo tar -zxvf jdk-8u6-linux-arm-vfp-hflt.tar.gz -C /opt

Edit .bashrc, to set JAVA_HOME and PATH:
$ nano .bashrc

Add the two line
export JAVA_HOME=/opt/jdk1.8.0_06
export PATH=$JAVA_HOME/bin:$PATH

where /opt/jdk1.8.0_06 is the unpacked folder of the new JDK.

Finally reboot Raspberry Pi.



Related:
- Try demo of Java SE 8 for ARM on Raspberry Pi

Saturday, August 2, 2014

The MagPi magazine issue 26 released, with introduction of The Model B+

This month’s MagPi contains another great selection of hardware, software and programming articles. Michael Giles explains how to turn your Raspberry Pi into a magic wand with a fun hardware project that demonstrates the persistence of vision effect, while John Mahorney from Suncoast Science Center in Florida shows how a Raspberry Pi is used to display dynamic art. Big news this month is the launch of the Model B+ and MagPi writer Aaron Shaw has all the details for you on page 22.

Robotics is always a popular theme and Harry Gee continues on from last month’s article and shows how to add speech, voice control and facial recognition to your robot. Additionally, Rishi Deshpande describes how to use the SmartDrive controller board to easily control high current motors.

Another popular topic is beer and Sebastian Duell explains his hardware and software “Mashberry” project which he uses to optimise the mashing process. Karl-Ludwig Butte continues his series on using a Raspberry Pi and BitScope for electronic measurement plus we have an interesting article by Walberto Abad on how to set up your own VoIP telephone system.

Last, but definitely not least, Jon Silvera continues his series on learning how to program with FUZE BASIC. This is an exciting article with lots to discover. I certainly don’t remember ever being able to control sprites this easily with BASIC!

Visit: http://www.themagpi.com/issue/issue-26/

Friday, August 1, 2014

Java 8 and Embedded JavaFX

Presentation on using the new embedded features in Java 8, including JavaFX on devices like the Raspberry Pi and Lego Mindstorms EV3. Also covers JavaFX on tablets and smartphones.