Lockdown project 2 – wooden Pi Camera

So after reading this article about building your own camera with a Raspberry Pi 4 by Becca Farsace from The Verge I was sold. It was still (sort of) lockdown, I had waaay too much Raspberri Pi stuff. So i went about making my own.

First off I got the core components.

  • Raspberry PI 3A+ (already owned)
  • Raspberry Pi camera module
  • C-Mount lenses (Pentax 25mm, Raspberry Pi 6mm Wide Angle Lens)
  • Puck.js button (to remotely control the device – essentially the shutter release button)

I then tried to get a suitable case, I first bought a couple of second hand broken camera bodies off of eBay, an old Pentax film camera, but it was too small to house the Pi, then a Olympus underwater camera housing which very nearly worked after hacking at it, but I couldn’t then screw the lenses in! Finally I decided I needed to make the case. So bought some 3mm plywood…..

Et voila.

View of camera from the front

Now for the programming, I am a web developer, but my craft is HTML, CSS, Javascript so not really a l33t python dev. So this was mostly trial and error, oh and a shit load of googling (a.k.a. The Web Developer’s Handbook ™ ® ©)

I use rmate because I *still* can’t use VI/nano

The first file is the command we want to run, based around raspistill, well use this later. So I created a file called camera.sh which will take the photo and save it to an Apache server instance to you can remotely access it, e.g. http://192.168.0.*


# Unix time and date filename
sudo raspistill -f -ts -o /var/www/html/photos/PI_CAM_%d.jpg

Now to set up the Puck.js button, we can use the web based IDE to flash code the device, this code (below) will allow the Puck.js button to act like a bluetooth keyboard key, e.g. F7, (note the Puck needs to be paired with the Pi)

//For Puck.js 8b1e

var kb = require("ble_hid_keyboard");
NRF.setServices(undefined, { hid : kb.report });

//F7 key - https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
function btnPressed() {
  NRF.sendHIDReport([0,0,64], function() {

// trigger btnPressed whenever the button is pressed
// consider repeat:false
setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50});
function ledBlink() {
  setTimeout(function() {
  }, 250);

Now we need to set up a multimedia keyboard daemon that can intercept the Puck.js button click (which for our purposes is going to act as a bluetooth keyboard – a one key keyboard). I found something called esekeyd and here are the various commands to get that firing

sudo apt-get install esekeyd
sudo keytest /dev/input/event1

// sudo learnkeys /etc/esekeyd.conf /dev/input/event1
// where eventX == result from above, e.g. event1

sudo learnkeys /etc/esekeyd.conf /dev/input/event1

// Press F7 (), esekeyd will create the configuration file you need (esekeyd.conf). You then need to edit it with your editor of choice. You’ll see a line like this: `#F7(press):` Delete the #, and add your desired command directly after the : (no spaces!). Your new line might look something like this:


// Make sure the sh file is executable

chmod +x camera.sh

// Now let's set up the config
touch esekeyd.conf
rmate esekeyd.conf
sudo cp esekeyd.conf /etc/esekeyd.conf

//run the file
sudo esekeyd /etc/esekeyd.conf /dev/input/event1

//to run on startup
sudo nano /home/pi/.bashrc
sudo esekeyd /etc/esekeyd.conf /dev/input/event1

mkdir -p ~/.config/autostart
cd /home/pi/Desktop
touch terminal.desktop 
rmate terminal.desktop
sudo cp terminal.desktop ~/.config/autostart

This file, terminal.desktop, will launch terminal and the esekeyd service so the camera is ready to take clicks from the button however this didn’t work for me, terminal opens up but I get an error ‘Failed to open /dev/input/event1 (Permission denied)’ I think this is because bluetooth hasn’t enabled yet, I dunno.

[Desktop Entry]
Comment=Test the terminal running a command inside it
Exec=/usr/bin/lxterminal -e "bash -c 'sudo esekeyd /etc/esekeyd.conf /dev/input/event1;$SHELL'"

And there we have it a (mostly) working camera. Here is it:

And here is a time-lapses I took with the wooden pi Camera.

And some of the camera in action / build process

View of camera mounted to balcony
Me building the wooden case

Leave a Reply


No webmentions found.