piOneer - build a DIY action cam

By Russell Barnes. Posted

Build your own battery-powered, slow-motion, 90fps action camera to prove you’ve ‘been there and done that’!

Most adventurers who are thinking about recording an action event would choose to explore the GoPro camera system. While being a very capable recording device that’s housed inside a diminutive package, the GoPro cameras have an exorbitant price tag that stops weekend warriors in their tracks. What if an action camera cost less than $50? What if you could build this camera yourself? What if this camera had a fully functional Linux computer inside? Although it might sound like pie-in-the-sky dreaming, these are the hallmarks for our piOneer slo-mo action camera project.

You'll need

STEP-01 Print it

Borrowing a page from the Astro Pi design book, piOneer consists of a three-part 3D-printed case that holds a Raspberry Pi, Camera Module, user interface, LiPo battery, and large capacity micro SD card. The case consists of three separate STL files that can be printed on any 3D printer with a 150×150mm build surface. The case’s top piece should be printed with a removable support structure. You can download the STL files from the Pioneer website.

STEP-02 Build your UI

The user interface (UI) for piOneer is dead simple. Consisting of seven LEDs and one switch, the entire UI is housed in the case top piece. Begin your UI construction by gluing the LEDs and the switch to the upper surface of the case top. While you can use the same colour LEDs for piOneer, we opted to mix it up a little: a red LED for power (PWR), blue for ready, white for countdown 3 and 2, a yellow LED for countdown 1, red for recording (Rec), and a green LED for finished. Just one caveat about gluing the LEDs: ensure that all of the cathodes are lined up with each other; this makes the next step very easy to complete.

STEP-03 Solder your UI

We’re going to use a little bit of wiring trickery here! Rather than routing each LED cathode to a separate Pi GPIO GND pin, we’re going to connect each cathode together in a daisy chain fashion, thereby using only one GND pin for six LEDs! Begin this wizardry by gently bending the ‘finished’ LED cathode so that it’s touching the ‘recording’ LED cathode. Now solder these two cathodes together. Continue up the daisy chain, carefully bending the ‘recording’ cathode until it’s touching the ‘countdown 1’ cathode, and soldering that connection. Likewise, for the remaining LEDs, bend and solder each LED cathode to the next until you reach the ‘Ready’ LED. Stop at this LED. Do not solder the power (PWR) cathode to this chain: it must be connected to its own GND pin.

STEP-04 Wiring your UI

The resistors are each individually soldered to the anodes of all LEDs. Begin this process by carefully wrapping one end of a resistor lead around an LED anode lead. The resistor should be parallel to the inside of the top case. Solder this connection, and trim and discard the leftover resistor lead. Add the six remaining resistors to the final LEDs. Solder a jumper wire to the free end of the resistor’s other lead. Complete the LED’s cathode wiring by soldering a female jumper wire to the power (PWR) LED cathode lead, and one final female jumper wire should be soldered to the daisy-chained cathodes that we created in step 03. The piOneer UI is now complete.

STEP-05 Adding battery power

The power system for piOneer consists of three sub-assemblies: the power (PWR) LED, the SPST switch, and the battery. While the LED and switch are pretty straightforward fixtures in a do-it-yourself (DIY) project, the battery has one additional component that enables the Pi to run without being tethered to a power outlet. A 5V step-up converter takes the output from the 3.7V LiPo battery and increases it to 5 volts.

STEP-06 Wiring your battery

Two wires are individually soldered to the switch’s terminals. One of the switch’s wires is soldered to the positive terminal of the JST connector. The JST connector is keyed for proper power signal orientation. Use the battery for identifying which terminal is which – remember, the battery’s red wire is positive, while the black wire is GND. The other wire from the switch is connected to the IN pad on the 5V step-up converter. A female jumper wire is connected to the OUT pad of the converter. The final pad on the converter is a ‘common’ GND connection. In other words, both the battery’s GND and the Pi’s GND must be connected together via this pad. Therefore, solder a wire from the GND terminal of the JST connector to the 5V step-up converter GND pad and solder a female jumper wire to this pad. All of the soldering is now finished for piOneer.

 All that's left is the Raspberry Pi and camera

STEP-07 Begin final assembly

The Raspberry Pi and Camera Module will be fastened to the base portion of the case. Note the orientation of the two openings in the base. These openings will hold the Camera Module’s lens and status LED. Line the module up with these openings and use four M2 screws for attaching the Camera Module to the base. Lay a rubber grommet on each of the four tall mounting posts, set the Pi on top of the grommets, route the Camera Module’s ribbon cable out and over the GPIO pins, and use four more M2 screws for securing the Pi to the base. These rubber grommets will provide a small amount of cushion for the Pi during your upcoming rough-and-tumble adventures. Insert the Camera Module’s ribbon cable into the Camera interface connector on the Pi.

