Feb 08

Simple DIY Lambda Sensor

This will show how to assemble a few components and create a simple dashboard display for your in-car Lambda sensor.

A Lambda sensor is a component fitted to the exhaust system of a car that measures oxygen levels emitted from the engine. This information can be used to adjust the “mix” in the engine helping fine tune and improve performance of the car.

The following tutorial and diagrams show how a few simple components can add a high performance measuring tool to the dash of your car!


Aug 15

Smart Elex Raspberry PI components review.

I recently purchased the smart-elex Raspberry pi GPIO starter kit. I placed the order on Saturday 10t August and it was delivered on the following Tuesday. So following the speedy delivery what did I receive?

Smart Elex GPIO Starter kit

Kit Includes

1x Smart Elex Pi-Cobbler equivalent GPIO Breakout kit (No soldering is required pre-assembled for you. Simply plug & play)
1x Ribbon Cable including connectors 200mm.Connectors include strain relief.
1x GPIO Breakout board.
65x Male-Male jumpers cables for breadboard circuitry
1x 400 tie-point transparent solderless breadboard.
6x LEDs (2 of each: Red, Yellow, Green)
2x 6mmx6mm Miniature Tactile switches
9x Quality Metal Foil Resistors (3x330R,3x1k,3x10K)
1x Tilt Switch

All this for less than £10 delivered!

All components are of a very high quality and the GPIO Breakout board that connects into the breadboard is pre-assembled to a high standard. (All pins soldered and still clearly labelled).

You can connect the ribbon cable to the Raspberry PI GPIO socket then the other end connects to the GPIO breakout socket on the breadboard. this allows for testing and electronics projects to be assembled without any soldering.


Breadboard and GPIO Socket

The Breadboard and GPIO Socket


To test its functionality I created a simple LED circuit and connected to the Raspberry PI.

The simple LED circuit

The simple LED circuit

Very Simple starter project to demonstrate the use of the board – Turn off the power to the Raspberry PI (Please be careful with ANY electronics project as you may cause damage to your PI!)

Connect up the LED and resistor as per the simple diagram. The +3.3V goes to the top left pin. connect the 0V to ground. When the Raspberry PI is powered on it should light the LED.

LED Circuit

LED Circuit with ribbon cable.


LED Layout

LED Layout

Lets make it a little more interesting… Power off the PI again and move the +3.3V wire to one of the GPIO pins.

The easy way to control the GPIO from the command prompt is to use wiringPI – download and install from the following location:


When you power back on you can set the gpio mode and state using the following commands (Change the 0 to the GPIO number you selected.) this should select the GPIO pin to be used as an output then turn the LED on then OFF again….

gpio mode 0 out
gpio write 0 1
gpio write 0 0


Overall this is a great cheap way to start using the GPIO systems on the Raspberry PI – To purchase yours: http://www.smart-elex.co.uk/RaspberryPi/RASPBERRY-Pi-GPIO-ACCESSORIES



Jul 16

The Raspberry Pi runs on battery!


To make your Raspberry Pi time lapse device more portable you can add a battery pack!
Anker 10000mah Astro 3e on Amazon

Anker Astro 3E 10000mah Battery Set

The Anker Astro 3e Battery pack is available with 10000mah cell and features dual usb output BOTH at 1A – This allows you to charge an average smartphone 5 times from the battery.

Specifications on back of box:

Anker battery specifications

Product is supplied with a short usb cable and various adaptors to allow connection to major products (and Raspberry PI)


The Battery arrived fully charged but charging from empty takes around 20 hours. It features 4 lights that indicate how much charge is left in a minty blue colour. In my early tests I have connected the battery to the Raspberry PI and powered it continuously for 14 hours.

In my test I used a Model B Raspberry PI with Camera and Edimax Wifi Dongle connected using wifi. No keyboard, No Screen. Just used putty to connect to it.

To keep it busy I ran a time lapse screen capture every 15 seconds for over 12 hours.

The battery was still functioning on its last blue segment – but felt happier being able to shut down the PI safely! (didn’t want to corrupt my memory card!)

Overall I would say this is a very good well built product. Highly recommended.

Raspberry Pi with Battery




Jun 30

The Simple Raspberry PI on demand PHP Webcam


In this post I will show you how easy it is to set up a simple PHP scripted webcam that returns an image from the Raspberry PI camera on demand.

I will assume you  have the Raspberry PI, Camera and Debian with a web server running with PHP. (There are many tutorials out there offering this basic setup!)

1. Create a simple PHP script to return the image from the camera every time it is called: (Create this as “embed.php” in your public www folder:

system('sudo raspistill -hf -w 512 -h 320 -o /var/www/imageembed.jpg -t 0');
$filename = "imageembed.jpg";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
echo $contents;


2. Now we can use this very simple code to embed the image into our webpage:


<center><h3><u>Live Webcam</u></h3></center><br>
<img src="http://insert-your-web-address.com/embed.php">


You can embed this code directly on the PI or on some remotely hosted webspace!

If you find your apache web service is unable to run the raspistill command you may need to modify the www-data apache user to allow it to run the command:

echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules
 usermod -a -G video www-data


Jun 23

The £2 Raspberry PI Tripod!

Raspberry Pi-Pod

The finished Tri-Pod

Here is a quick and easy way to get your PI & camera stable for taking time lapse photos & videos!

Take a trip to Poundland and buy:

The basic camera tripod:
Link to Poundland Site

Tripod Image

The Tripod in store

And a pack of 2 jelly iPod nano covers:

Nano case

The Nano Case in store

Construction is easy –

Use the end of a small plastic container to make a mounting point by drilling a hole in the base to enable it to sit tightly on the threaded screw at the top of the tripod. Drill a further 2 small holes in the front of the L-Shape to fix the camera to later.

Cable tie the Raspberry PI across 2 of the legs holding it tightly. I found the camera  ribbon cable sits across the top of the network socket on a model B allowing it to exit the case without any modifications:

Raspberry Pi tri-Pod

The top view of the tri pod.

Feed the camera through the slot in the nano case (it looks better when finished) Carefully position the camera onto the front. Feed some insulated wire through the four holes on the front of the camera feeding it back through the holes drilled on the tripod mount. Carefully tighten the wire to secure the camera to the tripod.

To stop the bright red light from the camera whenever it takes a picture/video:

Cut a small round hole in the middle of the Nano case just big enough for the camera lens to poke through. (Not too big else the light will still shine through.)

Fit this over the front to cover the camera electronics. (I used a tiny amount of glue to secure the edge of the nano case to the plastic L-Shaped mount.)

Raspberry Pi Tri Pod Camera

Back view of the Tri-Pod Camera.

Be careful to ensure the ribbon cable is able to move when you change the angle of the camera.

The finished product:

Raspberry Pi-Pod

The finished Tri-Pod


Thanks for reading…


Jun 22

Setup a the Time Lapse Example and Create a Video

Hi In this post I will try to explain how I set up the Raspberry PI to take time lapse images and create full 25 fps videos.

Example output:

You Will Need:

  1. Raspberry PI
  2. Camera Module
  3. PC to create the video files.


I will assume you have the Raspberry PI and camera module installed.

I personally use a laptop with WinSCP & Putty installed to remote admin the Raspberry PI. this allows me to position the PI anywhere I can get a wireless signal or patch to a network. (Tutorial coming soon!)

Log in as root. In your home directory create a file called timelapse – type the following lines of code:


while [ "$NUM" -lt "$TOTALF" ]; do
filename=$(date -u +"%d%m%Y_%H%M-%S").jpg
raspistill -w 1280 -h 800 -t 0 -o $SAVEDIR/$filename
NUM=`expr $NUM + 1`

Save it and return to your command line.

You easily can modify the code: TOTALF being the number of frames to take and SLEEPTIME is the number of seconds to wait between shots (This is approximate – you need to add on the time it takes for the camera to take the image and store it – about 2 seconds) The resolution can also be changed in the above example its set to 1280 x 800.

Create a folder in your home directory called stills – use WinSCP or with command line/Putty – something like:

mkdir /home/stills

You are ready to start taking pictures!

To launch the script (directly from the PI or you can putty/ssh in)

Login and go to the home directory:

cd /home

Run the script… (You will need space on your memory card!)


If you used the settings I left in the script it will take approx 7 hours to run and eat around 900MB of space on your memory card.

Time Lapse Raspberry Pi

Screenshot: The Timelapse scriptis running….

If you want to stop it early press CTRL+C to jump out of the script.

When the script is done the stills folder will be full of date stamped images…

To process the output and make a video…

To make this easy I am using a Windows 7 Laptop with WinSCP and Putty…

Connect to the Raspberry PI using WinSCP – You need to copy all the images from the PI to the PC. Navigate to /home/stills (in the right hand pane). On the left hand side Navigate to a folder to copy the images to.

WinSCP Copy files

Copy all files from the PI to a Windows folder…

click on one of the image files in the stills folder  then press CTRL+A to select all files. Drag them all in one move to the windows folder on the left.

Depending on the image size and number of images this may take some time! (using the script defaults 900MB took around 7mins)

Now you have all the images on your PC we need to rename them to process. I like to use the Bulk Rename Utility as it offers many great features and is also free! Download and run the application (No install version works fine for me!) and navigate to your folder full of images. SORT THEM BY DATE! else the images will be out of sequence!

With the files listed in date order – press CTRL+A to select all images. Of all the settings below we only need to change 2…

Set the numbering mode to “Suffix” and File to “Fixed” (Type a filename). you should see the new name in green with a name and number with increment. (See below)

Bulk Rename Utility

The Bulk Rename Utility – highlights where to change settings.

When all looks good press the Rename button at the bottom right and the files are renamed. Close the app…

Create the video

At this point I would recommend you have xvid installed to create encoded video files – this is not essential but will help save a lot of disc space!

To encode the video I am using VirtualDub a great FREE video processing tool.

Install and run VirtualDub.

From the file menu pick Open Video file. Navigate to your folder of images and click the first one. set the file type to Image Sequence:

Open Image Sequence

VirtualDub Open Image Sequence

click Open and the whole sequence of images will load into VirtualDub.

Select Video->Frame Rate menu item and set the frame rate (I set mine to 25fps)

Video framerate

Set output Video Framerate

Next – Set the video compression – on the Virtualdub menu select Video -> Compression.  I set mine to xvid for a smaller output file if you do not have this select cinepak/intel/microsoft.

VirtualDub video comression

Select Video Compression format

Finally select File -> Save as AVI and give your final output a filename.

Virtualdub in action

VirtualDub Creating the final AVI Video file.

The video is now ready to watch using Windows media player, VLC or transfer to your media device. This file can also be uploaded directly to youtube – depending on your internet bandwidth you may need to scale the images down or shrink the video further as the output files can quickly become quite large!

Final Video Image

The Final Video

Have fun!