Skip navigation

The Raspberry PiRaspberry Pi has been a huge phenomenon in the maker scene, spawning a wide range of accessories, add-ons and even specialised 'Hats'. One of the most underappreciated peripherals would have to be the small Raspberry Pi camera boardRaspberry Pi camera board. At first look it might seem to be the same as any cheap USB camera, but its functionality is far beyond that. The special 15 pin ribbon cable the camera board uses enables it to interface directly with the graphics processor on a Raspberry Pi. This allows it to use the full power of the Pi for all the image processing and heavy lifting, rather than relying on processors in the camera itself. This, combined with its reasonably high fidelity photo sensor, lets the camera produce great quality images and videos at a reasonably low cost. The other feature of the camera board is its ability to be activated and controlled from various coding languages. There is an extensive library of code for the Python programming language and it can also be used right from terminal in a compatible Linux distribution.


For a project using the camera board, I mounted it along with a Raspberry Pi and a small LCD screen into a car to be used as a DVR system. Car DVRs are very popular tools both for private and commercial vehicles - they are used to provide evidence in resolving traffic disputes and aid in insurance claims. If your car is your pride and joy, having video evidence of a crash can be the difference between getting an insurance payout and being stuck with an expensive wreck.

For this project the Raspberry Pi can be running a number of Operating System. The requirement is that it has to run Python and be compatible with the camera board and GPIO modules. For a quick and easy setup I used a NOOBs pre-loaded microSD cardNOOBs pre-loaded microSD card. It comes pre-loaded so there is no need to format or write an SD card, it's ready to go right out of the box. By holding Shift on a keyboard right after boot you'll get to the recovery menu that will let you choose different operating system. For this project I stuck with the pre-loaded Raspbian.


Depending on the electrical system in your car, powering a Raspberry Pi from it can cause difficulties. When starting the engine or switching on electric devices, such as headlights, the power from the battery or alternator can momentarily drop. Modern car stereos are designed to tolerate this, but the humble Raspberry Pi is not - any significant drop will cause it to fully loose power then reboot. This can be annoying at best, forcing a system reboot every time you want to start the engine or switch the headlights to full beam. A solution to this is using a UPS - Uninterruptable Power Supply.


A UPS works by having a battery that can power devices when incoming current temporarily drops out. My low cost UPS solution was using a super cheap, unbranded, USB Power Bank - small external batteries that are commonly used to charge cell phones on the go. Unfortunately, most of these types of devices aren't the best solution. A normal UPS works by having an ultra fast, automatic switch that can toggle from the incoming power to a battery bank when the current drops below a certain level - switching fast enough that devices attached to the UPS do not notice any difference. Most cheap power banks, however, function by having the input power charge a battery and have the output power coming from the battery simultaneously. Inefficiencies in the battery and the circuitry used to charge it means that the power coming out is significantly less than the power coming in. Because of this some of these devices are unusable as a UPS while others may function but can have issues, such as the battery running flat even when it is being recharged. There are many such devices and each one is different. The brandless one I have functions adequately when powering a Raspberry Pi, but others may not.


The best way to have simple control of the cameras recording functionality is to connect a toggle switch to the GPIO on the Raspberry Pi. By using a GPIO switch to control the camera, you leave any keyboard, mouse or even touchscreen input unused and free for any other use by your chosen operating system. You can use a flick switch or a rocker, but to keep the footprint on the dashboard small I used a latching pushbuttonpushbutton. You may have seen other guides use pull-up resistors for buttons on the Raspberry Pi, but we can use a line of code to pull-up for us. Simply wire one of the button contacts to an available GPIO pin - in my case I chose #24, but any will do - and the other contact to one of the Pi's ground pins. The easiest way to do this is using female jumper wiresfemale jumper wires, just cut the end off two wires and solder them to each of the button contacts.


Latching PushbuttonsLatching Pushbuttons and Rocker SwitchesRocker Switches connected to jumper wires


Something that you don't release before seeing it in the flesh is just how small and light the camera board is. My original plan was to use a small piece of acrylic attached to suction cups to make a mount that sticks on the windshield. Unfortunately getting it to hinge on the right angle for a good view while still being solid enough to not wobble while recording was tough. The solution I found was to use a GPS suction mount that has a good hinge, using light adhesive and small screws to stick the camera board to its backside. It was solid enough to not shake while recording but could still be oriented for the best viewing angle out the windshield.

Suction Mount

Camera board mounted on the windscreen


When mounting the camera board, be careful to check what your local laws and regulations are. Certain states in the US, including California, have laws against attaching any device to a vehicles windshield even if it is just temporarily adhered with suction cups. Fortunately, here in cold New Zealand no such laws exist.


