steviec63
Posts: 7
Joined: Tue Feb 17, 2015 10:56 pm

Raspberry Pi Dash Cam - how?

Fri Apr 24, 2015 11:15 am

Hi,

Apologies if anyone has covered this already but I am a newby and trying to create a dash cam.

Hardware components I have:
Raspberry Pi (Raspbian OS)
Berry Clip
Raspberry Pi Camera
USB Flash Drive

Questions:
- Does the USB drive need mounting and if so how?
- I have no Python knowledge so how do I record and then convert the file to an MP4 format?
- How can I use the button from the Berry clip to turn the recording on from power on and show it as active with the green light but show the red light when not recording?
- How can I create a cron job so that this can work without a mouse/keyboard/monitor attached?

Thanks in advance for any input / help.

Cheers

Steve

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Raspberry Pi Dash Cam - how?

Fri Apr 24, 2015 11:32 am

steviec63 wrote:Hi,

Apologies if anyone has covered this already but I am a newby and trying to create a dash cam.

Hardware components I have:
Raspberry Pi (Raspbian OS)
Berry Clip
Raspberry Pi Camera
USB Flash Drive

Questions:
- Does the USB drive need mounting and if so how?
- I have no Python knowledge so how do I record and then convert the file to an MP4 format?
- How can I use the button from the Berry clip to turn the recording on from power on and show it as active with the green light but show the red light when not recording?
- How can I create a cron job so that this can work without a mouse/keyboard/monitor attached?

Thanks in advance for any input / help.

Cheers

Steve
Hi,
that's a lot of questions. Most of these can easily be answered with google/search facilities of this forum, but the best approach is to cover each subject separately.
One question back at you - what do you think cron will do for you, as I do not think it will help you in the way you describe. In order for you to use your Pi as you say, ie 'headless', you need to network into it with ssh/putty.

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
RaTTuS
Posts: 10558
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Raspberry Pi Dash Cam - how?

Fri Apr 24, 2015 11:39 am

easy answer is you don't...

you arrange the Rpi to boot up fast and immediately go into record mode - either on the SDcard [big enough] or USB stick
then you need to have a battery backup solution to shut down the PRi when the power is removed,
charge it via the cars 12V supply
it all has to be automatic

you have to have it shut down gracefully as if power is removed in a crash or other stuff it has to close down properly otherwise the data may well be useless.
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

steviec63
Posts: 7
Joined: Tue Feb 17, 2015 10:56 pm

Re: Raspberry Pi Dash Cam - how?

Sat Apr 25, 2015 2:09 pm

I have scanned the internet for tutorials and I did find one that I tried to follow which mentioned a cron job but the tutorial didn't really answer all the questions and now I am left with a desktop with no icons so have replaced the memory card again.

I am extremely new to all this and have probably picked a project that's too intense for my lack of knowledge but I basically need it to record through raspivid to the length of about 20 minutes at a time, write to a USB memory stick, convert from H264 to MP4 and overwrite the existing files when the memory starts to become full.

Because I want this in my car, I don't want to have to attach a monitor or use a remote network connection so want everything to rely on the Berry Clip so as soon as power is attached it will boot and be ready to go, one push of the button starts the record, another stops it and a long hold down on the button starts the power off for the raspberry pi. Is this possible and if so, can someone point me in the right direction?

Many thanks,

Steve

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Raspberry Pi Dash Cam - how?

Mon Apr 27, 2015 9:05 am

steviec63 wrote:I have scanned the internet for tutorials and I did find one that I tried to follow which mentioned a cron job but the tutorial didn't really answer all the questions and now I am left with a desktop with no icons so have replaced the memory card again.

I am extremely new to all this and have probably picked a project that's too intense for my lack of knowledge but I basically need it to record through raspivid to the length of about 20 minutes at a time, write to a USB memory stick, convert from H264 to MP4 and overwrite the existing files when the memory starts to become full.

