You are on page 1of 21

 (/) Circuits

Car (/circuits/)
Raspberry Workshop
Pi3 Dash Cam (/workshop/) Craft (/craft/) Cooking
by vijayp44 (/member/vijayp44/) (/cooking/)
Follow Living (/living/) Outside (/outside/) Teachers (/teachers/) Download Log Favorite
w
In (/account/login/) | Sign
I Made It Up (/account/register/)

instructables (/circuits/)
circuits
Projects (/circuits/projects/) Contests (/contest/) Let's Make... 
Car Raspberry Pi3 Dash Cam
By vijayp44 (/member/vijayp44/) in Circuits (/circuits/) > Raspberry Pi (/circuits/raspberry-pi/projects/) 81,671 224 49 Featured

Download Favorite

auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=ba643fd0d3019237bb648d2182a6401b)
(https://cdn instructables com/ORIG/FTO/1YDO/INM7E251/FTO1YDOINM7E251 jpg?

Intro
/
I have(/member/vijayp44/)
Car Raspberry Pi3 Dash Cam by vijayp44 previously worked with
Follow Arduino boards to develop a motion based mobile alerts. But
Download Favorite w I Made It
always wanted to work with Raspberry Pi because of the diversi ed projects that could be done
relatively easily because it is a full blown mini computer running on Debian based Linux. Then I
remembered looking for a Car Dash cam a couple of years ago, but never bought one as they
didn't feature all the requirements that I had in mind. The timing was perfect as I was already
trying to explore Raspberry Pi and this use case made perfect sense to me to play around.
Luckily for me they released RaspBerry Pi 3 model very recently, so went for it.

My expectation was below:-


1) Automatically start the raspberry Pi, start webcam and record in segments of 30 min as you
soon turn on the car 12V+ Ignition Key.

2) Store videos for a month considering I spent 60 Hrs of driving on an average. Then delete any
video les more than 30 days old.

3) Log all actions into a log le and again delete anything more than 30 days old.

4) When car ignition key is turned o , video recording should stop after 30secs and a graceful
shutdown of OS has to be initiated. After 2 minutes, the power has to be completely cut o from
the car battery. I don't want to risk with a dead car battery at any cost.

5) Finally the most important thing is to access the video and log les from my Android mobile
device without connecting any cables or having to connect any keyboard/mouse/display to
raspberry pi. [i.e. need to conveniently access les from inside my car cabin thru either bluetooth
or wi ]

 Add Tip V Ask Question | Comment Download

Step 1: Ended Up Buying the Following Hardware

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=38a8174d24f84031683cc97863b60660)
(https://cdn instructables com/ORIG/FLM/6RBE/INM7E2XT/FLM6RBEINM7E2XT jpg?

1) 12V 2amp Wall Wart - This is mainly to simulate the car battery during my
development/testing e ort.

2) 12V Dc on/o toggle switch. Can be handy when required, but optional.

3) Snap plugs for easy installation and snug t.

4) DC 12V Multifunction Self-lock Relay PLC Cycle Timer Module from Ebay - This will give you
the 2 min delayed physical power o to the Raspberry Pi.

/
5) 2 LM2596
Car Raspberry Pi3 Dash Cam by vijayp44 Step Down
(/member/vijayp44/) Module
Follow DC-DC Buck Converter - one to convert 12V Car Voltage to 5V to Favorite
Download w I Made It
power up Raspberry Pi and the other - 12 to 3.3V to be connected to one of GPIO input pins[This
will be used to signal turn on/o from Car Ignition 12V]

6) micro USB cable, cut o and then will be soldered to one of the LM2596 voltage regulator.

7 RaspBerry Pi3

8) RTC module - ds3231. To maintain time for raspberry pi...Note as it is installed in car there is no
way for me to maintain time unless we have this module. We can also go without this module,
but this makes life much easier to have the les organized and have the right timestamps.

9) Universal PCB Board to hold all components together in a neat layout.

