The idea for this  current version is to condense down the functions from the previous versions in to a single board that fits on top of the raspberry pi zero W.

I also wanted to reduce the cost and complexity of the previous versions to increase the reliability and make it easier to use.




The main board sits between the various components and the pi, and is populated with jst connectors to make fitting it all together easier.

I’ve been running a version of this board that I built with the excellent  protozero board : and thought I’d have a go at putting together a circuit diagram on fritzing.

A few clicks later I had the first version of the board ordered from – this was a bit of a mess, mainly as I managed to use an odd relay template but after a bit of tinkering I had this version printed.


Circuit diagram (click to enlarge):



The heart of the board is a L293D IC. I chose this as it can reverse the polarity of a signal which is necessary to control the IR filter over the camera lens. Further information here:


The L293D has 2 channels and I have used the second channel to control the relay. This is handy as it allows the GPIO pins to control a 5v relay with minimum effort or additional components (just a diode to prevent feedback) and provides an element of protection to the pi.

5v relays are easy to get hold of and cheap, and the minimal components mean that I can include the relay on the main board and not have to rely on per built boards.


The light is a 5v, 10W Infrared IR 840-850nm SMD LED unit.  It draws about 2A current so I’ve connected it to the USB battery supply via the relay to enable it to be switched.

Previously I’ve used a ring of LED’s but this brighter and doesn’t require a 12v supply so the whole assembly is smaller.

It gets very hot, so it may get an upgrade with a heat sink in the future.

Infra Red filter

This filter is designed for use with security cameras and consists of a small plastic element that is pulled in front of the camera lens to prevent infra red light getting through.

When it is deployed it gives a more natural colouration however when it is removed it picks the light reflected by the infra red lamp giving better vision in the dark.

It works by sending a 5v signal for a fraction of a second to the actuator – one way it moves in front of the lens and the other retracts it.

The polarity of the signal is handled by the L293D chip with the following outcomes:

Filter off
Chip pin Pi pin Signal
1A 16 LOW
1B 13 HIGH
Filter on
Chip pin Pi pin Signal
1A 16 HIGH
1B 13 LOW
Filter stop
Chip pin Pi pin Signal
1E 7 LOW


The buttons are simple and cheap ones from mod-my-pi but they’re decent quality and a normally open (push to make) type. They are current limited with a 220? resistor and the pin is pulled down to negative on the board so it is simple to put any button or even an LDR or similar with a jst soldered to it.

There’s no protection on these and I managed to fry my old test pi by plugging in the 5v supply to the light on the first board (stupid mistake, but it had a broken camera connector anyway).

PIR sensor

I’ve used an inexpensive HC-SR501 PIR (passive infra red) detector  datasheet

5v is supplied to the module and when it detects movement, it sends a 3v signal through the yellow wire which is detected by the pi on pin 15

There are adjustments on the sensor for trigger time, sensitivity etc which can be altered however it is set up in a configuration that seems to work.



Once again this does all of the heavy work to include the actual motion detection and video conversion. I’ve used the in built ability to add on a button to the main web interface that links to my own webpage which alters button size etc so  it’s a bit easier for kids with touchscreen devices to use.

  1. Status
  2. Current date & time
  3. Main screen
  4. Buttons



A program called “detect” is running which is started via cron at boot. This program is a loop that performs the following actions:

  • Waits for a trigger from the PIR then turns on the light;
  • Reads the pikrellcam pipe to see if the light or filter buttons have been pressed on the web page
  • Reads the 2 x buttons and performs the shutdown / restart wifi commands

Link to code:  HERE



I’ve not been able to give it a proper test with animals yet -I don’t have any secure outside space to use it anymore and when I’ve put it out in other gardens nothing has been about at night (as its a bit cold). It works well in low light with early risers and curious children so performs as well as the previous version in terms of triggering.


  • fritzing is really easy to use and handy for drawing up the circuit diagram.
  • It’s simple to turn the diagram in to a pcb, but you need to be careful with component choice to make sure they are easy / cheap to get.
  • Aisler are quick and  cheap  – 3 identical boards cost approx £20 which is less than buying the prototype boards. It’s also fun to get Emails from Felix keeping you updated on progress.


  • The lamp gets REALLY hot! Not so bad when it is on sporadically outside but running for long periods wil require a heat sink.
  • The top line of emitters failed on my first lamp during testing. This could be down to getting hot, defective lamp or mishandling (it was messed about with a lot).
  • the lamp is an 840-850nm version which works well with the pi camera. I’ve since bought 3 x smaller (3W) ones at 740nm, 850nm & 940nm to test out which is best.


I’ve used an easyacc 10400mAh power supply – link which works fantastically in normal operation, giving a good 10 to 12 hours of power for both the pizero and lamp.
It’s got 2 connections – 1A & 2.1A with the lamp requiring all of the 2amp supply to function correctly.
The only issue with the power supply is its size. It’s pretty small for its output however it is now the largest component in the whole setup, so it dictates the overall box required.

Internal access

There is nothing more irritating than the insides of the camera flapping about and disconnecting so I’ve screwed everything down in this version. All worked beautifully until I needed to get to the sd card and had to unscrew and disconnect the board so I’ve bought an SD card extender which should do the trick.

The battery is now easily accessible via a flap in the bottom of the birdbox and the connections, while fiddly to put in, are nice and stable.


Old version

The is the original version with the ring of IR LED’s and the main control board with separate ones for the relay and the filter control. Not shown are the 9v battery to power the light (supposed to be 12v but needed the space!),2 buttons  and the main powerpack.

New version