Because I want this in my car, I don't want to have to attach a monitor or use a remote network connection so want everything to rely on the Berry Clip so as soon as power is attached it will boot and be ready to go, one push of the button starts the record, another stops it and a long hold down on the button starts the power off for the raspberry pi. Is this possible and if so, can someone point me in the right direction?

Many thanks,

Steve
Steve,
please see my earlier post as I can only give the same advice. One thing I would say is that you probably do not need to use the GUI desktop for any of the software you will end up using. Are you at least to remotely log into the pi using Putty/ssh ?
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
RaTTuS
Posts: 10558
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Raspberry Pi Dash Cam - how?

Mon Apr 27, 2015 9:20 am

assuming you mount your USB stick as /mnt/Video
update everything on it via
sudo apt-get update && sudo apt-get upgrade -y
no need for any desktop stuff keep it at the commandline

a crontab like the following will do 59mins of video over written each month
crontab -e
0 * * * * /usr/bin/raspivid -t 3540000 -o /mnt/Video/`/bin/date +\%w:\%H`.h264

or
use a simple bash loop
to increase a file counter say from 0-9
and loop record
i.e.
/usr/bin/raspivid -t 1200000 -o/mnt/Video/file.h264
will do 20mins
I know nothing about berryclip but I assume it comes with instruction on how to make it do stuff
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

steviec63
Posts: 7
Joined: Tue Feb 17, 2015 10:56 pm

Re: Raspberry Pi Dash Cam - how?

Wed Apr 29, 2015 4:32 pm

So I've been looking into this and I understand that on the command line I can mount the usb stick using the following:

#How to mount a USB drive
cd /mnt/
sudo mkdir usb
dmesg #(tells you the name of the device (possibly sda))
sudo mount /dev/sda /mnt/usb
df -h #should show you the USB

Then how do I create a cron job to do the following:

crontab -e
0 * * * * /usr/bin/raspivid -t 3540000 -o /mnt/Video/`/bin/date +\%w:\%H`.h264

and that's with the understanding I can just discard the berry clip/pibrella so I can just turn the Raspberry Pi on and it will automatically start to record from boot and then I just need to find a way to make it all power down without brutally pulling the power. Any suggestions on that?

I didn't really want to use a remote connection to it as I want it to be just like a dash cam you can buy from the shop.

Cheers,

Steve

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Raspberry Pi Dash Cam - how?

Wed Apr 29, 2015 4:55 pm

Just try it - what do you have to loose?

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

steviec63
Posts: 7
Joined: Tue Feb 17, 2015 10:56 pm

Re: Raspberry Pi Dash Cam - how?

Wed Apr 29, 2015 5:03 pm

lol - my sanity!

I guess I am just scared and have overwhelmed myself a little with everything I think I need it to do when its probably quite simple.

I do appreciate the help though and now have an idea how to create a cron job :)

steviec63
Posts: 7
Joined: Tue Feb 17, 2015 10:56 pm

Re: Raspberry Pi Dash Cam - how?

Wed Apr 29, 2015 6:42 pm

Ok I am really sorry but I've spoken too soon - I have managed to add that line of code to the crontab -e but when I do ctrl X and then Y and then go back into it, the line of code has gone. I've tried rebooting it as well but it wont stick.

alik47
Posts: 7
Joined: Sat Apr 29, 2017 12:37 pm

Re: Raspberry Pi Dash Cam - how?

Wed Oct 11, 2017 10:47 pm

Hi Steve,

if you want you can test my Project: viewtopic.php?f=41&t=181861

Image

If there are any improvements to make or wishes let me know!

Thanks
Ali

mlepage
Posts: 95
Joined: Tue Jun 12, 2012 1:58 am

Re: Raspberry Pi Dash Cam - how?

Sat Oct 14, 2017 11:43 pm

I'll probably make a dash cam some day eventually. If I do, I'll make a guide.

Return to “Other projects”