10) 22 Gauge wires for soldering components together.

11) USB Web Cam - Anything from the compatibility chart here (http://elinux.org/RPi_USB_Web-
cams). Didn't use Raspberry Pi camera module as I was concerned about the length of ex cable
to be used with the CSI port. Also bought a USB extension cable as in my case I required more
than 2 meters of wire.

12) 32 GB micro SD Card - almost 4-5 GB will be used for OS and have at least 20 GB remaining to
store 50 hrs of video [DVD quality]

 Add Tip V Ask Question | Comment Download

Step 2: Tools Required

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=340c51c8cca255893d4c871ffa6b8eef)
(https://cdn instructables com/ORIG/F51/RXDF/INM7E21Z/F51RXDFINM7E21Z jpg? auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=14b45f3b09e576f6142d48d98190e
(https://cdn instructables com/ORIG/FDK/K9MC/INMAWH0I/FDKK9MCINMAWH0I jpg?

/
1) Solder
Car Raspberry Pi3 Dash Cam by vijayp44 kit
(/member/vijayp44/) Follow Download Favorite w I Made It

2) Hot Glue Gun

3) Cutting tools - nose plier, wire cutter, wire stripper

4) Heat Shrink Tubes, electrical tapes

5) Your own custom case - I used a small neat storage box from michael's store.

6) Multimeter for testing and tuning voltages for LM2596 Step Down Module DC-DC Buck
Converter

 Add Tip V Ask Question | Comment Download

Step 3: Set Up Everything

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=744633ef582270
(https://cdn instructables com/ORIG/F95/PPUC/INM7E2IF/F95PPUCINM

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

2 More Images
auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=489574077bbf61685b2f3a79046cf4d9)
(https://cdn instructables com/ORIG/F8W/M65O/INM7E2EE/F8WM65OINM7E2EE jpg?

1) Install (https://www.raspberrypi.org/documentation/installation/noobs.md) Noobs to


RaspberryPi 3 using the 32GB SD Card.

2) Tune the 2 LM2596 Step Down Module DC-DC Buck Converter. One to 5V and the other to
3.3V be connected to one of GPIO input pins[This will be used to signal turn on/o from Car
Ignition 12V]

3) Con gure (http://www.plexishop.it/pdf/I120%20-%20datasheet.pdf ) the timer circuit to


function-10 [120 sec Delayed relay switch o once trigger goes o - This is how you achieve
physical shutdown of Raspberry Pi after 2 mins, once car Ignition switch is turned o .]

4) Connect the 12V Wall Wart and all other components as shown in diagram. For now skip the
timer circuit to make development faster.

5) Connect RTC module - ds3231. I followed anotherinstruction (http://www.raspberrypi-spy.-


co.uk/2015/05/adding-a-ds3231-real-time-clock-to-the-raspberry-pi/) (http://www.raspberrypi-
spy.co.uk/2015/05/adding-a-ds3231-real-time-clock-to-the-raspberry-pi/)from Instructables.
This will make sure time is always maintained.

6) Con gure your wi for 2 routers - 1) home - for development/testing 2) to your mobile[Wi
Tethering].

7) I didn't use raspberry bluetooth as didn't nd any easy way to connect automatically without
display and share les later to my mobile.
/
8) Install
Car Raspberry Pi3 Dash Cam by vijayp44 (http://www.raspihub.com/go/bab90e6facaf540d64f-
(/member/vijayp44/) Follow Download Favorite w I Made It
b7488d0d07e3661128793c4eec53261c7c36699842177)avconv for USB video recording.I didn't
use motion to record as that was more for motion based recording and didn't quite get the
controls i needed.

9) Install (https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md)
Apache web server. so that you can access les directly through http.

10) Connect everything as shown in the circuit diagram. I am no expert in doing circuit
schematic diagrams :) and hopefully my rough diagram explains everything even to the novice
reader over there.

 Add Tip V Ask Question | Comment Download

