Raspbian Wheezy on Raspberry Pi Setup

On this page:

Introduction

This document will describe the Initial setup of Site Controller on an Raspbian Wheezy installation. Raspbian is a standard OS for the Raspberry PI

Prerequisites

You will need to know the IP of the system and to have access via ssh.

Required installation files

  • SiteController installation archive (e.g. SiteController-install-1.1-Jever.tar.gz):  SiteController modules and necessary python libraries 


SiteController is available through official purchase of a license or directly through azeti for development tests / integration tests. Upload the required files to the ubuntu server, e.g. in /root/download and proceed from there.

Configure the time zone

Timezone configuration

Before you begin the installation, make sure that you have the system with the right time configuration and a timezone configured in your system. Please read the file /etc/timezone to check that it is including your location. This file should contain a pair (Example: Europe/Berlin), that corresponds to the names that you can find in /usr/share/zoneinfo.

Core software installation

All the following commands must be done as root. You can add "sudo" to the beginning of all the commands or use "sudo su" in order to be root and continue with the instructions.


Once the system is installed, you will need to do a basic configuration of the system in order to connect to the cloud server. You should have received all the credentials beforehand, contact your provider in case you miss some information.

  1. Install prerequisites for compiling packages

    raspberrypi:/home/pi/SiteController-install# apt-get install python-dev
  2. Install mosquitto, create a mosquitto group and user.

    The default mosquitto package in the raspbian repositories is before version 1.0. You must add the special mosquitto.org repository to retrieve the latest debian package (version 1.4 or higher). The next step is a short version of the full instructions, taken from mosquitto.org, which you can find here.

    root@raspberrypi:~# wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
    root@raspberrypi:~# apt-key add mosquitto-repo.gpg.key
    root@raspberrypi:~# cd /etc/apt/sources.list.d/
    root@raspberrypi:~# wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
    root@raspberrypi:~# apt-get update
    root@raspberrypi:~# apt-get install mosquitto
    
  3. Install SiteController (output was truncated)

    raspberrypi:/home/pi/SiteController-install# ./setup.sh
    WARNING: at least Python version 2.7.9 is required for TLS support
    Press [a] to abort, any other key to continue!
    OS type is raspbian
    Checking for previous installation of SiteController ...
    Found a previous installation in /opt/azeti/SiteController. Stopping SiteController ...
    Creating backup ...
        Using tar with bzip2 ...
    Creating new site controller startup configuration ...
    Installing python libraries ...
    Checking python module setuptools, version 12.2 ... already installed.
    Checking python module Crypto, version 2.6.1 ... not installed.
    Checking python module psutil, version 2.2.1 ... not installed.
    Checking python module pytz, version 2014.7 ... not installed.
    Checking python module bitstring, version 3.1.3 ... not installed.
    Checking python module pyasn1, version 0.1.7 ... not installed.
    Checking python module pysnmp, version 4.2.5 ... not installed.
    Checking python module pyxb, version 1.2.3 ... not installed.
    Checking python module serial, version 2.7 ... different version (2.5) installed. WARNING: That version might be incompatible with this product.
    Checking python module six, version 1.9.0 ... not installed.
    Checking python module apscheduler, version 3.0.0 ... not installed.
    Checking python module paho.mqtt, version 1.1 ... not installed.
    Checking python module pyftpdlib, version 1.4.0 ... not installed.
    Installing pycrypto-2.6.1.tar.gz ...
    Installing psutil-2.2.1.tar.gz ...
    Installing pytz-2014.7.tar.gz ...
    Installing bitstring-3.1.3.tar.gz ...
    Installing tzlocal-1.1.2.zip ...
    Installing futures-2.1.6.tar.gz ...
    Installing pyasn1-0.1.7.tar.gz ...
    Installing pysnmp-4.2.5.tar.gz ...
    Installing PyXB-1.2.3.tar.gz ...
    Installing modbus-tk-0.4.2.tar.gz ...
    Installing six-1.9.0.tar.gz ...
    Installing APScheduler-3.0.0.tar.gz ...
    Installing paho-mqtt-1.1.tar.gz ...
    Installing pyftpdlib-1.4.0.tar.gz ...
    Installing SiteController ...
    Creating config folder ...
    Copying default configuration ...
    Installing new source files ...
    Creating log folder ...
    Creating tmp folder ...
    Creating persists folder ...
    Updating autostart script ...
    Adapting configuration to your system ...
    Changing serial devices in SiteController from "" to "/dev/ttyRPC0".
    Please provide a unique serial name for your SiteController!
    Allowed characters are upper and lower case ASCII [a-zA-Z],
    digits [0-9], dashes - and underlines _.
    Your entry: > raspi-test-sebastian
    Serial name set to raspi-test-sebastian
    Thank you.
    Changing serial id of SiteController from "" to "raspi-test-sebastian".
    
    
    /opt/azeti/SiteController/config/SiteController.cfg has been modified.
    # configure the paths according to your system
    SC_HOST_TYPE=RasPi
    SC_HOME_FOLDER=/opt/azeti/SiteController
    CONFIG_FOLDER=/opt/azeti/SiteController/config
    LOG_DESTINATION=/opt/azeti/SiteController/log
    TMP_DESTINATION=/opt/azeti/SiteController/tmp
    PERSIST_DESTINATION=/opt/azeti/SiteController/persistent
    MOSQUITTO_FOLDER=/opt
    MOSQUITTO_CFG_FOLDER=/etc/mosquitto
    
    # chose which modules you need by setting the variable to "Yes"
    START_CLOUD_MODULES="Yes"
    START_AUTOMATION_CONTROLLER="No"
    START_VIRTUAL_SENSORS="No"
    START_MODBUS="No"
    START_UDP_ADAM="No"
    START_SNMP="No"
    START_HTTP_MODULES="No"
    START_GPIO_MODULES="No"
    START_LOCAL_STORAGE="No"
    START_SIMULATOR="No"
    
    Please check SiteController.conf (content is shown above)
    and the configurations in "/opt/azeti/SiteController/config".
    Adapt them to your needs, then start the controller with
    the following line (copy the complete line, there are two
    quotes in it):
    
        "/opt/azeti/SiteController/run_SiteController.py" start
    
    
    
  4. A known issue is