I used an unbranded 7" LCD screen and HDMI adapter board as the monitor for the Raspberry Pi. These are very cheap, but also inconsistent in quality. Some are able to run on the 5 volts from a USB port, while others need a higher voltage - even between identical looking models. They are also prone to having flaws on the LCD, like dead or stuck pixels, and often have poor viewing angles. Hopefully when the long rumoured official Raspberry Pi touch screen is released these problems will be a thing of the past, but for now it is a case of buyer beware.

Completed Circuit

The full completed circuit


If your cars dashboard already has a screen built in it might be usable for this project. The Raspberry Pi can output a composite A/V signal, just like what every DVD player and game console used long before HDMI was common. If you have an "Aux Video" or "AV input" option you'll just need a Raspberry Pi 3.5mm to 3 RCA cableRaspberry Pi 3.5mm to 3 RCA cable to wire it in. Keep in mind that the video quality of composite video is significantly inferior to HDMI, but there will be no change in quality of any video recorded by the camera board. It'll be hard to read text, so the Raspberry Pi will most likely have to be set up on a HDMI monitor first.


Unfortunately the dash in my 1983 Toyota didn't have a great spot to put a screen. To hold it in place I used rubber washers attached to small bolts along with double sided mounting tape attached to a piece of thick, solid card. I put the latching buttons in the card, using a spade bit on a drill to get the right sized holes. Strong cable ties attached the card to my cars centre console. I left the USB power adapter exposed and ran the cables back just to allow all the wiring to be easily removed if necessary.


I attached the Raspberry Pi to a sheet of card and placed it securely in the glove compartment. In order for the camera to mount on the windshield I had to use a longer ribbon cable, one meter as opposed to the standard 15 centimetres. You have to be careful when doing this. Because the cable is unshielded, having a longer run can cause problems with the video signal and even make it not work at all depending on the level of interference.


A USB car charger is an easy way to get the voltage to the right level for a Raspberry Pi. It also useful as most units you buy have a fuse built in, giving extra protection if your cars electrics may not be that reliable. Be sure to use a good quality charger that gives out a constant, smooth voltage. My Pro-Power AC adapterPro-Power AC adapter has two USB ports, I used one for the Raspberry Pi and the other for the LCD screen.


To get the button to activate the camera recording I used this Python script.

import datetime
import picamera
import RPi.GPIO as GPIO

GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)

while True:
GPIO.wait_for_edge(24, GPIO.FALLING)
        dvrname ="%y%m%d_%H%M%S")
        with picamera.PiCamera() as camera:
camera.resolution = (1920, 1080)
camera.start_recording('/home/pi/' + dvrname + '.h264')
GPIO.wait_for_edge(24, GPIO.RISING)



From the top down:

  • Line 1, 2 and 3 import modules for controlling the camera board, accessing the GPIO interface and for reading the date and time respectively.
  • Line 4 selects what numbering system is used to identify GPIO pins - I used the BCM numbering, the alternative is to use Board numbering. Be sure to double check what system you used when attaching the buttons to the Raspberry Pi.
  • Line 5 sets the pin used to be 'up' or 'down'. This line allows buttons to be used with the GPIO without having to wire resistors. Setting it to up means one side of the button should be attached to a ground pin to bring it down.
  • Line 6 sets up a while loop that will check if a certain condition is met before proceeding.
  • Line 7 detects when out chosen GPIO pin is Falling - going from being up to down, or more simply when the attached button is pressed.
  • Line 8 builds a filename for our recorded video, based on the current date and time for unique file names for every video and for easy sorting of videos.
  • Line 9 is when we start using the camera.
  • Line 10 sets the resolution to 1920x1080, also called Full HD.
  • Line 11 starts the preview, letting the video from the camera be displayed live on screen. Remove this line if you don't want to see what is being recorded.
  • Line 12 starts the recording and outputs it to the filename that was made in line 8.
  • Line 13 detects when the GPIO pin is pulled up, or when the button is switched off.
  • Line 14 stops the recording.
  • Finally, line 15 cleans up our used GPIO pins to prevent clashes or things getting out of hand.

I then saved this python script as '' in the /home/pi/ directory.

In order to have this script running in the background while Raspbian is running, the file at /etc/rc.local needs to be edited. Open it up and add the following line to the very bottom.

python /home/pi/ &

The ampersand and the end is important, it ensures the script is always running in the background and will not close.


This script is fairly reusable, you could substitute the camera function for other code to get a Raspberry Pi to do all kinds of things on the flick of a switch. You can also do more things with the camera, like adjusting for low light or recording in slow motion. Look through the picamera documentation for all the extra details.