Step 4: Write Some Shell Scripts/python Code

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

auto=webp&frame=1&height=1024&fit=bounds&md=ad56a636036e7f65f27010498c3cd1de)
(https://cdn instructables com/ORIG/FHB/RUBB/INM7E2DI/FHBRUBBINM7E2DI jpg? auto=webp&frame=1&height=1024&fit=bounds&md=35389f6f39c9c2d2a94fadf0
(https://cdn instructables com/ORIG/F73/DNYK/INM7E2CO/F73DNYKINM7E2

I have published all scripts and folder structure to GitHub (https://github.com/vijay2552007/Car-


Cam). Below would give some overview on what is done.

Put the following Crontab entries on bootup so that everything starts once pi nishes bootup.

To record from USB Cam

@reboot /home/pi/CamProj/scripts/shell/record.sh &

To monitor Ignition position through GPIO pins/python code and shutdown system
gracefully

@reboot sudo python /home/pi/CamProj/scripts/python/Monitor12V.py &

/
Delete
Car Raspberry Pi3 Dash Cam by vijayp44 any video/logFollow
(/member/vijayp44/) les older than 30 days. For a 32 GB SD card this archival policy was
Download Favorite w I Made It
good.

@reboot sudo /home/pi/CamProj/scripts/shell/deletearch.sh &

 Add Tip V Ask Question | Comment Download

Step 5: Solder All Components Together and Final Testing

auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=c5735c8738a892a9cb432cf0eda3
(https://cdn instructables com/ORIG/F5H/KEVT/INM7E212/F5HKEVTINM7E212 jpg?

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

6 More Images
auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=99fb984ac314d86a63c18a8e3d1eefa9)
(https://cdn instructables com/ORIG/FUQ/5U48/INM7E208/FUQ5U48INM7E208 jpg?

I soldered all components together and hot glued into the plastic box. Wasn't a perfect work,
but hey I was impressed myself with the nal look as I was totally new to this. I did some
extensive testing for hrs to make sure the setup was pretty stable and ned tuned the code at
this stage.

Some testing I did to make sure all worked:-

- Was the le deleted after a pre set time? I don't want the sdcard to become full and crash the
entire system.

- How good was the recording when camera was shaked and under low light settings? It was
good for a USB camera and would have been much better if it was a Pi Camera. Anyway I didn't
go for that because of the ex cable length restriction.

/
- Simulated
Car Raspberry Pi3 Dash Cam by vijayp44 the car keyFollow
(/member/vijayp44/) Ignition on/o toggle very frequently/randomly to make sure the OS
Download Favorite w I Made It
booted up/shutdown and all logs were captured as expected.

- Did some eld testing with car with Key Ignition on/o before I put the system inside the car.

- Accessed the video les from inside car cabin using Android Wi Tethering in mobile and with
Apache web server running on Pi. [i.e Pi connects to mobile as router]

 Add Tip V Ask Question | Comment Download

Step 6: Time to Connect to the Car

auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=c1838403840aa1cb1f45126ca7b5a
(https://cdn instructables com/ORIG/FVF/YGKO/INM7E245/FVFYGKOINM7E245 jpg?
/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

5 More Images
auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=affb076b73017e6a8f3020f9d0b7cbc6)
(https://cdn instructables com/ORIG/FFL/MFVY/INM7E28V/FFLMFVYINM7E28V jpg?

- The wiretap di ers between various car models, but you would need 3 basic connectors
coming out of the car

a) 12V always on from battery

b) 12V Ignition key On

c) Ground wire

- Use suction cup with mount to t the USB Cam nicely behind the rear view mirror.

/
- Pass(/member/vijayp44/)
Car Raspberry Pi3 Dash Cam by vijayp44 the Usb cable behind
Follow the headliner to A-Pillar to go inside the glove box and to the engine Favorite
Download w I Made It
bay as shown in pic. I didn't remove the headliner and A-pillar for these and was able to push
the cable from side. But was forced to remove the glove box to get proper access to route the
wire further.

- Keep the Pi box in a place where it does not move, connect the USB cable, power cables and
zip tie all in place.

 Add Tip V Ask Question | Comment Download

Step 7: Conclusion

Raspberry Pi 3 Car USB Cam

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download Favorite w I Made It

Below are my observation after having this installed in car for a couple of days

- First I was very much impressed with the stability and complete autonomous nature of the
system.

- Every time Pi booted, recorded and shutdown gracefully.

- No drain of battery.

- The quality was acceptable considering Pi does real time MPEG 4 encoding. Will try Pi Camera
module for 720P recording later if I could gure out a way to overcome the cable length
restriction without any signal loss.[I need 3 meters of cable length going inside tight corners
with twists] . Appreciate any suggestions here.

- Check out the video quality yourself which I took after all was connected.

- Last but not the least, the joy you get during the whole build process and viewing the end
product work has no words to describe. Pls input your feedback for improvements/suggestions
and I will try to incorporate.

Disclaimer:-

This Instructable info is to share my experience and intended purely for informational purpose
only. Changes may occur in circumstances at any time that may a ect the accuracy or
completeness of the information presented within any section. I do not accept responsibility for
any loss,expense or liability that you may incur from using or relying on the presented
information.

 Add Tip V Ask Question | Comment Download

Participated in the
First Time Author Contest 2016 View Contest
(/contest/firsttimeauthor/)
/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Be the First to Share Download Favorite w I Made It

Did you make this project? Share it with us!

I Made It!

Recommendations

(/id/Refrigerator-Magnet-Clock/) (/id/Crystal-Glass-Beads-and-LEDs-a-Kind-of-
Kaleidoscop/)
Refrigerator Magnet Clock
(/id/Refrigerator-Magnet-Clock/) by Crystal Glass Beads and LEDs - a Kind of
Moose408 (/member/Moose408/) in Clocks Kaleidoscope (/id/Crystal-Glass-Beads-

 246 8 23K
and-LEDs-a-Kind-of-Kaleidoscop/) by

 859 5.1K

(/contest/mim2020/) (/contest/buildatool/)

 Add Tip

V Ask Question

| Post Comment

/
We have a be nice policy.
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Please be positive and constructive. Download Favorite w I Made It

Add Images Post

49 Discussions

(/member/c-fuu/) c-fuu (/member/c-fuu/) Question 25 days ago


Answer / Upvote
Great project! I was wondering, since it's a bit scary (to me at least) that the Pi will have to constantly
shutdown and startup depending on the ignition key, how would we able to add in a battery
pack/powerbank to prevent this? As in, how would the wiring go? Sorry, a bit new to these thing.

Cheers for this, appreciate it very much!


1 answer F

lalohambrickday (/member/lalohambrickday/)
(/member/lalohambrickday/)
Question 5 weeks ago on Step 3
Answer / Upvote
Hey Vijayp44,
How do you use the Cron tabs? What are they for?
I have a rasp 4.

(/member/shinigami.ric/) shinigami.ric (/member/shinigami.ric/) 2 months ago on Step 7

Reply / Upvote
Thank you so much! I use your script with the time relay to automatically gracefull shutdown the rpi3
carpc. It works great!
1 reply F

(/member/GabrielDimonde/) GabrielDimonde (/member/GabrielDimonde/) Question 4 months ago

Answer / Upvote
/
Hey vijay! im new to python and wanted to program this on my own, but I'm having a lot of trouble
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Download
understanding how your code deletes videos after 30 days. I even gave your code a look and I still
Favorite w I Made It
cannot figure out how to read the age of all of the files in a given folder. If you could shed some light
on how your delete video code works, it would be much appreciated!

/1 (/member/xthree/) xthree (/member/xthree/) Tip 1 year ago on Step 4


Reply / Upvote
If you are having troubles with the Monitor12V.py (http://monitor12v.py) script monitoring ignition
voltage on pin 40, change GPIO.setmode(GPIO.BCM) to GPIO.setmode(GPIO.BOARD).

This fixed it for me. With it set to BCM, I was locked out of the Pi due to
it sending the shutdown command right when the PI booted up. I had to
take the SD card out, and manually rename the file to something else
just so I could boot up again. Then I debugged. I found that issue with
the Monitor12V.py (http://monitor12v.py) script.

BOARD mode uses the pin numbers as they are numbered by the PI. BCM mode uses a numbering
scheme that is tied to the Broadcom chip specs.

I feel like this fix should be for all Pis, but I could be wrong. I am using a Raspberry Pi 3b.

Hope this helps someone!


1 reply F

(/member/BenjaminH10/) BenjaminH10 (/member/BenjaminH10/) Question 2 years ago

Answer / Upvote
Hi would this work with a raspberry pi 3b+?
2 answers F

(/member/rpotthoff62/) rpotthoff62 (/member/rpotthoff62/) Question 1 year ago

Answer / Upvote
This is great Work!
I would like to know if I can do more then one camrea?
Want to use this on my Motorcycle.

/
ZathrasSquared (/member/ZathrasSquared/) Question 1 yearDownload
ago
(/member/ZathrasSquared/)
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Follow Favorite w I Made It
Answer / Upvote
Hi. Following along this tutorial to build my own Pi Dashcam (although with a Pi Zero and the Pi
Camera), and just wanted to clarify: there is a direct electrical connection between the car ignition (or
the plug/socket from the ignition), CH1, and the +ve of the 3.3V LM2596, correct?
Presumably the tap from the ignition is from the 'ON' position, not the 'START', or the Pi will boot and
immediately (2 minutes later) shutdown whenever you start the car?
Hopefully you're still getting notifications for this Instructable, and thanks for making it.
1 answer F

(/member/FeritO4/) FeritO4 (/member/FeritO4/) Tip 1 year ago on Step 7


Reply / Upvote
what about saving the video files on a flashdrive or 2,5" harddrive with a usb extention cable in the
glove compartment.
would also make life a lot easier if you want to save more than 1 file or watch dem on a pc

/1 (/member/KeithM9/) KeithM9 (/member/KeithM9/) 2 years ago


Reply / Upvote
Nice one. Is there a way to make it with some kind of manual record and stop buttons?
3 replies F

(/member/alextovey/) alextovey (/member/alextovey/) Tip 1 year ago on Step 3

Reply / Upvote
To install apache in RPI to go the console and type sudo apt-get install apache2

To install the cron tab items go to terminal and type crontab -e


Scroll tothe bottom and type in the command lines without any timings. save and exit.

More Comments Post Comment

/
Car Raspberry Pi3 Dash Cam by vijayp44 (/member/vijayp44/) Categories
Follow About Us Download Resources
Favorite w I Made It

 Circuits  Living Who We Are (/about/) Sitemap (/sitemap/)


(/circuits/) (/living/) Why Publish? Help (/id/how-to-
 Workshop  Outside (/create/) write-a-great-
(/workshop/) (/outside/) Jobs (/jobs/) instructable/)
 Craft  Teachers Contact (/contact/)
(/craft/) (/teachers/)
 Cooking
(/cooking/)
Find Us

(https://www.instagram.com/instructables/) (https://www.pinterest.com/instructables) (https://www.facebook.com/instructables) (https://www.twitter.com/instructables)

© 2020 Autodesk, Inc.

Terms of Service (http://usa.autodesk.com/adsk/servlet/item? Privacy Statement (http://usa.autodesk.com/adsk/servlet/item? Privacy Legal Notices & Trademarks
siteID=123112&id=21959721) siteID=123112&id=21292079) settings (http://usa.autodesk.com/legal-notices-trademarks/)
| | |
(http://www.autodesk.com)

You might also like