Playing with raspberries

One key feature of the xBAM project I’m working on is cost. Normal BAMs retail for about £100k and I want to make a BAM for just £8k. In the Lego BAM, I used the Mindstorms package as a control system, but this is wholly unsuitable as it is expensive, proprietary and can’t do video processing. I also lack the skills to build a controller system from scratch (I think I did some electronics back when I was 15…). So the solution I came to was the fantastic Raspberry Pi – an open-source mini-computer which I can buy for about £25.

I won’t go into what the Raspberry Pi is, there are other articles that have done it better and in more detail than I want to do here. What I did want to share is my experiences of actually trying to use it.


I bought a Maplin’s Raspberry Pi starter kit that came with all the extra components (keyboard, mouse, pre-loaded SD card, etc) however I had read that it’s best to re-program the SD cards with a fresh image of a Raspberry Pi operating system (I was going to be using Raspbian). Flashing a new card was pretty basic thanks to some helpful installers, the only problem I had was that my stupid SD slot wouldn’t recognise that the SD card was in write mode.

Getting started

The raspberry pi is the little black box in the right hand corner

Step 1 – Wire it up. Pretty simple really – I have mounted my Raspberry Pi in a plastic case and despite looking like a fragile little circuit board, the connections are pretty robust. Once I had it wired up, it did stop looking like a little computer and started looking like the computer from Superman 2 thanks to the number of wires it needed.

Step 2 – Turn it on. *click*

Step 3 – Stare at a blank screen

Step 4 – Flail around for 5 minutes checking monitor connections

Step 5 – Insert SD card containing operating system and restart it.

Step 6 – Settings. The first time you start the Pi up you are dropped into a settings menu. You don’t seem to need to change anything here except for boot_behavior which I changed to start in desktop.

Step 7 – Restart and enjoy your fancy operating system!

Important test

This is an optional step and very nicely described in a little how-to here. All I really wanted to do was prove that I could download and run a program and see how well it performed.


USB camera server

The xBAM microscope has two important aspects that need controlling by the Pi system – the camera and the motorised stage. I am still waiting on parts and components for the motorised stage so I can’t do anything towards that at the moment, but I can work on the USB camera bit. The first thing I wanted the camera to do was stream over HTTP – this will make it easy to send the images to a wide range of devices (PC, Mac, tablets or smartphones) where the stream can be recorded.

Step 1 – Update. So before doing anything, I needed to download the latest packages to make sure the Pi contains the latest updates. This was pretty simply done by opening the LXTerminal on the desktop and typing in the code;

sudo apt-get update

Step 2 – Install Motion. Motion is a great bit of code that handles a number of USB webcams and includes options for motion detection and even motor control. The package rather effectively handles all the nitty gritty of capturing images and then packing them up for HTTP. Again, in the LXTerminal, I installed Motion using the command;

sudo apt-get install motion

Step 3 – Configure. Once it had downloaded and un-packed itself, the next step was to configure the camera to allow it to both run in the background and to broadcast the steam globally – instead of only on the local network. Editing the config file is done using a editor program called Nano which can be called using the following command;

sudo nano /etc/motion/motion.conf

In this pretty well documented file (there is more description than there is code – very good to see!) I changed two options;

Daemon = on (by default this is off)

webcam_localhost = off (by default this is on)

Step 4 – Make it go;

sudo service motion start

Step 5 – Do a little dance. It worked! When I checked the stream (at the address 192.xx.xx.xx:8081) in a browser on my mac, I could see the video broadcast live. I then added port forwarding to my router and checked it again using my global IP and sure enough, it was broadcasting to the world. I recorded a short segment of this stream for posterity (I had the frame rate a 1fps so it’s a little jerky….okay a lot jerky);

Given how easy this has been, I am now thinking about wiring up my whole life with Raspberry Pi computers – running motion based security; a cloud server; media centre pc for my TV; time-lapse control system for my camera; and possibly even an updated baby monitor. I’ll post more as I start writing my own code and trying out more complicated systems.

Leave a Reply

Your email address will not be published. Required fields are marked *