IMG_20140516_201633 - Copy4

AberCam Minor Upgrades

With the weather now sunny and warm, AberCam’s tupperware box was acting like a greenhouse, with CPU and GPU temperatures soaring to 60°C+ (by contrast, they are now below 40°C). The solution to this included chopping up a belvita breakfast biscuit box (other breakfast biscuits are available) to shield its sides and top, the front of the box already has a silver heat shield to protect the camera from the sunlight.



For AberCam’s last couple of weeks of streaming, I have placed it outside the window again where it gets a slightly cleaner view. Also had to modify how the wind speed sensor was secured to the window, as it was previously held in place by the large and heavy window sitting on top of the end of the piece of wood. With the window now open, the safety ropes attached to the end of the wind speed sensor bit of wood have been clamped to the window sill, and a foam chock placed underneath to keep it vaguely level.



Starting Scripts on Start-up – Wind Speed Sensor

Cron is great for starting normal scripts on startup, but scripts that require sudo (administrator / superuser privileges) need to be run in a different way. During my dissertation, I found that init.d scripts can be used to easily start other scripts on boot, even ones requiring superuser access (e.g ones that access Pi hardware, like the GPIO pins). init.d script:

#! /bin/sh
# /etc/init.d/

# Provides: a0-windspeedsensor
# Required-Start: $remote_fs $syslog $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start wind speed sensor script
# Description: Start wind speed sensor script

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case “$1″ in
echo “Starting script”
# run application you want to start
/usr/bin/python /var/www/ &
echo “Killing”
# kill application you want to stop
PROCESSID=$(sudo ps aux | grep “/usr/bin/python” | grep “” | awk ‘{print $2}’ | awk “NR==1″); sudo kill -9 $PROCESSID
echo “Usage: /etc/init.d/ {start|stop}”
exit 1

exit 0


The first section is the init.d information, specifying what the script provides, and that it should be ran after all other scripts ($all).  It also specifies on which run levels the script will be started and stopped (e.g start when booting in all modes, stop when shutting down/rebooting etc).

In the start case, the windspeed python script is started, in the background. In the stop case, the process ID is found for the running script, and is then killed.

The script is named a0-…. so that it will run first before any other script that I create, which will be named a1, a2… as the scripts run in alphabetical order. This just keeps things tidy and running in a known order.

This script is placed into /etc/init.d/ then registered with the update-rc.d command e.g: sudo update-rc.d defaults. This will create relevant symbolic links in the relevant rc.d start up and shut down folders, so that the script will start on boot automatically. The permissions need to be set to 755 on the init.d script: sudo chmod 755

Give it a test, and you’re good to go!