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.
Terminal: the command line interface on the RaspberryPi, accessed by clicking the LXTerminal
icon on the desktop
(1) Raspbi Distribution
(2) SD card writing instructions
(3) Troubleshooting
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.
The RaspberryPi distribution used is the basic Wheezy Raspbian available from the RaspberryPi downloads page. Download the image and unpack.
Instructions for writing an image to an SD card can be found at [2]. Using win32diskimager, perform the following steps:
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.
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
raspberry
(I often just use a space)Select <finish>
and reboot the device to save changes. You will need to login with the username pi
and whatever password you set above.
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
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
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.
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
To get the latest firmware run
$ sudo UPDATE_SELF=0 rpi-update
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:
daemonize
to yes
pidfile
to /var/run/redis_6379.pid
loglevel
to notice
dir
to /var/redis/6379
Save and then in the console set up the init.d file to run on startup
$ sudo update-rc.d redis_6379 defaults
ZeroMQ is used for client/server communications over a network
$ sudo apt-get install libzmq-dev
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
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
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
You can optionally remove software that is not required to free up some disk space:
$ sudo apt-get autoremove scratch dillo wolfram-engine