IMG_20140227_153625 (2) thin

AberCam Upgrade 3 – Wind!

Got a wind speed sensor from Maplin’s Ebay shop for ¬£2.50. Stuck it in a bit of polystyrene and used my computer’s case fans to blow air at it for testing purposes. I imagined there would be a little motor in there, and different (tiny) voltages would determine how fast it was spinning – nope that was wrong. What happens (I imagine with a magnet and reed switch, as I’ve found some use that) is that every half a revolution, it makes (or breaks, can’t remember) the circuit, so I just plugged this straight onto my breadboard where I had been testing push-to-make buttons with Python, Pi GPIO and interrupts (really easy to do, and eats 90% less CPU than just having the script whirl round in a while True: loop).

wind sensor

After a bit of maths to convert the RPM to mph (basically speed = distance/time, and time = 1/frequency(rpm)) I started to get some realistic values. Also after some research, most desk fans blow air at about 4mph if you are a foot or two away from it, so used one to test my results were feasible.

Next I got a bit of wood, drilled some holes in the end of it so the wind speed sensor and its wire could be secured, and stuck it out the window.

abercam looking at wind speed sensor

Other News

In other news, I was in some credits!


Some of the footage taken by me of the Aberystwyth storms made it into the programme “The Storm That Stole Christmas” on Channel 4 (27th Feb, 9pm), so I was listed in the credits!


AberCam Upgrade 2 – Focus

Had the problem that AberCam’s webcam with its autofocus kept focusing on the dirty window that it was sat behind, so had a look to see if it was possible to stop the webcam autofocusing, and stumbled upon this great tool called¬†uvcdynctrl. Downloadable here (or for the pi, use apt-get install uvcdynctrl), and there are some examples and a list of functions and explanations here.

With uvcdynctrl, you can stop the camera autofocusing (uvcdynctrl -d /dev/video0 [if its the only camera - video zero] -s [set] “Focus, Auto” [param] 0 [value - zero in this case].

A good idea is to -g [param] before you set it, so you know what the parameter was set to before you changed it. Also you can -S (capital S) and save a backup of the config file.

Another feature is being able to edit the zoom! e.g: uvcdynctrl -s “Focus (absolute)” 3 [try values 1-5 inclusive].

Also just found a great feature – uvcdynctrl -vc (verbose list of controls – tells you the bounds and step sizes for each param!)

Currently playing with the pan and tilt (e.g of a zoomed in image, my camera doesn’t physically move), managed to get them to each set once, but once attempted to be set, each defaults to the value 36000 and won’t move again. Looks like it could be to do with the webcam driver – oh well, not essential.

Looking at buying a little wind speed sensor to compliment AberCam’s temperature sensor!

AberCam’s focused view:

abercam view

Abercam Upgrade

Finally got around to adding the temperature sensor to Abercam. The temperature sensors I got (DS18B20 ones I believe) use the Dallas 1-Wire protocol to communicate with the Pi, meaning you can attach many temperature sensors in parallel, and the Pi can differentiate between them all and interrogate them individually, without having to use tons of GPIO pins, one for each sensor.

I dug out a 4.7k ohm resistor that I used for this Adafruit tutorial regarding temp sensing on the Pi, and used PHP from this YouTube video to get the temperature.

The PHP script simply opens the w1_slave files, finds and nicely formats the temperature. The HTML uses JQuery to request the .php file every 5 seconds and updates the HTML accordingly.


Hang about, I haven’t got PHP on my Pi

No problem, if you aren’t using a LAMP server – e.g I’m using lighttpd for my webserver, install php with the command:

sudo apt-get install php5-common php5-cgi php5


This guide I have refered to suggests installing the PHP MySQL libraries if you are using MySQL. Another good, similar, guide is here.

sudo apt-get install php5-mysql


After, enable the fastcgi-php module and reload the server:

sudo lighty-enable-mod fastcgi-php

sudo service lighttpd force-reload

Abercam with temp

That all works lovely on a local network, but when using my website to try and access the Pi to get the temperature, I ran into the problem of being stopped from accessing another server and displaying its information on my webpage due to the threat of cross-site scripting attacks. Ways to get round this are make an API or possibly use cURL. I also considered using FTP to upload a file every minute from the Pi containing the current temperature, which would be included in the webpage. Currently, I am using the below script, with a 20 second timeout, and the line “header(‘Access-Control-Allow-Origin: *’);” in the php file it is accessing.

This works really well now, with the page requesting an updated temperature every 20 seconds. Might have to revert to the FTP solution if getting the temp from the Pi is too slow or causes it too much extra traffic.



The Scripts


//File to read
$file = ‘/sys/bus/w1/devices/28-000004abb89f/w1_slave’;

//Read the file line by line
$lines = file($file);

//Get the temp from second line
$temp = explode (‘=’, $lines[1]);

//Setup some nice formatting
$temp = number_format($temp[1] / 1000, 1, ‘.’, ”);

echo $temp;



<script src=”” type=”text/javascript”></script>

<script type=”text/javascript”>

function refreshTemp(){
$(‘#tempHolder’).load(‘temp.php’, function(){
setTimeout(refreshTemp, 5000);
<div id=”tempHolder”></div>


Abercam Viewers, Pi Rover, PiMS


As we have been in the middle of a good storm here in Aberystwyth, Abercam has again been getting a good few hundred different people viewing it every day, and over 3000 page views this month. As well as streaming live images of Aberystwyth all over the world, I also tasked it with taking a snapshot every couple of seconds, which I have made into time lapses and stuck on YouTube here.

abercam shots


Pi Rover

Found this great YouTube video of a chap who has done many different random things such as making a little printer and milling machine using the Pi, but what interested me most was he has also built a Pi Car… And you can drive his little Pi Rover here:¬†



PiMS? Yes it has Pi in it. Its the topic I have chosen for my dissertation here in my final year at Aberystwyth. I will be creating a Raspberry Pi Management System that will manage engines such as those found in the Internal Fire Museum of Power in Cardigan. The system will monitor different temperatures, fluid levels (water/oil/fuel etc) and engine speed, notifying museum staff if any of these falls outside a set range.


Now back to work…