This is the final output from the road test
of the dashcam prototype. The camera seems
to be out of focus and as you can tell there
is a lot of scope for improvement. The project
is not yet complete and I have decided to
make some major changes to improve the overall
usability. I will talk about these towards
the end of the video. I also think that the
scripts written for this prototype may be
of use to some of you so I will share them
and show you how I built the prototype, for
those who want to follow along.
I decided to reinstall the operating system
just to make sure everything works as it should.
I will quickly go over the entire process
but you can find more details by checking
out the dashcam playlist where I cover everything
in detail.
I first had to download Raspbian lite, flash
it to the microSD card and then copy the wifi
& ssh files. I then inserted the microSD card,
connected the camera, soldered the status
LED, the shutdown switch and then powered
it on. I then logged into the board and enabled
the camera along with the serial port using
raspi-config. Next, I had to update the operating
system by running this command and then install
the required libraries using the commands
shown on screen. Finally, I had to disable
the getty service and we were ready to run
the scripts.
I copied the files over to the board using
filezila, and then logged back into the board
to automate the script. This was done by using
crontab and adding the following line to the
file. As we will see later, this also creates
a log file which can be useful for debugging.
I then rebooted the board and it automatically
ran the script and started recording as seen
here. I verified this by checking the log
file and everything seemed to be working as
it should. Next I had to add an enclosure
so I started by desoldering everything. I
used this model from thingiverse which was
recommended by one of the viewers. It appears
to be very well designed with space to glue
magnets for mounting along with screw holes
for additional mounting options. There is
also a cutout for the camera as well as a
cutout for the GPIO pins.
The camera sits in this location and I decided
to mount the GPS here, with the antenna facing
the road. This meant that I had to cut off
these standoffs and since this is only a prototype,
I was happy enough to do that. The GPS module
can be held in place along with the camera
which is good enough for now. I didn’t have
the required screws to mount everything so
I decided to use hot glue to hold things down,
starting with the camera module. I then soldered
some wires to the GPS module and glued it
into position.
I then used the raspberry pi as a reference,
cut the wires to suitable length and soldered
them to the board. I also added the status
LED followed by the shutdown switch. I decided
to pass the wires through the other half of
the enclosure but this was not needed as you
will see later. I then connected the camera
cable and added some Kapton tape to the bottom
of the board to provide some additional isolation.
Once this was done, I freed up the switch
to make the board placement a bit easier.
I then positioned it and used some hot glue
to hold it in place. This is the final outcome.
All I had to do next was pass the switch and
LED through the cutout and seal the enclosure
by pressing the halves together. I then mounted
it to a mobile phone stand using some cable
ties. This is an old stand that I had with
me and I didn’t have to use all the parts.
Before heading to the car, I decided to carry
out one final test by powering it ON. You
can see the blue LED from the GPS module through
the opening and the status LED indicates that
everything is working as it should.
I then mounted it to the car and headed out
for a short drive. It was a gloomy and frosty
day which didn’t help with the video quality.
Accessing the files was easy enough. I simply
had to bring the prototype home, power it
on using a USB cable and I could then access
the files using filezila. The log file contains
the relevant information and this tells me
that file number 14 is when the test drive
started. Each of these files is 1 minute long.
I then copied over some video files and played
them back using VLC. The original h264 files
were very choppy and I wasn’t exactly sure
what happened. I actually forgot to disable
the getty service so I wasn’t sure if that
was interfering the GPS communication which
was ultimately causing the glitches. The videos
improved significantly once they were converted
to the mp4 format so once again, I’m not
entirely sure what went wrong.
I wrote a script to convert the files to the
mp4 format. It uses MP4Box which needs to
be installed using the following command.
Once that was done, I opened up the convert-video
script and then updated the start and end
file numbers. I then ran the script, which
automatically converted and saved the files
to the output folder. I then copied them over
and played them back. As you can see, the
video is much smoother now. It still appears
to be out of focus but I am not sure if this
was because the camera was too close to the
windscreen and focussed on that instead. This
needs to be looked into as well.
And that is how this prototype was built.
Making a dashcam definitely seems possible
once the necessary tweaks have been made.
You could modify this script and use it for
whatever video recording application you may
have but there is one thing you need to do
– which is shut it down using the switch.
If you simply unplug the board without shutting
it down first, then you run the risk of corrupting
the operating system which will mean that
you will have to reinstall everything. I’ve
used raspberry pis for a while now and this
has not happened to me yet but it is definitely
a possibility which is something that needs
to be dealt with. I’ve thought about two
solutions for this, the first one uses a battery
and an additional circuit for power management.
This should work but I’d like to avoid using
a battery and that is why I am considering
the second solution which is as follows.
Currently, we are using the Raspbian operating
system for this project. When the board is
powered ON, there are several processes that
are being run from the microSD card along
with several files that are being read from
and written to as well. If you shut down the
board when something critical is being accessed
or written to, then there is a chance that
the operating system might get corrupted and
refuse to boot.
There are some operating systems that can
be run completely through RAM which prevents
this from happening. One such OS is PiCore.
I have not used it before so I will try it
out and I will also evaluate any others that
I find. While I’m at it, I will also try
to add a microphone to capture sound, along
with some sort of streaming capability so
that you can access and view the files from
your phone. I will also try to save the files
directly in the mp4 format. Instead of releasing
multiple videos, I will test everything out
and release one final video once it is completed.
That’s it for this video. The description
will contain links to the scripts if you want
to use them. Thank you for watching and I
will see you in the next one.
