Blitz Manual
 

RaspberryPi Server Setup Guide

1. Introduction

The aim of this document is to provide a set of instructions for configuring the RaspberryPi to act as a Blitz Logger "server". It is intended to be followed sequentially.

1.1 Definitions

Terminal: the command line interface on the RaspberryPi, accessed by clicking the LXTerminal icon on the desktop

1.2 References

(1) Raspbi Distribution

(2) SD card writing instructions

(3) Troubleshooting

1.3 Overview

The Blitz Logger is a low cost data logger which is being designed for lab based application and also to provide live wireless telemetry and downloadable data logging for mobile applications. The software is designed to be networked and multi-user.

2. RaspberryPi Distribution

2.1. Downloading

The RaspberryPi distribution used is the basic Wheezy Raspbian available from the RaspberryPi downloads page. Download the image and unpack.

2.2. Installing

Instructions for writing an image to an SD card can be found at [2]. Using win32diskimager, perform the following steps:

  1. STEP 1
  2. STEP 2

Steps?

If the RaspberryPi doesn't boot, you may need to update the kernel.img file and start.elf on the SD card. Visit [3] and download the links to these files, then drag and drop them on to your SD card, replacing the existing ones.

2.3. Configuration

Insert the SD card with image into the RaspberryPi, connect power, keyboard and mouse and the HDMI-DVI adapter to your monitor. Leave the Wi-Fi adapter (if any) unplugged and use an Ethernet cable for network connection. When the device boots set the following options

  1. Expand file system to fit card
  2. Change the password to something other than raspberry (I often just use a space)
  3. Optionally change the internationalisation options to your region in particular the keyboard layout
  4. Make sure the boot option is set to boot to terminal
  5. In advanced options change the memory split to 32 for the GPU

Select <finish> and reboot the device to save changes. You will need to login with the username pi and whatever password you set above.

2.4. Autologin on boot

To automatically login to the console we need to edit some config files

$ sudo vi /etc/inittab

Find the line:

1:2345:respawn:/sbin/getty --noclear 38400 tty1

Replace with

1:2345:respawn:/sbin/getty --autologin pi --noclear 38400 tty1

2.5. Configure the network connection

To start with, use a network cable plugged into a DHCP enabled router to configure and install updates.

We need to configure our network adapter. From the command line by type

$ sudo vi /etc/network/interfaces

Then change the file so that it contains the following:

auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp

When you are finished save (escape then :wq) and reboot through the terminal:

$ sudo reboot

Set up the network configuration (as an ad-hoc wifi network by pasting in the following configuration file into /etc/network/interfaces: Later on we will add: allow-hotplug wlan0 auto wlan0 iface wlan0 inet static address 192.168.1.55 netmask 255.255.255.0 wireless-channel 1 wireless-essid telemetry wireless-mode ad-hoc

3. Software Installation

Many of the following instructions are carried out in the terminal. These are indicated with a $ symbol to let you know that everything after but not including the dollar sign should be entered into the terminal.

3.2. Install updates

Firstly update the software by typing the following two commands (which may take some time)

$ sudo apt-get update
$ sudo apt-get upgrade

Then install essential items for building and installing. (These may already be installed and up to date)

$ sudo apt-get install build-essential git-core vim  
$ sudo apt-get install python-pip python-dev
$ sudo apt-get install arduino rpi-update ca-certificates ntpdate

We can then update the time zone

$ sudo ntpdate -u ntp.ubuntu.com

3.2.1 Update the RaspberryPi Firmware

To get the latest firmware run

$ sudo UPDATE_SELF=0 rpi-update

3.3.Install Required Software for Blitz

3.3.1. Redis

Redis is used to store logged data on the server

$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xvzf redis-stable.tar.gz
$ cd redis-stable
$ make
$ cd src
$ sudo cp redis-server /usr/local/bin
$ sudo cp redis-cli /usr/local/bin
$ cd ..
$ cd ..
$ rm redis-stable.tar.gz

To start Redis on application start using an init script, do the following:

$ cd redis-stable
$ sudo mkdir /etc/redis
$ sudo mkdir /var/redis
$ sudo cp utils/redis_init_script /etc/init.d/redis_6379
$ sudo cp redis.conf /etc/redis/6379.conf
$ sudo mkdir /var/redis/6379
$ sudo vim /etc/redis/6379.conf

In the configuration file set the following options:

Save and then in the console set up the init.d file to run on startup

$ sudo update-rc.d redis_6379 defaults

3.3.2. ZeroMQ

ZeroMQ is used for client/server communications over a network

$ sudo apt-get install libzmq-dev

3.4. Install Blitz Software

The blitz software is the actual data acquisition system. It is is simply a Python script so we can clone the latest software update from the Blitz github repository. We save this into our home directory as follows:

$ cd ~/
$ git clone https://github.com/will-hart/blitz.git       

3.5. Python Dependencies

We can use pip to install our requirements (which are listed in the requirements_server.txt file:

$ cd blitz
$ sudo pip install –r requirements_server.txt

3.6. Set the server to autorun on boot

Then we want to ensure that the server runs on boot. We will use upstart to build a script. To install upstart:

$ sudo apt-get install upstart

You will need to type in a sentence to get this to install as it replaces sysvinit which can potentially cause the device to stop working if things go wrong. As soon as installation finshes:

$ sudo halt

Wait until it shuts down, remove the power and wait a few seconds before powering up again. Next lets create the script which starts the blitz server (and restarts it on a crash):

$ sudo vim /etc/init/blitz.conf

When the file opens, add the following script:

description "Runs the Blitz Server on startup"
author "William Hart"

start on runlevel [2345]
stop on runlevel [016]
chdir /home/pi/
exec python /home/pi/blitz/start_server.py
respawn

This script runs the python script for starting the server and restarts it if the script exits. To get the script running type

$ sudo service blitz start

3.7. Remove Non-essential Software

You can optionally remove software that is not required to free up some disk space:

$ sudo apt-get autoremove scratch dillo wolfram-engine

4. Configure for “headless” operation

5. Save a backup image