2.6.1 Raspberry Basic Software

10 minute read

Installation of Raspberry Pi to enable IoT Adaptors

This installation guide describes the installation of necessary prerequisites of the Raspberry PIs in order to enable the installation of IoT Adapters that are used to establish communication between the modelling tool and the physical objects. It contains the following sections:

  • Installation of the base system: the core operating system is installed and necessary configurations are performed
  • Installation of the required software dependencies
  • Installation of the IoT Adapters for the Dobot Arm and the mbot

1. Installation of the Operating System - Raspbian The following prerequisites are necessary:

  • Raspberry PI 3 is assembled and connected to a TV/Screen via HDMI.
  • A keyboard and mouse are connected via USB. An SD card with 32GB is available.

This guide provides an overview on the installation procedures based on:

For more information, please refer to the aforementioned original Raspberry-Pi links.

Installation Procedure:

  1. Preparation of the SD card: a prerequisite is to have a blank SD card formatted. For formatting the SD card on Windows, use the SD Association’s Formatting Tool, which can be downloaded from sdcard.org. Instructions for using the tool are available on the same site. The SD card should be formatted as FAT.
  2. Download the NOOBS package and extract: NOOBS is used to install the operating system. Download NOOBS from http://raspberrypi.org/downloads.
  3. Copy to SD card: Copy the extracted files onto the SD card that you just formatted, so that this file is at the root directory of the SD card. Please note that in some cases it may extract the files into a folder; if this is the case, then please copy across the files from inside the folder rather than the folder itself.
  4. Insert SD card into Raspberry and start: put the SD card into the Raspberry and boot it by connecting it to the electric power via a Micro-USB cable and to the monitor via HDMI. NOOBs performs a FAT check and resize and provides you with the following screen.
  5. Connect to WIFI network: Connect to a WIFI network to enable remote installation of Raspbian. The connection manager is available in the top menu.
  6. Select Raspbian (pre-selected) and click on install to start the automated installation process.
  7. Initial boot and base configuration: After a reboot, the Raspberry starts into the desktop mode. Hence, the following configurations are required to setup the Raspberry-Pi for the physical devices.
    • System update: The first action after the successful installation of the operating system is to run an update. This update is performed by opening a terminal and run the following commands:

sudo apt-get update

sudo apt-get upgrade

Both commands require the super user password, which is after installation by default “raspberry” in order to confirm the installation of the packages.

  • Network Configuration: Connect to WIFI network. This information is persistently stored in the operating system. The configuration is started using the network button in the taskbar.
  • Perform RaspiConfig: Start the configuration interface to change the base configuration parameters:

First, change “boot” from “To Desktop” to “To CLI to switch to Command Line Interface (CLI). This is needed to run the Raspberry-Pi without screen and hence interact remotely with the command line interface.

Second, change the hostname to:

  • “dobot_raspberry” when configuring for the Dobot Magician and
  • “mbot_raspberry” when configuring for the Makeblock mbots.

Third, change the password of the default user “pi” to a secure password of your choice and take note of it for future use.

Forth, click on “Expand filesystem” to resize the SD card to the maximum available space.

Fifth, switch to the interfaces tab and change the access rights of the user interface. Enable the communication via “Serial” and “SSH.”

Sixth, confirm the configuration with “OK”, which enforces a restart. The Raspberry Pi is now ready for configuration and installation. After re-configuration, the Raspberry Pi starts on command line interface (CLI).

2. Installation of the Required Software Login to command shell interface after restart of the Raspberry-PI in order to configure the IP address of the Raspberry-PI and install dependencies for the software.

2.1. Configuration of the IP Address The first step is to assign a static IP address to the Raspberry-Pi that matches the IP addresses invoked from the modelling tools.

  1. Open the file /etc/dhcpcd.conf by using a text editor of your choice. The following we assume the text editor nano is used.
  2. To define a static IP address, run the following:

sudo nano /etc/dhcpcd.conf

interface wlan0

*static ip_address=/*

*static routers=*

*static domain_name_servers=*

  1. Reboot the Raspberry-Pi to ensure that the changes are effective (sudo reboot). Verify that the IP is effective by pinging the Raspberry-Pi from another device in the same network. In case the ping was successful, the Raspberry-Pi can now be connected by login in via SSH.

2.2. Install Software to operate the IoT Adaptor The second step is to install the Java Environment, the Apache Tomcat as the basis for the IoT Adaptors.

  1. Install the Java Environment – OpenJDK 8 - that is required to run the application server. The following command line executes the installation: sudo apt-get install -y galternatives openjdk-8-jdk
  2. Install the Application Server (Apache Tomcat (8.5.40)) that hosts the IoT Adapter and hence enables the access from the modelling toolkits via http requests. The installation procedure to install Tomcat as a service is published online at www.linuxize.com/.

Run the following commands one by one:

sudo apt install unzip wget

sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat

sudo adduser tomcat dialout

cd /tmp

wget https://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.zip

unzip apache-tomcat-.zip*

sudo mkdir -p /opt/tomcat

sudo mv apache-tomcat-8.5.40 /opt/tomcat/

sudo ln -s /opt/tomcat/apache-tomcat-8.5.40 /opt/tomcat/latest

sudo chown -R tomcat: /opt/tomcat

sudo sh -c ‘chmod +x /opt/tomcat/latest/bin/.sh’*

sudo nano /etc/systemd/system/tomcat.service

[Unit] Description=Tomcat 8.5 servlet container

After=network.target

[Service] Type=forking

User=tomcat

Group=tomcat

Environment=”JAVA_HOME=/usr/lib/jvm/default-java”

Environment=”JAVA_OPTS=-Djava.security.egd=file:///dev/random”

Environment=”CATALINA_BASE=/opt/tomcat/latest”

Environment=”CATALINA_HOME=/opt/tomcat/latest”

Environment=”CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid”

Environment=”CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC”

ExecStart=/opt/tomcat/latest/bin/startup.sh

ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[Install] WantedBy=multi-user.target

sudo systemctl daemon-reload

sudo systemctl start tomcat

Verify that the installation of the Tomcat was successfully by navigating with a browser that is in the same network to http://<RASPBERRY_IP:8080/ from another computer (ideally from the computer that has the modelling tools installed).

Information

Usage

Updated: