Unlock Ideas | Raspberry Pi Dashcam Project
single,single-post,postid-21470,single-format-standard,ajax_fade,page_not_loaded,,select-theme-ver-2.0,wpb-js-composer js-comp-ver-4.4.4,vc_responsive

Raspberry Pi Dashcam Project

Raspberry Pi Camera

Raspberry Pi Dashcam Project

Before You Begin

Before starting a project, it is sensible to ensure that you have everything to hand. This avoids frustration part way through the process. Here’s what you will need:


Prepare Your SD Card

Step 1. Formatting SD Card

  • Open SDFormatter (this will require your admin password)
  • Select your SD card from the drop down
  • Choose “Overwrite” in the formatting options
  • Now press the format button, sit back and wait, this could take a while depending on the size of your SD card


Step 2. Flashing The SD Card

There are several different options for flashing an SD card wth a disk image, all depending on what Operating System you’re running, since I’m running a Mac I used ApplePi-Baker.

Alternatively you could follow on of the official guides at: RPi Easy SD Card Setup.

Before opening ApplePi-Baker, to get the main UI to open, I had to run the following command in the Mac Terminal which disables retina display for the app:

This app is really simple to use and self explanatory, in the “Pi-Ingredients : IMG Recipe” selection select the Pi image you downloaded earlier and click “Restore Backup”, depending on the size of your SD card it might be worth making a coffee.


Setting Up The Camera Module

Enabling the Pi Camera is made really simple using the “raspi-config command”

From the menu select “Enable camera” and hit Enter, then go to “Finish” and you’ll be prompted to reboot.

Once logged back in you can use this example python script to record some videos:

Don’t forget to create the recordings folder:

Converting The H264 Videos to MP4

The easiest and best way to wrap the H264 videos recorded by the Pi’s camera in an MP4 container (.MP4 files), is to install MP4Box (aka gpac)

Using the script below, that i’ve named “process_files.sh”, we can covert all the .h264 files to MP4 video files in one go.

Keeping The System Time Set Without Internet

Until I started testing I didn’t consider how the Raspberry Pi would keep it’s system time, without an active internet connection for NTP to use.
After looking at all the options, I’m using a DS3231 RTC (Real Time Clock) module which is similar to what a desktop or laptop uses and can be identified by the 3V coin battery powering it during system downtime.

When it comes to the hardware and software setup, the credit has to go to the guys at Raspberry Pi Spy who have a tutorial on setting everything up Link

PLEASE NOTE. As of a kernel update in the early part of 2015, you may be required to edit the following file before your RTC module will be recognised:

At the bottom of the file add this line before saving and exiting:

After a reboot you should be able to finish the complete the tutorial and test everything is working after some downtime and an internet-less date check.

Using The Pi As A WiFi Access Point

This may sound like an unusual idea without second thought, but many smart devices e.g. SLR cameras, use Ad-Hoc self hosted WiFi networks, to allow partner apps to access web services on the device or simply a lightweight SAMBA server to copy files with.
I won’t be going into how to setup a Debian SAMBA Server or how to make REST services using Pythons Flask framework in this tutorial, but I will give you everything you need to start experimenting yourself.

Now after trying several tutorials which didn’t work in the slightest! The experts at Adafruit recent put together a PDF outlining every little step required to set up a WiFi network on the Pi that Bridges the Ethernet connection for internet access (this part doesn’t really matter to us, but it’s good to know).

You can download the PDF from either sources:

Or if you fancy cheating, I’ve uploaded my fully working Raspberry Pi Access Point Disk Image to my Google Drive account:

You can flash your SD card the same way you would the Wheezy image, by jumping back to the “PREPARE YOUR SD CARD” section of this post.

Other Peripherals You Could Consider

Since starting this project I’ve explored many different setup variation, to find the best Dashcam functionality for what I wanted to achieve. Not to let the research and experience go to waste and in hope someone else may find what I’ve done useful here are 2 other peripherals that may work for you.

Setting Up The Touchscreen Display

I followed a great tutorial at circuitbasics.com that helped me get up and running without any hiccups: Waveshare 3.2″ TFT Setup

From the PI SSH terminal edit the following:

In this file, find the line that says: Option “fbdev” “/dev/fb0″ and change the fb0 to fb1
The fb0 option tells the video driver to output to HDMI, and the fb1 option tells it to output to the LCD screen.

We now need to change the Raspberry PI Configuration settings by running:

From the Configuration menu select “Advanced Options” followed by “SPI ENABLE/DISABLE AUTOMATIC LOADING” and select “Yes” for both the questions asked.

We’re done here for now and need to do a reboot for the changes to take affect

We can download and install the drivers for the Touchscreen. At the command prompt, enter:

This will download and install the drivers and kernel modules that are needed to run the LCD touchscreen (This will download 47.2 MB)

Before we reboot, we need to configure the kernel modules to enable the Touchscreen display:

Add this code below the snd-bcm2835 line to support the fbtft_device and ads7846_device modules:

Now to edit the boot command line file to enable the touchscreen on boot:

Change the content of the file to match:

A word of caution: make sure the modified files “root=” value is the same as what it was before, I made this mistake the first time I tried to setup the touchscreen and was left unable to boot afterwards.

If you want the screens orientation to be Landscape change “fbtft_device.rotate=0” to “fbtft_device.rotate=90”. This value can be changed to either; 0, 90, 180 or 270.

We’re almost done, the last step is to enable the touch sensor of the screen, edit:

And append the following after the last entry:

That should do it, reboot your PI and you should see your PI’s boot process on the screen.

Setting Up Bluetooth Serial Comms

So that I could run tests and debug from the passenger seat I needed to enable Bluetooth Serial comms to run shell sessions without WiFi.

To take control of the serial port for the project to use, you need to disable login automatically using the port at boot.

Step 1. /etc/inittab

Using your favourite text editor you need to modify /etc/inittab

Find the line like:

And comment it out to prevent the port being used for the login prompt:

Step 2. /boot/cmdline.txt (optional)

Now edit the /boot/cmdline.txt file to stop bootup information being sent to the serial port.
This maybe useful if you ever want to debug boot processes.

The contents of the file look like this

Remove all references to the serial port (ttyAMA0) so the file now looks something like this:


As of writing this post I’m still deciding on the setup for my Raspberry Pi Dashcam, whether I want a touchscreen interface, simple 16×2 LCD screen, iOS remote app, or simply status LEDs discreetly placed near the rev counter. With this in mind I’ll undoubtably be updating this post with any further developments.

After plenty of reading and experimenting I hope I’ve managed to give you everything you need to get up and running with your own Raspberry Camera project.

Here’s an photo of my current solution:
Raspberry Pi Dashcam

I’ll try to reply to any questions left in comments.

Useful Reading

No Comments

Post a Comment