The is the new version with the pi zero attached to the back and all of the elements connected. The usb plug goes to the 2.1A output from the battery with the pi powered by the 1A output (lead not shown). It is a considerable saving in space & complexity over the old version with fewer areas to break.


This picture shows the evolution of the camera board:

  1. simple version for pi V1 to break out the gpio pins. Very bulky and needed the wires kept falling off of the pins.
  2. this version is again for the pi V1 but introduced a couple of buttons on the board
  3. the final pi V1 board with pins that allowed the various elements (relays, buttons etc) to be positioned in more convenient places.
  4. Explorer phat version that I just couldn’t get to work well enough. It was excellent for the filter switching but the relay control needed a bit more oomph (or a better programmer!)
  5. The populated and working previous version.
  6. prototype of the new board constructed on an excellent protozero board. Loads of messy wires and my crummy soldering underneath so plenty of points of failure.
  7. PCB version 1 – i managed to mess up the relay type and didn’t want to use expensive ones so moved on to the current version.
  8. Current version, populated and unpopulated.
  9. Current version fully connected.


Group shot of the cameras, from left to right:

  • Handheld version – as described on previous posts.
  • The current trailam. The lamp is in the top and camera below., the pir is now fitted under the camera (not shown in this pic) and the buttons are inside.
    Stupidly I ended up putting the smallest version of the trailcam in the biggest box I had! In reality it could easily fit in the smallest box with space to spare.
  • normal colour trailcam. This is just pikrellcam and an old camera and pi model A used in daylight.
  • old version – this has got the big light around the camera and the PIR in the little window. The button is cunningly positioned behind the door.


Custom index page

The Anicam is controlled with a custom php page that uses the feed from pikrelcam.



require_once(dirname(__FILE__) . '/config.php');
include_once(dirname(__FILE__) . '/config-user.php');
include_once(dirname(__FILE__) . '/config-defaults.php');

function time_lapse_period()
$tl_status = "../../.pikrellcam/timelapse.status";
$f = fopen($tl_status, 'r');
$tl_period = 1;
if ($f)
$input = fgets($f);
$input = fgets($f);
sscanf($input, "%d", $tl_period);
return $tl_period;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo TITLE_STRING; ?></title>

<script src="js-css/jquery.min.js"></script>
<link rel="stylesheet" href="js-css/pikrellcam.css" />
<script src="js-css/pikrellcam.js"></script>
<script src="js-css/expandable-panels.js"></script>
<link rel="stylesheet" href="js-css/expandable-panels.css" />

if (isset($_GET["hide_audio"]))
$show_audio_controls = "no";
if (isset($_GET["show_audio"]))
$show_audio_controls = "yes";

echo "<body background=\"$background_image\" onload=\"mjpeg_start();\">";
echo "<div class=\"text-center\">";
echo "<div class='text-shadow-large'>";
echo "</div></div>";
echo "<div class=\"text-center\" style=\"color: $default_text_color; font-size: 1.4em;\">";
echo "<img id=\"mjpeg_image\"
alt=\"No preview jpeg. Is pikrellcam running? Click: System->Start\"
style=\"border:4px groove silver;\"

echo "<div class=\"text-center top-margin\">";


<input type="image" src="images/bigstop.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
onclick="fifo_command('record off')"
<input type="image" src="images/bigpause.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/bigrecord.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
onclick="fifo_command('record on')"
<input type="image" src="images/bigtakestill.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/bigmotion.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
onclick="fifo_command('motion_enable toggle')"
<input type="image" src="images/mainmenu.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/lampon.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/lampoff.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/filteron.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/filteroff.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/videos.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"
<input type="image" src="images/stills.png"
style="vertical-align: bottom; margin-left:9px; margin-right:0px;"
width="100" height="100"

<div id="container" class="top-margin">

if (file_exists("custom.php"))
include 'custom.php';


This page basically hijacks the pikrellcam pipe and sends its own information through it to the python program.

import RPi.GPIO as GPIO
import time
import os
import sys
# Set pins to BOARD

# Setup pins for relay
Motor2A = 36
Motor2B = 32
Motor2E = 37
# Setup pins for filter
Motor1A = 16
Motor1B = 13
Motor1E = 7
#PIR setup
#set up PIR pin
PIR_PIN = 15
#set PIR pin as input

#set up BUTTON A pin

#set up BUTTON B pin

#below is the function MOTION which is called by the main program at the bottom
				print "motion detected"
				# double check
#				time.sleep(2)
				while GPIO.input(PIR_PIN)==1:
					print "confirmed"
#					time.sleep(1)
					# switch relay on
					print "light on"
					# wait 20 seconds - can change this
					print "waiting"
					# check the PIR again, if its on wait for another 20 seconds
					while GPIO.input(PIR_PIN)==1:
						print "still waiting"
					#turn off the relay
					print "motion stopped"
					print "Light off" 
				print "button A detected"
				while GPIO.input(BUTTON_PINA)==1:
					print "confirmed"
					os.system('sudo poweroff')

				print "button B detected"
#				os.system("sudo ifup --force wlan0")

# message is prined at startup & gives the PIR sensor 2 seconds to settle down before the program starts.
print "PIR Module test press Ctrl+C to exit"
#turn off the relay
print "Light off"

print "Sending signal"

print "Filter off"

print "ready"

# this runs all the time, checking to see if the PIR or buttons are triggered
	GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION, bouncetime=300)
	GPIO.add_event_detect(BUTTON_PINA, GPIO.RISING, callback=BUTTONA, bouncetime=300)
	GPIO.add_event_detect(BUTTON_PINB, GPIO.RISING, callback=BUTTONB, bouncetime=300)
	while 1:
# stop program if ctrl+C is pressed
except KeyboardInterrupt:
				print "quit"