Using a Raspberry Pi as the core of a car DVR system has a big advantage. Rather than having to take the SD card out of the car to review the video footage, adding a WiPi wireless adapterWiPi wireless adapter lets you copy the videos from the Pi wirelessly. In Raspbian, set the directory where the cameras video files are saved as a network share. Then setup the WiPi to connect to your home WiFi network. Now as long as your car is in range of your wireless access point you can copy the video files remotely to your computer or tablet.


A few final things:

  • Its a good idea to wire in switches to the power going into everything, just to be able to keep everything turned off. It will also let you turn the Raspberry Pi on again after shutting it down without having to unplug it.
  • If wiring the system using the feed directly from your car battery you can run the risk of getting a flat battery if you forget to shut everything down. I used the ignition power feed to ensure that the key has to be in the car for it to get power. You can also set a shutdown timer in Raspbian that will turn everything off after being idle for a set period.
  • You can run out of SD card storage space very fast recording full HD video. Try setting a lower frame rate to save space over the default 30 frames per second, or connect a USB flash drive and use that to record to.
  • After the installation you have a full Raspberry Pi installed in your car! If you disable the video preview you can do whatever you want while recording, the quad core processor in the Raspberry Pi 2 makes this multitasking work well. Try installing media players and connect the audio output to your stereo, or doing other fun things. Great for entertainment when waiting for people in your car! Just please don't try and watch a movie while driving. If that's not illegal where you are, it probably should be.


If you have any questions or suggestions, leave them on the comments below or you can contact me on Twitter - @aaronights.

Hello forum,


being totally new to the Raspberry world, I hope to get a few comments and answers to my (maybe crazy) thoughts about using a Raspberry farm instead of Intel i7 systems to serve as a crawling and parsing system.


Application background: I have developed my own crawling  (internally using wget) and very specialized parsing software. The goal is to permanently crawl and parse a couple of 10 million websites websites for special purposes (very different from normal full text searches). It currently runs on OpenSuSe Linux on two Intel PC i7 3770 and 4770 nearing the end of beta tests. In the end I will need about 7-10 such PC to run all tasks permanently.


Since I must work on self-financed low-budget, I had the idea of employing a farm of Raspberry systems to handle these tasks. The software could be ported although this would mean some efforts, which must be justified.


However, this would only make sense if most of the following expectations could be fulfilled by a Raspberry server farm:


1) The initial hardware investment related to the same processing level must be less than 50% of what Intel based PCs would cost to justify the additional hassle, handling and software port.

2) The power consumption should be significantly lower.

3) Reliability should reach around 80% of the one of the Intel systems (i.e. somewhat less could be accepted).

4) Crawling / downloading could be separated from parsing. It would be sufficient if parsing was delegated to Raspberries. Crawling / downloading uses RAM disk as intermediate storage because the SSD drives quickly get to their limits and this might therefore better stay on the 32 GB RAM Intel PCs.


What do the Raspberry experts say?


a) Forget about it!

b) A viable concept worth considering.

c) Cost saving will not be significant enough.

d) Or what else?


Thank you very much in advance for your comments.


Best regards


wallace and gromit


My dog Penny is one of the best. She has the two critical commands of ‘come’ and ‘stay’ down pat so well that I can go for a run with her off-leash here in Denver.


She’s gentle with our newborn baby, and she doesn’t destroy things. Her only issue is that she goes BONKERS for food. My wife and I have done a great job training it out of her when we’re around so we no longer have to worry about a cheese board sitting on the low coffee table, but I know she gets on the counters any time we are away. Sounds like a job for a machine!

0528151441d.jpgI decided that it might be helpful to have a surrogate to defend the counters when she’s home alone. After the success of the Silent Laser Doorbell, I decided that a Laser Dog Watcher could be similarly effective.  Here are the features:

  • Setup a Laser tripwire using the same mechanical system in the Silent Laser Doorbell<link>
  • On a laser beam break, trigger the digital GPIO of a Raspberry PiRaspberry Pi to play an audio file of me reprimanding her AND taking a photo with the Pi CameraPi Camera. The audio file changes so it’s not always the same.
  • There is a calibration knob to allow for various levels of ambient light.
  • There is an ‘enable’ switch to disable the audio and photo features to allow the user to line up and calibrate for ambient light.
  • If the first audio file doesn’t get her off the counter and reestablish the beam, it plays up to two more audio files before disabling itself. That way it won’t loop over and over in case the system was knocked out of alignment.


Here’s the system in action! I put a bit of food on the counter and left for a while with a video camera setup.


I’ve put a step-by-step tutorial below and attached full documentation to this article for those that would like to build one, but first a few design decisions that had to be made.


Raspberry Pi2 Choice:

I’ve been keen to use my Pi2, and this seemed like a great chance. Although it doesn’t really use the muscle behind the new version I like knowing that expansion of this project would be no problem. Who knows – maybe I’ll do image processing to recognize her and generate a trigger! Here is a spec comparison for the Rev 1 vs. Rev 2 Raspberry Pi:

Pi Pi2_compare_jan30.png



In the Silent Doorbell project, I implemented a clever moving average system to automatically calibrate for ambient light. This was certainly needed in sunny Denver, CO. However the Raspberry Pi doesn’t have any analog inputs that would be required for such an algorithm. Since this design is intended to be used indoors with mostly stable ambient light and the sensor is mostly enclosed, a calibration knob makes on leg of the resistor divider variable and gave plenty of stability (i.e. lights on, lights off, etc…). The way to calibrate is to have the beam broken and make sure the status LED shows that the beam is broken by turning on. Turn on all the lights in the room to be sure it will work in all conditions. Then aim the beam to the sensor and be sure the status LED turns off. Check out the schematic:

<insert schematic image>


Enable Switch:

During laser aiming and calibration, I was annoyed by constantly hearing myself yell at the dog, and poor penny was so worried and confused! It took me about 5 seconds to decide that an enable switch is needed.


Status LED:

When the enable switch turns off audio output, one needs an LED to show that the laser is broken during aiming and calibration! It was a huge help.



Catching animals in the act is hilarious! Also, I want to be sure the system is working properly and count the number of times that it was tripped.


There you have it! If you want to build one for yourself, follow the tutorial below and let us know in the comments how it goes!




1. Download the NOOBS files and follow the tutorial created by Raspberry Pi. It’s a big file so grab a coffee/tea/beer and build the circuit hardware described on the Silent Laser Doorbell page.

2. Plug the Pi into a monitor, keyboard, and mouse and power up the pi

3. Select ‘Raspian’ for your operating system and set your desired language and keyboard. The install takes a while so now’s a great time to re-up your beverage of choice.

4. After the install completes, the Pi restarts itself in the Configuration Tool. Go into ‘Advanced Options > SSH’ to enable SSH. Go into ‘Enable Camers” > ‘Enter’ > ‘Finish’

5. Reboot the system and if you’d like to SSH into the Pi you can remove the monitor, keyboard, and mouse.

6. Update and upgrade the packages. This takes a bit. Probably time for another beverage.

sudo apt-get update

sudo apt-get upgrade

7. Install the RPIO package to allow reading the GPIO lines, Alsa audio drivers, the mpg123 MP3 player, and the PiCamera library

sudo easy_install –U RPIO

sudo apt-get install alsa-utils mpg123

sudo apt-get install python-picamera

8. Reboot the Pi

9. Load the sound drivers and set  the system to use the 3.5mm audio jack output

sudo modprobe snd_bcm2835

sudo amixer cset numid=3 1

10. Create a folder to hold your MP3 files and python script, and another one (in the dogwatcher folder) for the image files

mkdir dogwatcher      #in the pi directory

mkdir photos          #in the dogwatcher directory

11. Transfer your MP3’s to your Raspberry Pi into your ‘dogwatcher’ folder. There are many ways to do this. My two favorite methods are (1) login to your Pi with an SFTP (SSH File Transfer Protocol) client like FileZilla and copy them to the desired directory or (2) Use a thumb drive to transfer the files. My files are ‘hey.mp3’ ‘uhoh.mp3’ and ‘baddog.mp3’

12. Test to be sure that you can play the file desired to your 3.5mm audio jack by running the following command in your folder:

mpg123 hey.mp3

13. Install the Rpi.GPIO module on the Pi

sudo apt-get install python-dev python-rpi.gpio

14. Upload the python script to the dogwatcher folder. Feel free to use mine; attached here as ‘’

15. Build the laser detection hardware and enable switch circuit described in the schematic

16. Turn on the Pi, navigate to the dogwatcher folder, and run the python script.

cd dogwatcher

sudo python

17. Calibrate the sensor, then enable the switch to make sure everything runs as planned. You can pull photos off in the same way you added the MP3’s, but I’m a big fan of doing it over SSH FTP with Filezilla.

18. Setup the Pi to activate the system on boot using your favorite method (instructable listed below for the method I used, or you can use the included ‘’ file of mine attached here).

19. Test it! It should run on bootup.


Attached Design Files: Python script that runs the system

Laser Dog Watcher.sch: EAGLE schematic benefiting from the Raspberry Pi 2 EAGLE library

Laser Dog Watcher Schematic.pdf: PDF of the schematic

hey.mp3: One of the audio files that I used (in case you need a known-good audio file to test your system)


Helpful Links:

to start a python script at boot:

Filter Blog

By date: By tag: