Car Raspberry Pi3 Dash Cam





I have previously worked with Arduino boards to develop a motion based mobile alerts. But always wanted to work with Raspberry Pi because of the diversified 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 files more than 30 days old.

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

4) When car ignition key is turned off, 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 off 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 files 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 files from inside my car cabin thru either bluetooth or wifi]

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Ended Up Buying the Following Hardware

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

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

3) Snap plugs for easy installation and snug fit.

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

5) 2 LM2596 Step Down Module DC-DC Buck Converter - one to convert 12V Car Voltage to 5V to 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/off from Car Ignition 12V]

6) micro USB cable, cut off 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 files 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. Didn't use Raspberry Pi camera module as I was concerned about the length of flex 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]

Step 2: Tools Required

1) Solder kit

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

Step 3: Set Up Everything

1) Install 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/off from Car Ignition 12V]

3) Configure the timer circuit to function-10 [120 sec Delayed relay switch off once trigger goes off - This is how you achieve physical shutdown of Raspberry Pi after 2 mins, once car Ignition switch is turned off.]

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 anotherinstructionfrom Instructables. This will make sure time is always maintained.

6) Configure your wifi for 2 routers - 1) home - for development/testing 2) to your mobile[Wifi Tethering].

7) I didn't use raspberry bluetooth as didn't find any easy way to connect automatically without display and share files later to my mobile.

8) Install 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 Apache web server. so that you can access files 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.

Step 4: Write Some Shell Scripts/python Code

I have published all scripts and folder structure to GitHub. Below would give some overview on what is done.

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

To record from USB Cam

@reboot /home/pi/CamProj/scripts/shell/ &

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

@reboot sudo python /home/pi/CamProj/scripts/python/ &

Delete any video/log files older than 30 days. For a 32 GB SD card this archival policy was good.

@reboot sudo /home/pi/CamProj/scripts/shell/ &

Step 5: Solder All Components Together and Final Testing

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 final look as I was totally new to this. I did some extensive testing for hrs to make sure the setup was pretty stable and fined tuned the code at this stage.

Some testing I did to make sure all worked:-

- Was the file 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 flex cable length restriction.

- Simulated the car key Ignition on/off toggle very frequently/randomly to make sure the OS booted up/shutdown and all logs were captured as expected.

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

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

Step 6: Time to Connect to the Car

- The wiretap differs 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 fit the USB Cam nicely behind the rear view mirror.

- Pass the Usb cable behind the headliner to A-Pillar to go inside the glove box and to the engine 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.

Step 7: Conclusion

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 figure 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.


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 affect 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.

First Time Author Contest 2016

Participated in the
First Time Author Contest 2016

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    42 Discussions


    Answer 12 months ago

    Yes i've got it working on the 3b+ :) a bit of fiddling required but it works.


    Reply 3 months ago

    Can you give some information on what fiddling was required to get this working on a 3b+? Thank you!!


    Question 3 months ago

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


    Tip 6 months ago on Step 4

    If you are having troubles with the 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 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!


    Question 8 months ago

    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

    Answer 8 months ago

    I have wired it in a way such that as soon you turn the key to 'ON' position, the CH1 and LM2596 3.3V connections are powered. Thus powering 'on' the Raspberry PI. You usually start the car after putting the Ignition to 'ON' position. so process should continue as normal. But for some reason if you decide to switch 'OFF' the Ignition and take out the keys immediately, then Raspberry Pi will gracefully shutdown within 2 mins using the combination timer module and python code running within Raspberry PI. This could be optimized in several ways, but I never had issues for almost a year when I was using this setup in the car. Hope this info helps !!!


    Tip 9 months ago on Step 7

    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 year ago

    Nice one. Is there a way to make it with some kind of manual record and stop buttons?

    3 replies

    Reply 1 year ago

    Sure you can. It is a matter of adding Tactile switch, then interfacing with GPIO pins and using it appropriately in the python code.


    Reply 10 months ago

    Hi there, how do you prevent data loss if it is shut off early? I've been working on making a manual dashcam, so I removed -t. What python modules should I be using? I've got GPIO, and sys to run the shell script instead of crontab. I can make the mp4 file, but don't know how to stop recording properly so that it saves and isn't corrupted. Any tips would be appreciated :P


    Reply 10 months ago

    Sorry..but couldn't answer this very specific question, but the setup I had worked for a year without any issues as the shutdown itself stops the recording..Yeah, it can be improved in many ways, but this setup gave me on what I want. The entire code base for this setup is under GitHub and you can use it for your reference.


    Tip 12 months ago on Step 3

    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.


    Question 1 year ago on Introduction

    I am sorry for my ignorance but can I add some features in the camera - let's say object or light detection? Is this possible?

    1 answer

    Answer 1 year ago

    I know at least there is motion detection using python libraries for Pi Camera. For this setup to work, the raspberry Pi has to be in always ON using the car Battery. There are workarounds for this, but let this forum know of any ideas. After all this a place to experiment and learn :)


    Reply 1 year ago

    If you plan to use the CSI port for camera it will work. USB camera uses CPU for processing and will hog for resources.


    2 years ago

    Your circuit is a bit confusing around the timer. On the right side, there are two connections labeled NO and COM. Can you clarify that area's connection to power? It looks like the NO and COM are connected to each other, to the battery and to the positive connector on the LM2596 (5v). Is this the case, or does the connection from the COM port jump over both the connection to the NO port, and the ground to the LM2596 (5v).



    2 replies

    Reply 1 year ago

    COM to +ve side of Raspberry pi Power supply via LM2596 = Finally gives 5V+.

    NO to +ve side of Car Battery [Always ON line].

    Hope that clarifies


    Reply 2 years ago

    Yeah..It did look confusing when i see it now. COM receives always ON circuit[+12V] from car battery. NO - Normally Open goes as an input [ +5V via LM2596 ] to Raspberry PI. You can see more configuration options for this timer in