Raspberry Pi Installation (Java Server)

9H5G edited this page Dec 14, 2016 · 9 revisions

Getting Started

To coincide With the release of the Raspberry Pi 3, we thought it would be good to create a "How to" Guide for installing Signal K on a Raspberry Pi (RPi). This is being written whilst installing on a new RPi 3, but it should be applicable for earlier models.

So you have your RPi and are "chomping at the bit" to start using it. Well before we start make sure you have the following items...

  1. A network to connect the RPi to (via Wi-Fi or wire)
  2. An HDMI monitor or TV
  3. A USB mouse
  4. A USB keyboard
  5. An 8GB or larger micro SD Card
  6. A Windows PC or Mac that can read micro SD Cards via a card reader or SD slot+adaptor

First you need to install a LINUX operating system on to the micro SD Card but before you do that format the card using the SD Card foundations Formatting tool, which you can download from here...

https://www.sdcard.org/downloads/formatter_4/

There is a version for Windows or Mac OSX and after downloading the tool of choice, extract and run the Setup program. Once installed, run the program with the micro SD plugged in to a card reader or SD card slot on the computer. It is good practice to give the card a volume name such as "Signal_K" which will remind you what is on the card at a later date as one LINUX distribution card looks much the same as another.

If you intend to use the Raspberry Pi for other things, not just Signal K, I would strongly recommend preparing one SD Card for the Signal K installation and have another SD Card with a normal Raspberry Pi installation and then you can keep things separate and clean.

SD Card Formatter

Once your SD Card is properly formatted, we need to copy a LINUX Operating System on to it. To make things easy the nice people at RaspberryPi.org have created a "NOOBs" distribution which can be downloaded from here....

https://www.raspberrypi.org/downloads/noobs/

Select the NOOBs option on the left hand side (not the NOOBs Lite) and click on the "Download Zip" button. It is quite a large file approximately 1GB, so make sure you have a fast internet connection i.e. don't leave it till you get down on the boat !

Once downloaded open the ZIP file and extract all files/folders to your blank and freshly formatted micro SD Card. Once the copy operation is complete, insert the micro SD Card in to the RPi with the unit powered down. With all of the cables and peripherals plugged in, power up your Raspberry Pi and follow the instructions that appear on the screen. With the latest "Jessie" release the amount of options you need to select are significantly reduced and the whole operation should only take 10-15mins.

After everything has been configured you should be presented with the RPi Desktop and your LINUX operating system is installed and running, just waiting for you to install Signal K.

Raspberry Pi Desktop

Installing Signal K

The RPi installation of Signal K can be broken down in to three distinct steps;

  1. Install the tools and libraries required to run the Signal K server (the dependencies)
  2. Install a Signal K Server to process the Signal K data; we will install the Java-Server
  3. Install the Web Apps (consumers) that can read Signal K data

Step 1 - Install the Dependencies

Raspbian the LINUX distribution for RPi is based on Debian which has a powerful installation tool called "apt-get", which we will use to install some of the dependencies and tools required. Before you use "apt-get" it is always recommended to update its index of repositories (websites that store LINUX software) and to do that use the following command...

$ sudo apt-get update

Now we will download three tools; curl, git and build-essential. These tools will allow us to download more software, clone the Signal K server and allow it to run, Install the three tools using the following command...

$ sudo apt-get install -y curl git build-essential oracle-java8-jdk

Verify that Oracle Java(TM) is the default on your system:

$ sudo update-alternatives --display java
java - manual mode
  link currently points to /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java
...

The Raspbian Jessie - Lite image ships with openjdk 7 instead of the Oracle Java. The maintainer recommends the Oracle Java; Update the package alternatives database:

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                                   Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-armhf/jre/bin/java          1063      auto mode
  1            /usr/lib/jvm/java-7-openjdk-armhf/jre/bin/java          1063      manual mode
* 2            /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java   318       manual mode

Press enter to keep the current choice[*], or type selection number: 

Then we use curl to add the AdaFruit repository, followed by "apt-get" again to install Maven, a build installation tool for Java. At the same time we also install Node, which is not actually needed for the Signal K Java server, but which includes NPM which makes installing the consumer web apps easy.

$ curl -sLS https://apt.adafruit.com/add | sudo bash
$ sudo apt-get install maven node

(Note: you may have to check that jdk8 is the default after installing Maven - use: $ sudo update-alternatives --config java)

Once this has completed you can check that Node.js is installed OK, by typing...

$ node -v

and you should see "v0.12.11" appear or whatever the latest version is.

Finally we need to install a Bonjour (mDNS) service for LINUX called Avahi, which allows Apps and other network devices to Discover the Signal K server. To do this we will use "apt-get" again ...

$ sudo apt-get install libnss-mdns avahi-utils

To check if Avahi is installed and working correctly enter the following command...

$ avahi-browse -a

This will search for and list all of the discoverable devices/services on your network. Use ctrl+c to stop the search.

Avahi-Browse

Step 2 - Install Signal K Java Server

In this "How To" guide we are going to use the Signal K Java Server, but we also have a guide for the Node Server which is the other popular Signal K server.

A Signal K Server is the central hub of a Signal K system; reading and converting the boat's NMEA data (or Signal K data from a gateway), which it then stores and logs, before outputting the Signal K data to web apps (consumers) on the boat or sending it off the boat to other vessels or Cloud services.

To install the Java Server, we will first create a clone of all the Java Server source files that are on the GitHub repository by using the "git clone" command...

$ git clone https://github.com/SignalK/signalk-java.git

This will create a folder called "signalk-java" in the Home directory of your RPi. We need to switch in to this folder with the "cd" command, and then install and run the Java Server using Maven...

$ cd signalk-java
$ mvn exec:java

Maven will now complete the installation and run the Java Server. You should see a similar terminal output to that shown below, note the port number for the Java Server web interface is 8080...

Java Server Installer and Running

If you intend to use a web browser running on the Raspberry Pi to view the Java Servers popular Freeboard app, then the Epiphany browser that comes with Raspbian is not suitable as it does not display the chart data correctly and it is recommended to install IceWeasel (Firefox for RPi). To do this use apt-get to install the new browser...

$ sudo apt-get update
$ sudo apt-get install iceweasel

Once installed, open the IceWeasel web browser on your RPi and type this URL in to the address bar "http://127.0.0.1:8080/". This directs the browser to the Java Server on the RPi (127.0.0.1 is your local Loopback address) and you should see the following screen...

Java Server Web Interface

Step 3 - Install Signal K Consumers

A "Consumer" of Signal K data is any web app, mobile device app or software program that can read and use Signal K data. It is hoped that the number of consumers will grow rapidly as more developers discover this open format and dream up new applications to make boating easier, more efficient or just more fun.

The Java Server has a very simple "one click" web installer for installing Freeboard its native application, as well as two other Apps; Instrument Panel and Sailgauge. For the purposes of this "How to" we will install Freeboard, which is easily done by clicking on the "Install" button below the blue "Freeboard SK" button...

"One Click" App Installation

Installation will take a minute or so depending upon the speed of your internet connection and once complete you will either see some errors or an "Installation Complete" message...

Java Server Web Interface

Now you can go back to the main index page and click on the blue "Freeboard SK" button to run the Freeboard App...

Java Server Web Interface

If you have managed to get to the end of this guide, you will now have a good understanding of what Signal K is all about and in particular the Java Server. We have been using the server's demo file (select it in Configuration menu), but Java Server can also read NMEA0183 data via an NMEA to USB adaptor cable, NMEA2000 data via a 3rd party NMEA2000 gateway or both NMEA0183 and NMEA2000 via the new iKommunicate gateway.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.