APC Australia

Build a Pi-powered bodycam

Christian Cawley wants to record all the evidence that happens on his next family trip. The answer? A Raspberry Pi Zero bodycam.

-

Bodycams are chest-mounted cameras that have enough storage to record as much, oras little, footage as you like. Regularly used by police around the world, they’re also a favourite of certain vloggers. Bodycam footage could be anything from extreme sports to recordings of the San Diego Comic-Con and everything in between.

Fancy a bodycam but unsure of whether you would use it? Thanks to the Raspberry Pi Zero, you can build your own. While the Model B boards are more suited to retro gaming and media centre tasks, the Pi Zero and its variants are perfect for camera projects like this.

By combining the Pi Zero with a Raspberry Pi Camera Module, rechargeab­le battery and 3D-printed case, you can set up your own bodycam and record the day’s events for posterity. You might even livestream your activity to YouTube (see box on opposite page).

YOUR BODYCAM KIT

You’ll get the best results from this project with the latest version of the Raspberry Pi Zero or Zero W. The only difference between the two is that wireless networking and Bluetooth are available only with the Pi Zero W. Both devices have a 1GHz single-core CPU and 512MB RAM, a microSD slot, and run the latest version of Raspbian. In addition, you’ll need: Raspberry Pi Camera Module (any model)

Camera ribbon cable for Pi Zero Portable rechargeab­le battery 3D-printed case

The Raspberry Pi Camera Module you choose will affect the footage. The original camera module was just 5 megapixels, compared with the later 8 megapixels camera. Both have infrared variants, which would result in quite striking ‘washed-out’ video. These may be more suited to evening bodycam use.

A camera ribbon cable for the Pi Zero is necessary, as the port on the

Zero is smaller than that on the Pi Model A and B. Some versions of the camera module come with a suitable cable. If you don’t have one, you should be able to order one online for under a fiver.

Your battery option may differ depending on your budget, your chosen case and what you already have handy. The easy solution is a portable smartphone charging battery. For onboard power, however, a 500mAh lithium-ion polymer battery and PowerBoost 500 Charger will do the job.

Keeping the bodycam tidy in a 3D-printed case is a smart choice. Two of the two best options are the One Piece Raspberry Pi Zero + Camera Case and the (w w w. thingivers­e.com/thing:1595429) Raspberry Pi Zero Wearable Camera Case by Adafruit (www.thingivers­e. com/thing:1649799). The Adafruit option comes with a built-in clip and a hole for attaching a cord and wearing as a lanyard. Don’t own a 3D printer? Look online for a local or

“By combining the Pi Zero with a Raspberry Pi Camera Module, rechargeab­le battery and 3D-printed case, you can set up your own bodycam. ”

mail order 3D-printing business.

Whichever case you decide upon, and it may be something completely different, it’s wise to assemble the project before installing the boards in a case. Don’t do this until you’re certain everything is working right.

If you’re planning to power the Pi Zero using the li-Ion polymer battery and PowerBoost, you’ll need a soldering iron. Connect two wires around 5cm in length to the + and pins on the PowerBoost, then to the 5V and GND pins on the Pi Zero (pins 4 and 6).

Should you go full Raspbian or Raspbian Lite for your operating system? A browse of the Raspbian downloads page at www.raspberryp­i. org/downloads/raspbian reveals three options, rather than two. There’s the Raspbian Buster download with a bunch of preinstall­ed applicatio­ns, a stripped-down Raspbian Buster with Desktop (a version without the apps), and then Raspbian Lite, without a desktop.

For the purposes of demonstrat­ing this project, we used Raspbian Lite. However, for the most flexible option, you might consider Raspbian Buster with Desktop. Given the amount of space you’ll need on the SD card, it would be unwise to use the largest version of Raspbian. For quick results, copy Raspbian to the SD card using Etcher from www.balena.io/etcher, for Linux, Mac and Windows.

With Raspbian installed, connect a keyboard, mouse and monitor. Alternativ­ely, insert the SD card into your computer and create an empty file called ssh in the

/boot/ directory to enable SSH mode. For wireless use, you’ll also need to create a wpa_supplicant.conf file. Add the following lines to it:

ctrl_interface=DIR=/var/run/wpa_ supplicant GROUP=netdev update_config=1 country=US network={ ssid=”SSID” psk=”PASSWORD” key_mgmt=WPA-PSK

}

Take the time to input your own SSID and network passkey to ensure the device connects to your network. With SSH set up, the following steps should be easier.

Connecting the camera is straightfo­rward. Start by attaching the cable to the Pi Zero, then to the camera. Ensure the securing clips on both the camera and the Pi are loosened before inserting the ribbon, silver side facing up. Snap the clips back into place, then power up your Raspberry Pi Zero.

On the command line, open the configurat­ion tool:

sudo raspi-config

Here, select ‘5 Interfacin­g Options > P1 Camera’ then Yes to enable the camera. Once enabled, go to ‘7 Advanced Options > A1 Expand Filesystem’. Reboot the Pi when prompted.

The raspicam software is already installed with Raspbian, so to create a video, all you need is:

raspivid -o video.h264 -t 10000

This will record 10 seconds (10,000 millisecon­ds) of footage. You’ll probably want more than this, however. As such, some experiment­ation will be needed. The best results, of course, will be enjoyed with a larger microSD card – the Pi Zero supports up to 256GB. If you’re using the bodycam for sports, use the exposure setting:

raspivid -o video.h264 -ex sports

If you’re concerned about the amount of storage being used, the stop-motion bodycam is a smart alternativ­e. Start by checking for package updates and install the WiringPi library: sudo apt update sudo apt install -y wiringpi Next, create a new file, timelapse.sh: sudo nano /boot/timelapse.sh Next, head to Adafruit at http://bit. ly/LXF256-timelapse and grab the timelapse script. This is designed to work with an LED. Copy the timelapse script into timelapse.sh, then exit nano with ctrl-x and confirm with y. So that the code launches on startup, edit the rc.local file: sudo nano /etc/rc.local

Here, add a line before the exit 0. sh /boot/timelapse.sh 2>/dev/null & With the Pi Zero hooked up to the power supply and camera, a script for capturing video or time-lapse frames, and a case, your project is ready to go.

 ??  ?? Carefully connect the Raspberry Pi Camera Module to the Pi Zero, ensuring that the ribbon cable is correctly and securely attached.
Carefully connect the Raspberry Pi Camera Module to the Pi Zero, ensuring that the ribbon cable is correctly and securely attached.
 ??  ?? This 3D-printed bodycam case features a stylish clip for attaching to your clothes.
This 3D-printed bodycam case features a stylish clip for attaching to your clothes.
 ??  ?? A lithium-ion polymer battery and PowerBoost makes the project more flexible than using a portable mobile phone charger.
A lithium-ion polymer battery and PowerBoost makes the project more flexible than using a portable mobile phone charger.

Newspapers in English

Newspapers from Australia