Here I am creating a dashcam with simple software features and a minimal UI. One may think that this is pointless given the plethora of cheap devices already available. Indeed, the simple designs I have seen can be had for as little as $30. However, a two camera design competes with dashcams that cost over $200, and with added GPS, the home build becomes competitive. The new release of the Pi zero now has added camera support! I will continue prototyping with the Model A, and switch to the zero when it arrives (albeit I had to subscribe to the magazine to get it).
Main component pricelist:
Raspberry Pi zero 5 Raspberry Pi (via magazine)
Pi Camera 25 Raspberry Pi (on hand)
GPS module 25 Microstack (on hand)
WiFi adapter 10 Edisoft (on hand)
USB camera 10 (Tiger Direct)
Wide angle lens 10 Aukey kit (Amazon)
Power supply 25 SunAir (on hand)
Battery free Old cell phone (on hand)
Obviously these are retail module prices, and a finished manufacturing design would have much cheaper components – but that is unlikely to happen, since this is just a hobby and I lack the resources to compete with manufacturing companies.
At this point, it may or may not have a display (I have a handy 2.8″ 320×200 display from Adafruit). As a headless design, it could connect using WiFi, and push chosen video to a cloud drive (such as google drive, or ownCloud), or simply save to a USB key. It could use a model A (with WiFi or a USB stick), or the latest model 3 B (which has WiFi included), or even the elusive Pi Zero. A benefit of a headless design is that the only component that would have to be visible would be the camera (and it’s cable).
Conceptually, it will take video in x second chunks, in a loop of y segments. On the “save” button press, it will save the last y segments, and continue saving for another z segments – where x, y and z would be programmable parameters. A rear facing camera would be a nice addition (using USB since the Pi only supports a single CSI camera interface). Audio would be another option (requiring a microphone – but the rear USB cam might have one included). Conveniently, I think my truck would make mounting a rear camera fairly easy.
The user can view video using their existing mobile device or computer screen, either from the USB stick, over WiFi from the cam, or their cloud of choice.
I intend to use this guide as the starting point. I would gladly credit the author, but I can’t establish his name.
So far, I have installed minibian on an 8 GB SD card. I have expanded the filesystem, renamed the system to “dashcam”, enabled the camera and also SPI and I2C (required for the Adafruit screen), and updated the software. I made the necessary modifications (from Adafruit’s website) to the kernel and boot config to drive the display. I also installed fbcp – a tool which copies the internal GPU frame buffer to the SPI console frame buffer – required for the SPI driven screen to show the Pi Camera output in real time. This may go away if I switch to headless design. Initial tests show the video from the camera on the display. I installed omxplayer to allow local replay of the h264 video produced by the raspivid tool.
In terms of hardware I have ordered a set of camera lenses from Aukey to get a wider angle on the Pi Camera. I could have gone cheaper, but I wanted glass lenses. I have a small camera bracket, and a couple of simple Pi cases I can use until I have settled on a configuration and mounting method.
I want at least two buttons – one to trigger saving video, and one to initiate shut down. If I go with the touchscreen, it has optional physical buttons already. Otherwise I will use buttons on GPIO lines and project them through the case.
I have a GPS module which I can integrate, software can overlay the time and coordinates on the video. If I take this route, I am strongly considering adding navigation software and a larger screen (7″ Pi Display) to make full use of it. NAVIT sounds like a strong contender for this. However, I shall continue building from small and see how it works out. Another piece of hardware to consider is an INU. The accelerometer can be used to trigger autosaving – in the event of a crash for example – although I suspect a simple tilt sensor would also work for this purpose. As well, an INU can be used to augment or smooth GPS data using a Kalman filter – although I am not sure whether (or how hard it would be) to integrated that into NAVIT.
I successfully hooked up my gps module (a microstack board), by connecting the 3.3, ground and TX/RX lines to my Pi headers. One issue I ran into with gps is the gpsd package does not much like systemd. On initial install, it works fine, but as soon as I reboot, it does not start. running dpkg-reconfigure gpsd starts it up again, but again it fails on reboot. I followed the instructions here, and replaced systemd with tradition sysvinit support, and my problems miraculously vanished.
I then discovered another problem – raspbian jessie comes with libgps21 and the dashcam scripts were built for version 2.2. Anyhow – I think I need to go beyond the scripts from the pidashcam guide. I think I will write a python application from the ground up, using the picamera module, gpsd.
Last but not least, I need to look at the power supply. Car cigarette lighter chargers usually drop abruptly as soon as they engine is stopped – in order to protect the car battery. This could be disruptive to data collection, and possibly injurious to the SD card. Ideally, I would have a constant 5 v supply available, and a notification when ignition goes off, in order to shutdown gracefully. I am considering tapping into the overhead cabin light supply (as this is available after ignition off), and find another line in the vicinity to tell me when ignition is off.
On further consideration, I realize I have a SunAir Solar Power Board kicking around – I bought it on a kickstarter some time ago. It is a $25 board that controls charge to a 3.7 V LiOn battery, and supplies 5 V to Raspberry Pi-like devices. It expects 6 V from a solar panel, or a mini usb connector to charge the battery / power the device. This, coupled with a cell-phone battery or two will ensure I have a smooth shutdown, or ignition-off power available. The downside of this device is that it supplies only 1000 mA, which would only supply the model A + camera safely.