STEP-08 Connecting to the GPIO

Place the wired-up top case next to the base that holds the Pi. Slip the mid case onto the top case. Connect each of the female jumper wires from the top case to the Pi GPIO pins by following this listing:

  • GPIO pin - jumper wire
  • 1 - PWR LED anode
  • 4 - 5V step-up converter OUT
  • 6 - 5V step-up converter GND
  • 9 - PWR LED cathode
  • 22 - Ready LED anode
  • 16 - Countdown 3 LED anode
  • 15 - Countdown 2 LED anode
  • 32 - Countdown 1 LED anode
  • 33 - Rec LED anode
  • 37 - Finis LED anode
  • 39 - Daisy-chain LED cathodes

(see step 03)

STEP-09 Program the Pi

Carefully and thoroughly examine each and every solder joint and wiring connection, looking for touching wires, solder blobs, connection mistakes, and so on. Fix any problems before connecting your Pi to a power source! When your piOneer passes muster, connect the Pi to a monitor, keyboard, mouse, and USB power source; now set up your Pi so that it boots, with automatic login, to a command-line interface (CLI). These settings will enable piOneer to run automatically without user input every time you flick the power switch. Download or enter the piOneer code and save your code to the home directory on the Pi. You can alter the code to suit your recording tastes. As it stands, piOneer will record 1 minute of 640×480-pixel video at 90 fps. The final H264 file will be approximately 65MB in size. In order to make the Python code run automatically, open your user profile for editing:

sudo nano /etc/profile

…and add this line to the end of that file:

sudo python /home/pi/pioneer.py &

Save, exit, and disconnect piOneer.

STEP-10 Get out there!

Ensure that the power switch is in the OFF position and connect the battery to the JST connector. Slowly bring the case edges together, ensuring that no metal leads, wires, or solder joints are touching the Pi! Insert a long #6-32 screw through each of the cases’s connection lobes and fasten with a nut. We used wing nuts for our fasteners, which makes the case easier to open and close. In order to record a video, just flick the power switch and within 30-45 seconds, piOneer will start recording your slo-mo video. Videos are recorded and saved with a date/time stamp file name. In order to view the videos on your Pi, use:

omxplayer date-time-stamp-filename.h264

Have fun doing your daredevil deeds, because now you can prove it.

 Your finished camera!

Code listing

pioneer.py - Download from the website

import RPi.GPIO as GPIO
from time import sleep
import datetime as dt

import picamera

GPIO.setmode(GPIO.BOARD)
# Set up LED pins
# Ready LED
GPIO.setup(22, GPIO.OUT)
# Countdown 3 LED
GPIO.setup(16, GPIO.OUT)
# Countdown 2 LED
GPIO.setup(15, GPIO.OUT)
# Countdown 1 LED
GPIO.setup(32, GPIO.OUT)
# RECord LED
GPIO.setup(33, GPIO.OUT)
# finisH LED
GPIO.setup(37, GPIO.OUT)

# Camera is ready, begin countdown
GPIO.output(37, False)
GPIO.output(22, True)
sleep(2)
GPIO.output(16, True)
sleep(2)
GPIO.output(16, False)
GPIO.output(15, True)
sleep(2)
GPIO.output(15, False)
GPIO.output(32, True)
sleep(2)
GPIO.output(32, False)
GPIO.output(22, False)

# Begin recording video
GPIO.output(33, True)

# Records 60 seconds of video at 90 fps; change wait_recording
# for length, in seconds, for video
with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 90
    camera.exposure_mode = 'antishake'
    filename = dt.datetime.now().strftime('%d-%m-%Y-%H:%M:%S.h264')
    camera.annotate_text = dt.datetime.now().strftime('%d-%m-%Y %H:%M:%S')
    camera.start_recording(filename,format='h264')
    start = dt.datetime.now()
    while (dt.datetime.now() - start).seconds < 60:
        camera.annotate_text = dt.datetime.now().strftime('%d-%m-%Y %H:%M:%S')
        camera.wait_recording(0.2)
    camera.stop_recording()
    
# Finish
GPIO.output(33, False)
GPIO.output(37, True)
sleep(10)
GPIO.output(37, False)

GPIO.cleanup()

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.