Known Issues

A known caveat in current SiteController versions is the mosquitto path that has to be set properly, depending on OS. You will see following error if it isn't set, the SiteController will not be able to restart the mosquitto due to the wrong path.

raspberrypi:/opt/azeti/SiteController# ./run_SiteController.py restart
Time zone set to: Etc/UTC
Module wtsc_simulator.py is not running.
...
Stopping mosquitto
Starting mosquitto ...
Traceback (most recent call last):
  File "./run_SiteController.py", line 1540, in <module>
    exit_code = main(sys.argv)
  File "./run_SiteController.py", line 1518, in main
    start_mosquitto()
  File "./run_SiteController.py", line 1026, in start_mosquitto
    '-d'])
  File "./run_SiteController.py", line 707, in start_submodule
    LOGGER.exception('Exception while trying to run command "%s":' % cmd)
AttributeError: 'NoneType' object has no attribute 'exception'

For raspbian you must change the path properly. Below is a search and replace command, you could also use an editor and change the directive to MOSQUITTO_FOLDER=/usr.

raspberrypi:~# sed -i 's/MOSQUITTO_FOLDER=\/opt/MOSQUITTO_FOLDER=\/usr/g' /opt/azeti/SiteController/SiteController.conf

Starting the system

  1. Start the SiteController, it will start the mosquitto automatically if necessary 

    raspberrypi:~# /opt/azeti/SiteController/run_SiteController.py start

    Please stay 2 minutes in the terminal after the start of the site controller. If there is a problem in the system the modules will launch an exception. If no exception came in 2 minutes, the system is up and running with no issues.

  2. Once everything is started, you can use the following command to check that all modules are up and running:
    1. SiteController Status, note that required modules should be marked green and running

      raspberrypi:~# /opt/azeti/SiteController/run_SiteController.py status
      WARNING: section SiteController.conf not contained in SiteController.cfg.
      Time zone set to: Etc/UTC
      Serial of this installation: skoch-ubuntu01
      Main version of this installation: 1.1.0_(Build:1228_c300ebc)
      OK: Integrity check passed.
      OK: Module Watchdog.py is running with PID (21268)
      OK: Module cloudConnector.py is running with PID (21277)
      OK: Module HD2CloudExporter.py is running with PID (21284)
      OK: Module ConfigProvider.py is running with PID (21289)
      OK: Module RawResultsDeMux.py is running with PID (21296)
      OK: Module CalibResultsEvaluator.py is running with PID (21302)
      OK: Module JobProcessor.py is running with PID (21306)
      OK: Module AutomationController.py is running with PID (21310)
      OK: Module VirtualSensorProvider.py is running with PID (21316)
      OK: Module ModbusDaemon/ModbusMaster.py is running with PID (21322)
      OK: Module UDPserver_AdvantechAdam60xx.py is running with PID (21330)
      OK: Module trapd.py is running with PID (21334)
      OK: Module snmpgetd.py is running with PID (21339)
      OK: Module http_server.py is running with PID (21347)
      OK: Module persistord.py is running with PID (21354)
      WARNING: Module VS_fill_quantity.py is not running.
      WARNING: Module VS_flow_rate.py is not running.
      WARNING: Module VS_tank_simulator.py is not running.
      WARNING: Module VS_access_control.py is not running.
      WARNING: Module VS_battery_details.py is not running.
      WARNING: Module VS_HistoryAnalyser.py is not running.
      WARNING: Module VS_filesize.py is not running.
      OK: Module mosquitto daemon is running with PID (21265)
      root@ubuntu:~# 
  3. Once the system is up and running, and if no errors are appearing in your command line or in the logs, you can proceed to delete the installation compressed files and uncompressed folders to save space in the device.