...

Building A Dashcam With The Raspberry Pi Zero W

building-a-dashcam-with-the-raspberry-pi-zero-w
raspberry-pi-zero-w
by Ramon Persaud

I’ve been playing around with the Raspberry Pi Zero W lately and having so much fun on the command line. For those uninitiated it’s a tiny Arm computer running Raspbian, a derivative of Debian. It has a 1 GHz processor that had the ability to be overclocked and 512 MB of RAM, in addition to wireless g and bluetooth.

raspberry pi zero w with wireless g and bluetooth

A few weeks ago I built a garage door opener with video and accessible via the net. I wanted to do something a bit different and settled on a dashcam for my brother-in-law’s SUV.

I wanted the camera and Pi Zero W mounted on the dashboard and to be removed with ease. On boot it should autostart the RamDashCam (RDC) and there should also be 4 desktop scripts dashcam.sh, startdashcam.sh, stopdashcam.sh, shutdownshutdown.sh. Also create and a folder named video on the Desktop for the older video files. I also needed a way to power the RDC when there is no power to the vehicle’s usb ports. Lastly I wanted it’s data accessible on the local LAN when the vehicle is at home.

Here is the parts list:

  1. Raspberry Pi Zero W kit (I got mine from Vilros.com)
  2. Raspberry Pi official camera
  3. Micro SD card, at least 32 gigs
  4. A 3d printed case from thingverse.com
  5. Portable charger, usually used to charge cell phones and tablets on the go
  6. Command strips, it’s like double sided tape that’s easy to remove or velcro strips

 

First I flashed the SD card with Raspbian, powered it up and followed the setup menu. I also set a static IP address.

Now to the fun stuff. Lets create a service so we can start and stop RDC via systemd. Using your favorite editor, navigate to “/etc/systemd/system/” and create “dashcam.service”  and add the following:

[Unit]
Description=dashcam service
After=network.target
StartLimitIntervalSec=0 [Service]
Type=forking
Restart=on-failure
RestartSec=1
User=pi
WorkingDirectory=/home/pi/Desktop
ExecStart=/bin/bash /home/pi/Desktop/startdashcam.sh [Install]
WantedBy=multi-user.target

 

Now that’s complete lets enable the service, run the following: sudo systemctl enable dashcam

I added these scripts to start and stop RDC on the Desktop so my brother-in-law doesn’t have to mess around in the menus or command line. Remember to “chmod +x” these 4 scripts.

 

startdashcam.sh

#!/bin/bash # remove files older than 3 days
find /home/pi/Desktopvideo -type f -iname '*.flv' -mtime +3 -exec rm {} ; # start dashcam service
sudo systemctl start dashcam

 

stopdashcam.sh

Discover more from WIREDGORILLA

Subscribe now to keep reading and get access to the full archive.

Continue reading