Monday 23 September 2013

Installing the OS and setting up the cameras

I have tried to make this guide as easy as possible but it is recommended that you understand the
reasons behind the commands you are using. If things go wrong or a mistake is made then it is most
likely a simple fix. Restarting from scratch is easy enough but time consuming.

I make no bones about it, at first glance this seems like a fair bit of work but it really is not too bad.
And, all being well, you will have a fairly decent two camera Pi by the end of it.

Please note, I use vi for my file editing, if you prefer a more notepad style of editor then replace vi with
the word nano.


Installing the OS
In this guide I use Arch Linux. If you'd prefer to use Raspbian please follow this install guide.

This web page list many ways to install an SD card image (please take a look at it for install
instructions using Windows). If you do use that install guide then skip straight to the
"Start your Pi" section when ready.

Update: April 2018
Things have changed considerably since I initially wrote this guide, much of it is now out of date. If you are comfortable around the command line then please continue but be prepared for a fair amount of manual package installing. To save a bit of time I have created a new 2Gb image with everything for the dashcam already installed, you only need to resize the filesystem. The user names are root, camera and alarm. The passwords are the same as the user name. After installation please look at the /root/scripts/README.txt

Update: May 2016
If you don't feel like configuring things yourself you can download a 2Gb image file for the Pi 2 or 3.
You only need to resize the filesystem after installing. User names are root, camera and alarm.
The passwords are the same as the user name

Or, download and install the latest version of Arch Linux:
http://archlinuxarm.org/platforms/armv6/raspberry-pi

(http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz)
(http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz)
(http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz)
or check: http://www.raspberrypi.org/downloads and follow the Installation guide.

[+] Alternatively to install from an .img file
[-] Close image file install information

Change directory into where the file downloaded (for me it's my home Downloads directory).
MacBook-Pro:~ $ cd ~/Downloads
Double click or unzip the file.
MacBook-Pro:~ $ unzip archlinux-hf-2013-07-22.img.zip

Insert your SD card, mine mounted as follows...
MacBook-Pro:~ $ df -h
Filesystem      Size   Used  Avail Capacity  Mounted on
/dev/disk0s2   425Gi  391Gi   34Gi    92%    /
devfs          109Ki  109Ki    0Bi   100%    /dev
/dev/disk0s3    40Gi   39Gi  1.1Gi    98%    /Volumes/BOOTCAMP
map -hosts       0Bi    0Bi    0Bi   100%    /net
map auto_home    0Bi    0Bi    0Bi   100%    /home
/dev/disk2s2    29Gi  1.4Gi   26Gi     6%    /Volumes/Untitled
/dev/disk2s1    90Mi   24Mi   66Mi    27%    /Volumes/Untitled 1
Make a note of your SD cards device path, in this case it's /dev/disk2.

We need to unmount the volumes but not remove the device.
MacBook-Pro:~ $ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
(For Linux use umount /dev/disk2)

In the directory you downloaded and unzip'd the .img file install this file to your SD card using the
device path you noted earlier. N.B. Double check the device path you use is correct because
you could well be overwriting your own computers system disk!
MacBook-Pro:~ $ sudo dd bs=1m if=./archlinux-hf-2013-07-22.img of=/dev/disk2

If it is working correctly the prompt should not return for quite a while (for me it varied from
5 - 15 minutes) so go and grab a beverage.

When finished the card will probably be mounted automatically…
/dev/disk2s5   1.6Gi  442Mi  1.1Gi    28%    /Volumes/Untitled
/dev/disk2s1    90Mi   24Mi   66Mi    27%    /Volumes/NO NAME

Eject the freshly installed SD card from your computer.
MacBook-Pro:~ $ diskutil eject /dev/disk2
Disk /dev/disk2 ejected
(For Linux use eject /dev/disk2)

Start your Pi
Put the SD card into your Pi, connect up the network cable and then the power. Within a minute
the Pi should be running so check your router for the IP. The default host name is "alarmpi"

Once found ssh onto it as the alarm user from your computer, the default password is alarm.
(If you do not have ssh installed then check here. PuTTY is a popular choice for windows.)
MacBook-Pro:~ $ ssh -l alarm 192.168.1.65
When logged in change the alarm and root passwords to ones of your choosing.
[alarm@alarmpi ~]$ passwd
Changing password for alarm.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Switch to the root user and change this password also, the default password is root.
[alarm@alarmpi ~]$ su -
Password:
[root@alarmpi ~]# passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

To save time with future logins edit /etc/ssh/sshd_config and uncomment PermitRootLogin then
change it from 'prohibit-password' to 'yes'.
[root@alarmpi ~]# vi /etc/ssh/sshd_config
PermitRootLogin yes
Save the changes. The alternative is to login to your Pi as alarm user and then switch user (su -)
or use sudo to gain root privileges.

Notes
 If you cannot find the Pi on your network remove the power, connect up the HDMI or video and
 a USB keyboard. Replace the power, login and then type "ifconfig". Check on the screen for your
 network interface like "eth0" or "wlan0", next to it will be "inet". This address will be for your Pi.
 For example:-

[root@alarmpi ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.65  netmask 255.255.255.0  broadcast 192.168.1.255

 An excellent guide to Arch Linux : https://wiki.archlinux.org/index.php/Beginners'_Guide

--- Optional ---
Sudo
Many people like to use sudo. We do install the package later to make the wiringPi build easier but if you
want to start using sudo now then install it with "pacman -S sudo" and set up the "camera" user account.
Then edit the sudoers file by typing (as root) visudo and add the following line, then write and quit to save:-
camera   ALL=(ALL) ALL

Notes
 If you are unfamiliar with vi then press "shift+g" together to move to the end of the file, then press the
 letter "o" or "i", you can then insert the text. When done press "Esc", then a ":" followed by "wq" (for
 write and quit) and then press return. If you make a mistake and just want to quit press Esc then type
 a ":" followed by "q!" then press return.

You can then login as the camera user (su - camera) and continue this install. Any command that
requires elevated privileges will have to be run with sudo.
E.G. [camera@alarmpi ~]$ sudo fdisk -l
--- End ---

Resize the filesystem
Check your current disk size:
[root@alarmpi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  444M  1.2G  28% /
devtmpfs         83M     0   83M   0% /dev
tmpfs           231M     0  231M   0% /dev/shm
tmpfs           231M  236K  231M   1% /run
tmpfs           231M     0  231M   0% /sys/fs/cgroup
tmpfs           231M     0  231M   0% /tmp
/dev/mmcblk0p1   90M   25M   66M  27% /boot

If the size on the /dev/root line is much smaller than your SD card then we should resize the filesystem
to use all of the cards space. I have a 32Gb card but the current filesystem is only about 2Gb in size.
(If the size roughly matches your SD card size then great, you can skip to Naming, time & CPU).

[+] Resizing the filesystem details
[-] Close resizing the filesystem
[root@alarmpi ~]# fdisk -l

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00057540

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      186367       92160    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          186368     3667967     1740800    5  Extended
/dev/mmcblk0p5          188416     3667967     1739776   83  Linux

So, we can see the device name of my card and the current partition table. We are going to delete the
Extended and Linux partitions and recreate them using all of our cards space. The most important thing
is that the Start sectors of the Extended and Linux partitions must be recreated with the same number.
The default choices are usually correct so you can just press return but if you make a mistake type
q (quit) or use Ctrl-C and start again.

[root@alarmpi ~]# fdisk -c -u /dev/mmcblk0
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p        <--- print current partition table

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00057540

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      186367       92160    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          186368     3667967     1740800    5  Extended
/dev/mmcblk0p5          188416     3667967     1739776   83  Linux

Command (m for help): d        <--- delete partition
Partition number (1,2,5, default 5): 2
Partition 2 is deleted

(As partition 5 is part of the extended partition 2 it is removed automatically)

Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00057540

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      186367       92160    c  W95 FAT32 (LBA)

Command (m for help): n        <--- new partition
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e          <--- create an extended partition
Partition number (2-4, default 2):         <--- use the default of number 2
First sector (186368-62333951, default 186368):         <--- default, the same as original start number
Using default value 186368
Last sector, +sectors or +size{K,M,G} (186368-62333951, default 62333951): 
Using default value 62333951                       ^--- we use default which is now all of our cards space
Partition 2 of type Extended and of size 29.6 GiB is set

Now the extended partition encompasses the whole of the cards free space.
Time to create a logical partition inside this extended partition.

Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00057540

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      186367       92160    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          186368    62333951    31073792    5  Extended

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l          <--- now create a logical partition
Adding logical partition 5
First sector (188416-62333951, default 188416):          <--- default, the same as original start number
Using default value 188416
Last sector, +sectors or +size{K,M,G} (188416-62333951, default 62333951): 
Using default value 62333951                        ^--- default which is all of our extended partition space
Partition 5 of type Linux and of size 29.6 GiB is set

We have created a new logical partition using all of the extended partitions space. Let's look at the
partition table now...

Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00057540

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      186367       92160    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          186368    62333951    31073792    5  Extended
/dev/mmcblk0p5          188416    62333951    31072768   83  Linux

Command (m for help): w         <--- all happy, time to write out the new partition table
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

All done, time to reboot.
[root@alarmpi ~]# sync;reboot

When we login again (ssh -l root ...) a quick check of the current disk space will probably show
that nothing has changed...
[root@alarmpi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  444M  1.2G  28% /
devtmpfs         83M     0   83M   0% /dev
tmpfs           231M     0  231M   0% /dev/shm
tmpfs           231M  236K  231M   1% /run
tmpfs           231M     0  231M   0% /sys/fs/cgroup
tmpfs           231M     0  231M   0% /tmp
/dev/mmcblk0p1   90M   25M   66M  27% /boot

We need to resize the Linux (logical) partition we created with fdisk.
[root@alarmpi ~]# resize2fs /dev/mmcblk0p5 
resize2fs 1.42.8 (20-Jun-2013)
Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p5 is now 7768192 blocks long.

If we check now it should be looking much better...
[root@alarmpi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        30G  446M   28G   2% /
devtmpfs         83M     0   83M   0% /dev
tmpfs           231M     0  231M   0% /dev/shm
tmpfs           231M  236K  231M   1% /run
tmpfs           231M     0  231M   0% /sys/fs/cgroup
tmpfs           231M     0  231M   0% /tmp
/dev/mmcblk0p1   90M   25M   66M  27% /boot

Naming, time & CPU
Good stuff! Time to choose a name for your Pi. I am going to call mine "carpi2".
[root@alarmpi ~]# hostnamectl set-hostname carpi2
Edit the hosts file and remove the "alarmpi" from the end of the line (if it is there) and add your new
host name that you just set with hostnamectl.
[root@alarmpi ~]# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost carpi2
Write and quit to save the changes.

Changing the timezone. You can see them all here...
[root@alarmpi ~]# ls -la /usr/share/zoneinfo
Make a note of the directory path for yours and then create a file link to point to it. First we need to
delete the old timezone link file.
[root@alarmpi ~]# rm /etc/localtime        <----- this file may not exist
Create the link file for your timezone...(the format is file source then link name)
[root@alarmpi ~]# ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime
If I was in the United Kingdom I would use...
[root@alarmpi ~]# ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

Another way to set the timezone is using the timedatectl command, more information at
https://wiki.archlinux.org/index.php/Time#Time_zone.

Uncomment the Medium setting in the boot configuration file so the CPU speed will be on-demand
up to 900Mhz.
[root@alarmpi ~]# vi /boot/config.txt 
##Medium
arm_freq=900
core_freq=333        <----- 250 is also an option
sdram_freq=450
over_voltage=2

Now is a good time for a another reboot.
[root@alarmpi ~]# reboot
After the reboot the host name, date and time (if connected to a network) should be correct.

Synchronise the package database and update
[root@carpi2 ~]# pacman -sSy
.
.
.
.
(lots of packages listed)

[root@carpi2 ~]# pacman -Su
Most likely it will have some updates so just hit return. It's going to take awhile so celebrate your
progress with another beverage.

The front Pi camera - raspivid
When done, let's check if the Pi camera is working (if you have not connected the Pi camera already
shut down the Pi and connect it now).
[root@carpi2 ~]# shutdown -P now
Then remove the power, connect the camera, reconnect power and log back in.
[root@carpi2 ~]# /opt/vc/bin/raspivid -d -t 1000
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not enabled in this build. Try running "sudo raspi-config" and ensure
that "camera" has been enabled

If you see the above or similar and you are sure the camera is connected correctly then add the
following lines to the bottom of the boot configuration file.
[root@carpi2 ~]# vi /boot/config.txt
start_file=start_x.elf
fixup_file=fixup_x.dat
#current_limit_override=0x5A000020
#disable_camera_led=1

 If you do not wish to see the Pi cameras LED when it is active then remove the # from
 #disable_camera_led=1

Time for another quick reboot….
[root@carpi2 ~]# sync;reboot

After the reboot login and test the Pi video command again, it should return after about two
seconds with no message.
[root@carpi2 ~]# /opt/vc/bin/raspivid -d -t 1000

Notes
 When everything was connected I had some problems with my network connection and some other
 odd behaviour. It appears the power demand was too much for my Pi. If you have similar strange
 issues try removing the # from #current_limit_override=0x5A000020 (and reboot).

The front Pi camera - picam
If you would like to use picamera for recording (which has a nice text overlay facility) we need to
install Python3 and picamera.
[root@carpi2 ~]# pacman -S python3 python-pip
[root@carpi2 ~]# pip install picamera
The picamera site has some great examples on programs you can write to use its different

The rear USB camera
Create the "camera" user account, set the password, login and make the directories.
[root@carpi2 ~]# useradd -m -G video camera
[root@carpi2 ~]# passwd camera
[root@carpi2 ~]# su - camera
[camera@carpi2 ~]$ mkdir -p front rear sound usb logs/tmp
Change the file permissions so the camera directories are available to all (only needed for SAMBA).
[camera@carpi2 ~]$ chmod -R 777 /home/camera
[camera@carpi2 ~]$ exit

Install the motion package so we can record the USB camera.
[root@carpi2 ~]# pacman -S motion wget
You will probably see around 65+ packages to be installed, press return to continue.

When finished make a backup copy of the original configuration file for reference.
[root@carpi2 ~]# cp /etc/motion/motion.conf /etc/motion/motion.conf.org

Edit the motion configuration file. The values in bold should be set as shown here, the others are
recommended options. You will have to test for the best width, height and framerate for your camera.
[root@carpi2 ~]# vi /etc/motion/motion.conf
width 512            <— change to suit your camera
height 288           <— change to suit your camera
framerate 12        <— change to suit your camera
max_movie_time 600    (previously called 'max_mpeg_time')
emulate_motion on      (previously called 'output_all')
output_pictures off      (previously called 'output_normal')
target_dir /home/camera/rear
movie_filename %Y%m%d%H%M-%v
stream_port 8080           (previously 'webcam_port') (required for the GPS text annotation)
webcontrol_port 9080    (previously 'control_port') (required for the GPS text annotation)
camera /usr/local/etc/thread1.conf (only needed if you are going to use the included scripts)

Write your changes and quit the file editing.

Make the directory which has the PID of motion when it's running and change the ownership.
[root@carpi2 ~]# mkdir /etc/motion/run;chown camera /etc/motion/run

--- Optional ---
GPS
If you are setting up the Adafruit GPS, installing the software or just want some general information
please check here.
--- End ---

Audio recording
Install the Advanced Linux Sound Architecture utilities:
[root@carpi2 ~]# pacman -S alsa-utils

If you want to try a quick test, plug in a USB webcam with microphone (or a USB microphone dongle)
into the Pi and then some headphones into the Pi's audio output and run...
[root@carpi2 ~] arecord -D plughw:1,0 -f /tmp/test | aplay -f /tmp/test
Use Ctrl-C to stop.

The "-D" is the device name of the microphone and the "-f" is the file name where the recording
is saved. I have not really been able to test the audio part that much but I will add more info. if
I get the chance.

--- Optional ---
GPIO
If you are going to use the included scripts or plan to add buttons, LEDs etc then you should continue
with this section:
Install the excellent wiringPi stuff, we'll use this for GPIO control.
[ Further information: http://wiringpi.com/download-and-install ]
[root@carpi2 ~]# cd
[root@carpi2 ~]# pacman -S git-core make gcc sudo        <---- you can take away sudo if already installed
[root@carpi2 ~]# git clone git://git.drogon.net/wiringPi
[root@carpi2 ~]# cd wiringPi
[root@carpi2 wiringPi]# ./build
--- End ---

Installing SAMBA (so we can access the video and logfiles remotely)
This is another optional step, it's very handy though as it saves having to take the SD card out of the Pi.
[+] Show details

[-] Hide details
[root@carpi2 ~]# cd;pacman -S samba
[root@carpi2 ~]# cp /etc/samba/smb.conf.default /etc/samba/smb.conf
[root@carpi2 ~]# vi /etc/samba/smb.conf

[global]
# workgroup = NT-Domain-Name or Workgroup-Name
   workgroup = FLUFFY   <---- change to your own workgroup name

# server string is the equivalent of the NT Description field
;   server string = Samba Server
   server string = {your hostname}

# if you want to automatically load your printer list rather
# than setting them up individually then you'll need this
   printcap name = /dev/null
   load printers = no
   disable spoolss = yes

# It should not be necessary to spell out the print system type unless
# yours is non-standard. Currently supported print systems include:
# bsd, sysv, plp, lprng, aix, hpux, qnx
   printing = bsd

# Unix users can map to different SMB User names
;  username map = /etc/samba/smbusers
map to guest = bad user

#============================ Share Definitions ==============================
;[homes]
;   comment = Home Directories
;   browseable = no
;   writable = yes

# NOTE: If you have a BSD-style print system there is no need to
# specifically define each individual printer
;[printers]
;   comment = All Printers
;   path = /var/spool/samba
;   browseable = no

# Set public = yes to allow user 'guest account' to print
;   guest ok = no
;   writable = no
;   printable = yes

( Add this to the end of the file )
[carpi2]
comment = CarPi2 Data
path = /home/camera
browseable = yes
writeable = yes
guest ok = yes

Now to start up SAMBA.
[root@carpi2 ~]# systemctl start nmbd smbd
The camera directories should now be available on other computers. You will have to start SAMBA
manually if you reboot the Pi. Later we can install a small script to do this for us as needed. If you want
it to always start automatically then enable it...
[root@carpi2 ~]# systemctl enable nmbd smbd
If your SAMBA share does not show up then try giving the Pi a quick reboot and starting it again (if
not enabled).

Recording video - Pi camera
Hopefully you've made it this far without any issues and now have two working cameras. You can test
the Pi camera recording with a command like this:-
[root@carpi2 ~]# /opt/vc/bin/raspivid -w 960 -h 540 -n -hf -vf -o /home/camera/front/test.h264 -t 1000000
This will record the Pi camera at the specified width and height, with no preview (no HDMI video),
flips the horizontal and vertical image and it outputs the video to a file called
/home/camera/front/test.h264. The video will record for 1000000ms (about 16 minutes). If you wish to
stop it then just press Ctrl + C

If you are using SAMBA, great! Navigate to the "front" directory and you can view the video
otherwise (if not using a USB memory stick) you will need to shutdown your Pi and put the SD card
into another computer (the video files will be located under /home/camera/front).

Important note!
 The Arch Linux filesystem is ext4. Unless you put the SD card in a machine that can recognise
 an extended filesystem then it probably will not be able to mount this partition. Previously I ran
 MacFUSE for the Mac but switched to FUSE for OS X as it has ongoing support. The module
 I used with both of these was fuse-ext2. Alternatively you can use a FAT formatted USB memory
 stick to view the data or use SAMBA.

Note
 Running "/opt/vc/bin/raspivid -?" or just "/opt/vc/bin/raspivid" will give a list of all the options.

You can easily write your own program to start recording when the unit is powered on but you also
need a way to stop it. If you simply remove power from the Pi then chances are the last recording will
not have finished writing to disk and the file will be empty. I installed a button so the unit could be
shutdown gracefully.

Recording video - Motion
Connect your USB camera. A link called /dev/video0 should be automatically created for this camera.
If you type on the command line lsusb you should also see some information for your camera.
Although most cameras are recognised automatically some older ones may have problems.
If you can see the camera using lsusb and the /dev/video0 file is created you should be fine.

Motion is located in /usr/bin which should already be in your PATH.
[root@carpi2 ~]# motion
[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] Motion going to daemon mode

Motion has started running in the background correctly. Wait a minute or two then stop the motion
process.
[root@carpi2 ~]# pkill -9 motion
Under the /home/camera/rear directory you should have an .avi file with the current date and time.
For example, 201309212228-01.avi
[root@carpi2 ~]# ls -l /home/camera/rear
-rw-r--r-- 1 root   root   4770814 Sep 21 22:29 201309212228-01.avi

With SAMBA navigate to the "rear" directory and view the video otherwise you will need to shutdown
your Pi and put the SD card into another computer. The videos will be located under /home/camera/rear
unless you have specified an alternate location, for example in the global.rc file.

Watch the video for the frames per second. If it constantly matches the frame rate you set in the
configuration file you may like to try increasing this or the video resolution. Once frames start to be
missed then you know you've gone to high and need to reduce things a little. You can make changes
to the configuration file and have it update the motion process whilst it is still running if you wish
like this:-
[root@carpi2 ~]# pkill -HUP motion

Note
 Motion can be controlled by systemd to automatically start and stop with the Pi :-
 [root@carpi2 ~]# systemctl enable motion
 Motion will now start and stop automatically when the Pi is switched on or shutdown.

Scripts  [ Last update August 2017 * ]
I have written several scripts for running the cameras and monitoring things. The idea is to use them
combined with the LEDs, GPS and a power-off / reboot button. If you are making this into a dashcam
(or other video recording device) I would recommend at least installing a button so you can shut down
the unit when it is not connected to a network.

Get the scripts like so... (as the root user on your Pi)
[root@carpi2 ~]# tar -xf scripts.tar;chown -R 0:0 scripts;rm scripts.tar

A directory called "scripts" in /root should now contain all the required files. The global.rc file contains
many values used by these scripts which you can change to best suit your needs.
N.B. An additional global.rc can be added to the top level directory of a USB storage device (the values
in this global.rc take precedence).

audio.sh                        - Uses arecord to save audio recordings to the audio directory
dashcam.sh                  - The main startup script. Mounts USB device, rotates logs, disk cleanup etc.
flash                              - C program to flash LEDs as required (GPIO #, count, delay, finish on/off)
global.rc                        - Resource file for all the global variables
gps_logger                    - C program to manage the GPS (via gpsd)

home.sh                        - Program to transfer files from the Pi to another computer before shutdown
motion_camera.sh        - Runs motion to record video when a USB camera is connected
picam.py                       - Pi camera recording using the picamera package
pico.sh                          - A script to make use of the optional UPS PIco module
pivid.sh                         - Pi camera recording using the raspivid command
pwr_butt                        - Monitors (GPIO 5 by default) for a button press to shutdown or reboot

N.B. Although it is not essential, having the Pi show the correct time is very useful. Adafruit has a nice guide for
adding an RTC to your Pi. I used it for version 1 but later installed a GPS instead unit.

File transfer & WiFi (home.sh)
For further information on setting up a WiFi connection and the home.sh script please see here

We now need to create a service file so things will start and stop automatically.
root@carpi2 ~]# vi /usr/lib/systemd/system/dashcam.service
[Unit]
Description=Dashcam control program
After=local-fs.target

[Service]
ExecStart=/root/scripts/dashcam.sh
Type=simple

[Install]
WantedBy=multi-user.target
 
Save the file then enable it:
[root@carpi2 ~]# systemctl enable dashcam

You could also control which scripts start by adding them as an argument, for example:
ExecStart=/root/scripts/dashcam.sh pivid motion
but it is preferred to change the *_enabled option in your local global.rc file.

Update systemd...
[root@carpi2 ~]# systemctl daemon-reload

You can test it starts from the command line:-
[root@carpi2 ~]# systemctl start dashcam (stop it with systemctl stop dashcam)

And the final test…!
[root@carpi2 ~]# sync;reboot

The End?
To set up the button and / or LEDs & GPS then please look here.
If you have any questions you can drop me a message, time permitting I will try and help.
Otherwise, thanks for following the guide and I hope everything is working for you.

107 comments:

  1. Thank you for all the details. The system started recording the videos. However please provide a detail explanation on how to get the file on windows system. I set up the SAMBA but was not able to see the share

    ReplyDelete
    Replies
    1. It seemed to show up okay for me after I refreshed the network shares on Windows 7 but
      you could try changing these settings in you smb.conf file…

      vi /etc/samba/smb.conf and modify...

      server string = carpi Samba Server
      wins support = yes

      Maybe also try adding:
      public = yes
      to your camera data share definition.

      save the smb.conf file and restart the services...
      [root@carpi2 ~]# systemctl restart nmbd smbd

      Delete
  2. Normal dashcames provide only the last x min and stop recording if you have an accident.
    Do you have implemented something like that? Do you plan it?

    ReplyDelete
    Replies
    1. Hi Peter,

      It was something I thought about and in theory I do not think it would be so difficult to configure.
      At least, having the Pi save the video up until the point of an accident into a 'safe' directory and
      then starting a new recording. If I get a suitable sensor I would implement it but at present I do
      not plan to do so.

      Delete
  3. Hello!
    Thanks for the great work! I was implementing the whole thing and about to do the scrips, but I run into an issue...
    I tried downloading the scripts, but somehow I can't extract them. Are they still available?

    ReplyDelete
    Replies
    1. Hi There,

      I have just re-uploaded the latest scripts (they expire without activity over two weeks).
      Please refresh your web page to see the new link and let me know if they still do not download.

      Delete
    2. HI,

      I admire the time and dedication you spent on writing up the walk trough. It has confirmed such a project is feasible with a PI.

      Could you reupload the scripts again please?

      Thanks
      Terry

      Delete
    3. Hi Terry,

      Thank you for your comments. This actually started out as a simple how-to for a non-technical friend
      who wanted to build one as a project, it's grown a lot since then.

      The latest scripts are available and I have updated the install webpage:
      http://dropcanvas.com/jthqh/1 / http://dropcanvas.com/jthqh/2

      Let me know if you have any problems.

      Best regards,
      Alan.

      Delete
    4. Hi,
      Could you reupload the scripts once again. I want to use powerbank as powersource and make bikepicamera that way.

      Best regards
      Wojtek

      Delete
  4. If sd card becomes full from storing, is there a way to clear out older video stored for new one?
    Thanks again btw for this.

    ReplyDelete
    Replies
    1. Hi Alvin,

      I have been trying to use a car ignition switch from mausberry circuits which
      supplies and shuts off power automatically. It's a very nice solution but at the
      moment I can't get it to work quite right for me and I am still try to find out why
      it drains my battery. Once I have more information I will post an update.

      The status.sh script has a cleanup section which runs every minute and deletes
      the oldest files first automatically when a threshold is reached on the filesystem.
      The two variables are root_limit and usb_limit and these are both set to 95%.
      When the filesystem reaches this limit the script will try and delete files from
      the front, rear and audio directories (also from a usb).

      From the command line you can delete them one at a time or all in one go, for example;
      rm -i /home/camera/front/*.h264 (asks for confirmation before each deletion)
      rm /home/camera/rear/*.avi (deletes all .avi files immediately)

      Hope this helps,
      Alan.

      Delete
    2. Hi, thanks for the reply.

      Yeah just read the status.sh script and found it just last night, so didn't get time to edit my post. This project has been so much help for me and my group already in our project.

      What we're actually doing is a modified black box for cars but using the OBD-II port. (Using OBD TTL adapter for arduino) while the raspberry pi records the video. I'm still trying to see if I can share the 12V charge usage that drives inside the OBD port of the car, or the other possibility would be an electrical line under the boards which direct to the battery of the car(which is technically harder, since we don't have time or permissions from our honorable car donators(friends)).

      Thank you so much once again.

      Delete
    3. modified and extended with additional sensors*

      Delete
    4. Hi Alvin,

      Sounds like a very interesting project especially using the OBD data. I remember
      reading another blog where they had over-layed this data onto the video after
      the journey. It looked pretty good but it took a long time to create the new video if
      you used the Pi itself to make it.

      For powering my Pi I fed wires from the car battery up inside the window strut with
      an on/off button and then a 12v - 5v regulator at the other end. It's for sure not
      something I would like to try and do on someone else's car.

      Good luck with your project and let me know if I can help further.

      Alan.

      Delete
    5. Hi again Alan,

      So apparently I tried testing my raspberry pi again in continuous recording and apparently in one of my recording sessions, it so happened that it stopped out of time. Then succeeding records all just show 0kb or 1kb. I tried searching the net for answers and I got to do some checking on my own, especially with the -v -o and istill test.
      It showed some mmal errors and 2 of them were particular, 1 was about something about ENOSPC I forgot the specific error, cause I do my testing in a lab in school. The other error was something in the lines of : "Failed to run camera app. Please check for firmware updates."

      Now, The solutions on the web were particularly specific with Debian and Python, but I couldn't find any solutions for arch linux raspberry pi installation. I thought they would be the same, but I couldn't risk since there were additional files that are used Rasbian that aren't part of Arch Linux raspberry pi camera setup. Have you had this problem at your end? Still finding a solution, maybe I'll try updating the firmware as it says, and I'm thinking of buying another camera in case this one was over heated by some spark I didn't notice.

      Anyway, our project is coming smoothly, though it will take time to fully enclose it and the power source we got from the car is not just from the OBD(12v - 5v regulated by OBDTTL) but we also got power from the cigarette butt charger for cellphones which worked perfectly 1A 5V with raspberry pi.

      Thanks again, Hoping for your answer on this problem

      Alvin.

      Delete
    6. Hi there Alvin

      Good to hear your project is going well. Regarding the camera problems, definitely install a firmware
      upgrade if one is available. Updating has fixed a lot of strange problems for me in the past. I thought
      the ENOSPC error was something to do with exhausted system resources. What are your config
      settings for the GPU / system memory split in /boot/config.txt? How's the memory usage when
      everything is running? Anything reported in the system messages if you use journalctl?

      Are you using raspivid for the recording? It sounds unlikely that the camera is the issue. Do you have
      the LED enabled so you can see it is running correctly when it has loaded the module?

      I would be really interested seeing some pictures or video of your project in action when it's finished.

      Let me know how you get on.

      Cheers,
      Alan.

      Delete
    7. Thanks for the quick reply,

      Well, I'll take pictures when I have everything mounted on the box(probably a week or two), and I'll probably take a printscreen with journalctl later when I get back to the lab. Yes, the same raspivid scripts are being used, and I had the LED enabled for checking. Which was weird when it did not record anything, even now.

      I'll see if I can update the firmware, I really don't think that it's a physical problem since I take good clean care of the rasp pi and the cable between the board the pi cam(desensitized and all that). Well if it does happen to be the camera, I'll spend atleast another 20$ for the new cam + some protection for it too.

      Will get back to you when another problem rises and/or everything's sorted out.

      Thanks,
      Alvin.

      Delete
    8. Hmm... I have tried every solution on the net, especially about the ones on blacklisting i2c-bcm2708 and also adding to the list in /etc/modules-load.d/raspberrypi.conf about wire1. Still nothing happens.

      I think my only solution is to either image myself another(rasbian or something else) or get my arch linux to downgrade. But I don't see the old arch linux firmwares... I don't suppose I need to compile myself 3.10 or lower because I'm not really that particular with the compiling process or how to install the older firmwares in my rasp pi.

      Well, the other way is to get another rasp cam... We'll see how it goes.

      Thanks,
      Alvin

      Delete
    9. It's hard to diagnose what might be causing the problem without much more detail. But I would try using a spare
      card, install a fresh copy of Arch Linux, add the camera information in /boot/config.txt, update packages and
      test on a Pi that has nothing other than the camera connected. Alternatively try the same using Raspbian.

      If this works then continue adding one component or additional package / package group at a time, testing the
      camera as you go. Also keeping an eye on the logfiles for errors and conflicts.

      If it doesn't work after a fresh 'bare bones' install then I would also start to suspect a problem with the camera
      and / or the Pi.

      Sorry I can't be more help and good luck!

      Alan.

      Delete
    10. Well, I've seen a lot of people online who have the same problem so maybe it really is a major bug/fault in terms of firmware updates and the such. Just thought that if I had this problem early into the project, It will help other people who will come to find this blogspot and be able to solve it early.

      Anyways, thank you so much, I'll try getting a new SD and try everything again, I still have atleast a week's worth before the deadline.

      Alvin.

      Delete
    11. Sorry to bother again, I've been wondering if I recreate a motion.sh for a second webcam would that work? Or will there be difficulties in memory allotment?

      Alvin.

      Delete
    12. Hi Alvin,

      If you are using 'motion' you can add in more cameras. For example, at the end of the motion.conf file you can
      uncomment the threadX.conf variables. Create a file for every camera and have it contain the information for
      one of your cameras. The variable format is the same as the ones use in motion.conf. When you start up motion
      it should have one thread for each camera.

      If you have a second instance of 'motion.sh' it will use more resources and possibly be less efficient. If you are
      worried about memory you could create a larger swap partition or add a swap file using mkswap. You might
      see a performance hit if it's used heavily though.

      HTH,
      Alan

      Delete
    13. Thanks again sir, so there are 2 ways to add the camera, one being with just one motion.sh, while the other is having 2 sh's but uses more resources. I'll try both methods, I'll see how it goes.
      I'm already done with my arduino code for the OBD data, just waiting for my parts to fit in nicely in the box.

      Thanks again friend, We'll be posting results soon. Thanks

      Alvin.

      Delete
    14. Hi, back again

      We just passed our mock defense, and preparing for Technical defense. I now just encountered a problem with the usb cameras and power,
      Back when my RPI camera was still working, I had power drawn from the OBD port, and the problem is, the RPI camera was recording but the usb camera didn't.
      Now, I switched power sources to the cigarette/adapter (with 2 usb slots 2.1A and 1A respectively) and still the usb cameras wont record, but when I connect it using only a usb adapter into a plug (1A), it records perfectly.

      Is it because of my cameras? What usb camera are you using and where are you drawing power for the raspberry pi?

      Delete
    15. nvm, saw it in your latter posts, though Is there a difference in using the 12V-5V 3.1 output that are commonly sold just about anywhere?

      I'll try to find something alternative here, and maybe learn a bit or two if my usb cameras are just hogging current or something.

      Where's that DC/DC converter connected? directly tapped? or the same cigarette/butt thing that I use?

      Delete
    16. I did once try powering two Pi's via the USB cigarette adapter (2.1A 2 x USB slots) but very soon after
      both were running one would power-off or reboot. The cigarette adapter just wasn't powerful enough
      which sounds like your situation.

      My Pi receives all it's power from the 12v - 5v converter which is directly connected to the cars fuse box.
      I think they are all much the same but I made sure it was described as a regulated converter to be safe.
      The Pi itself powers the Pi camera, GPS, USB camera, 3 x LEDs and sometimes a USB memory stick.
      My USB camera is an old Microsoft HD-3000 which is low res. but I do not think it draws much power.

      Not sure if you have tried or if it will help but I have:-
      current_limit_override=0x5A000020
      in my config.txt file which resolved some low power problems when everything was connected up
      including a wired network connection.

      Not something I would recommend but quite a few people have also bypassed the polyfuses to increase
      USB power:
      http://theiopage.blogspot.nl/2012/06/increasing-raspberry-pis-usb-host.html
      http://hackaday.com/2012/09/10/getting-around-the-raspis-usb-host-current-limit/
      https://www.john.geek.nz/2012/09/raspberry-pi-increasing-the-usb-power-limitations-part-2/

      If you know how much power all your stuff requires you should be able to decide if the Pi using a proper
      converter/regulator can cope or if you have to use an alternative solution like a USB hub.

      Delete
    17. I have tried a USB hub before, and It didn't power needed for the usb. I found the same product here in an e-bay like website in our country. I'll get in touch with the seller in a bit.

      I have tried uncommenting the over-ride statement before, I thought it would do something about the error in the RPI camera, never thought it was something for the power overall.

      I'll take a look with other people's roundabouts but I think if I get the same regulator as used, I might go ahead and use first.

      Delete
    18. Just got our 12V to 5V adapter, it read something like 12 Watts.
      How did you connect yours? I've read in dashcomtalk that they used Fuse Taps...
      Haven't seen a fuse tap in action, but I wanna know how did you connect your DC/DC adapter in your car.

      Delete
    19. And how much current (in Amps) is the fuse needed to coincide with it?

      Delete
    20. 12 Watts should be okay as long as it's around 3 amps.
      I used a piggy-back blade fuse holder so I could connect two fuses in one car fuse slot. The first fuse on this
      piggy-back blade makes the connection to the cigarette lighter like normal, this is 20 Amps. The second fuse
      on the blade is 5 Amps. and is connected directly to an on / off switch which then connects to my converter.
      Fuse taps could also work but then you are tied to that fuses rating.

      If you see the picture on my "The built-in version" page the red wire on the converter is the one connected to
      the 5A blade fuse on my car fuse box. The yellow and black wires go straight to a micro USB connecter and
      into the Pi. The label on it shows the voltage and rating for each wire colour.

      I should probably use a 3 or 4 amp fuse instead of the 5 but I did not have any spare at the time :-/

      Delete
    21. Thanks as always,

      I'm just really confused with the terms: Fuse Bypass, Fuse blade, Fuses, Fuse Panel and Fuse Tap. We're crossing dangerous waters by attempting this on someone else's car so I'm really cautious.

      Well, We'll see, I hope my friend bought the right bypass or whatever. Thanks again, We'll report back when everything's A-OK

      Delete
    22. btw, there's no pic on the built-in version page showing where the red wire is connected, Also, our converter version(also CPT) has the Red/Black wire then on the other end are 2 usb females.

      Will that change anything?

      Delete
  5. Hi Alan,

    is it possible to speed up the Motion video capturing by buying the mpeg2 video license?

    At the moment while recording the Pis cpu is at 90% CPU load.

    Cheers

    Julian

    ReplyDelete
    Replies
    1. Hi Julian,

      In short I do not really know but I thought the Pi's MPEG-2 and VC-1 licenses were
      only for decoding. I haven't tried different encoding options in motion (or by using
      alternative software programs) to record the video. This may give better
      performance but I think it would only be minimal due to the limitation of the Pi.

      90% is pretty high usage though, is that all from motion? If you are getting smooth
      video then I would be okay with it. If it's a little choppy then try lowering your
      resolution / frame rate settings in motion. My CPU usage for motion is around
      50-60% but the USB camera is set to quite a low resolution and frame rate.

      One option I have thought about trying would be using a USB camera that
      has built in video encoding. They are usually a little more expensive but would take
      the processing strain off of the Pi and you should be able to stream much higher quality
      video to the Pi directly.

      Cheers,
      Alan.

      Delete
    2. Hi Alan,

      Thanks for the fast answer. My resolution is 800x400 and around 7 fps. i´ve played also with other settings but there was no improvement. The next lower resolution motion is working with my camera is 320x240 which is to crappy to use... Other resolutions like 640x480 dont work with motion. Do you have a hint how to find out suitable which are working?

      i´ve also tried recording with ffmpg and also overclocking to 1000MHz. Still no better result...

      I´d like to have a small camera in my car so i decided to use the Lifecam HD-6000 instead of the HD3000. Now it seems that the hd6000 has higher demands on cpu.

      What i found out is, that motion does the recording in mpeg format. Is there a way / do you know a programm which does the recording in (hardware supported encoding) h264?


      All cameras i found with encoder are very huge/expensive so this is not a real option for me.

      Cheers,
      Julian

      Delete
    3. i found it its very tricky :D From http://www.raspberrypi.org/forums/viewtopic.php?f=83&t=63738

      "When using the Raspi camera, the whole image pipeline, from camera all the way to encoder is on the GPU - it never goes in to Arm space. The GPU is designed to handle full resolution raw images at that speed so it is very very fast - 1080p30 uncompressed YUV420.

      But if you are using a webcam, the image data is captured by a webcam attached to the ARM. That means it has to be captured, is transferred in to the ARM memory using the USB connection which is a big load on the ARM. Then it needs to be transferred to the GPU for encoding, again a big load on the ARM. Then it needs to be transferred back to the ARM as encoded data. Another big load on the Arm.

      So doing this with a webcam is going to put a lot of demand on the ARM, whist the GPU does a little bit of encoding.

      You're seeing 10% CPU at 320x240p10. Just going to p30 would be 30%, then doubling resolution to 640x480 would be 60%, then double again to 1280x960 would be 120%. So as you can see its unlikely you will be able to get 1080p30.

      If you must use a webcam you will need one that does the encoding for you."

      So only solution is camera with encoder included like you said :/

      Delete
  6. Using pivid.sh under Raspbian 3.12.26+ #704, I got "unknown operator" errors at statements 36, 65 and 151 when running from a command line as ./pivid.sh. Apparent cause was not double quoting first operand and use of == instead of = in the test comparison. i.e. if [ $pivid_enabled == "yes" ]; might need to be if [ "$pivid_enabled" = "yes"];

    Hope this helps your project and thanks for your work.

    ReplyDelete
    Replies
    1. Hi Matt,

      Thank you for spotting this and you are right with the expression formatting. I found some of
      these mistakes in the motion script too. I've corrected them all now and I have uploaded
      a newer version.

      It has also got me thinking I should try and make it more Raspbian friendly with the
      systemctl / service commands for example.

      Thanks again.

      Delete
  7. I really like your project. Do you have any suggestions to guide me to completing my project? I would like to know if there is a way to view the raspberry pi camera live? I would like to set a pi with camera near my pond and view what's happening live.

    ReplyDelete
    Replies
    1. Thanks Jim, a few ideas, you can plug a HDMI into the Pi and view the Pi camera in real-time. Alternatively if you are using a camera via motion you can edit the motion.conf file and give the 'webcam_port' variable a value. You'll then be able to view your camera via a browser etc. I think what would be best though is to use the RPi Cam Web Interface program. It has a handy web interface where you can view the Pi camera live, stop/start recording, enable motion detection, download videos etc.

      See: http://elinux.org/RPi-Cam-Web-Interface or http://www.raspberrypi.org/forums/viewtopic.php?t=63276 (original thread)

      I disabled the h264 to mp4 conversion on mine so recording events are not interupted (MP4Box false). It works really well and I think it is just what you are after. HTH.

      Delete
  8. Any chance of you posting or sending the original c code you used?

    ReplyDelete
    Replies
    1. Hi Paul, most of the C code I wrote for this started out as a small test just to get it working and then it mutated into a large (un-commented) sprawling mess. Hence why I do not include it with the download stuff. At the moment I am trying to update things into being more task specific. Drop me a mail at hmm.tricky@gmail.com and let me know what your after and I'll send what I can.

      Delete
  9. I don't get how you merge both video feeds like on the youtube videos. was that done in post ?

    ReplyDelete
    Replies
    1. Hi There, the front and rear camera videos were merged in post using iMovie. The Pi is not powerful enough to do this in realtime.

      Delete
  10. ./gps_logger: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory

    Need to follow directions at http://wiringpi.com/download-and-install

    ReplyDelete
    Replies
    1. Although it could be clearer it does mention in the install guide that if you are using the scripts you need to install the wiringPi libraries and also includes the installation instructions & the link.

      Delete
    2. It sure does! I missed it in all the good, detailed information.

      Delete
  11. I have installed SAMBA, it shows up under windows under network.
    But when i open it windows asks for a username and pasword.

    tried eveything, but can not acces the samba share.

    ReplyDelete
    Replies
    1. Solved:
      "map to quest" had to be "map to guest"

      Delete
    2. Good work, glad you've got it working.

      Delete
  12. Everything is working now. I have mounted the button and leds, and a usb webcam.
    maybe i do mount a GPS, i am thinking about that.

    i have changed the motion filenames of the video, it was quite simple. But i can not find where i can change the filenames of the video's from the front camera.

    I have to think about a solution to save shutdown the pi. The UPS is a good option, but i find it to expensive. there must be another way.

    ReplyDelete
    Replies
    1. Glad you have it sorted and I hope you are happy with the results.

      Regarding changing the video filenames, I really wanted to add it as a user defined option but sadly have not had the time to work on that. If you are using the picam program the easiest thing would be to change the 'video_file' variable at line 474.

      video_file = main_directory + "/front/" + "{0:02d}-{1:02d}_".format(event_count, sequence_count) + dt.datetime.now().strftime('%Y%m%d%H%M.h264')

      If you are using pivid it's a little trickier and probably best to modify the raspivid '-o' option at line 224.

      /opt/vc/bin/raspivid $res_size -o $main_dir/front/$file_count-""$seq_count""_$date_time.h264 -t $pivid_time $options > /dev/null 2>&1

      I was going to attempt making a simple UPS solution but when I saw the PIco UPS I decided to take the easy option. It's not without its quirks but so far it has worked fairly well. I did see a few pages with UPS's or similar that people have made but sadly do not have the links.

      All the best.

      Delete
  13. Thanks That's tricky, i shall try the suggestions you gave.

    I was thinking, i have a car with "come home lightning". when i turn of the engine, the lightning stays on for 20 seconds. Maybe i can use this to power of the PI.
    Then i must power the pi from this lightning, and when the contact is switched off then the pi must get a signal to shutdown, this can be the pusbutton.

    ReplyDelete
    Replies
    1. Making use of the cars home light function sounds like a good solution. 20 seconds is enough time for the Pi to shutdown. Not sure how you could implement it to initiate a shutdown automatically but using a push button would make it nice and simple.

      Delete
  14. maybe the shutdown can come from the car radio when the 12v is shut off by the ignitionswitch.
    I have to look if there is a gpio pin that can detect when there is 12v or not.

    In the meantime i have found an other solution that can work.
    http://www.ebay.nl/itm/12V-Digital-Programmable-Timer-Relay-Control-Module-IR-Remote-Controler-/131346807602?

    a programmable timer with a trigger function.

    ReplyDelete
  15. Found another one:
    http://www.banggood.com/12V-DC-Multifunction-Self-lock-Relay-PLC-Cycle-Timer-Module-Delay-Time-Switch-p-1028337.html

    Looks like the trigger can be the 12v from the car radio

    ReplyDelete
  16. Hello That's Tricky

    Is it possible that i can change the pwr_butt script to add some code for shutdown the pi when a GPIO get a high or a low?
    I have ordered the programmable timer, and it seems to work great.
    The only thing i have to do now is mannage the software so it does a shutdown when there is no 12volt.

    I think it should be the best when there is another GPIO thats shutdown the pi also beside the shutdown button.

    but i can not access the pwr_butt scipt, it looks like it is compiled

    ReplyDelete
  17. Hello Allen,

    I have a problem with the dashcam.
    It doesn't record to the usb-stick anymore.

    I have build everything in to the car and looks like everything is working well.

    But when i want to look at the pictures there was nothing.

    The only thing i have changes is the raspberry pi himself.
    The camera connector was broken on my pi, so i have changed the pi for another one, exact the same.
    I changed the sd card so it must be working again, i think.
    When i put in a fres usb stick, all maps are created on the usb stick, but no data.
    So the stich is mounted.
    Do you know what the proble could be?

    ReplyDelete
    Replies
    1. Hi,

      Double check your global.rc settings under /root/scripts or the global.rc in the top directory of your USB stick (default is /home/camera/usb). Make sure the usb_* variables are correct and depending which Pi camera program you use make sure that either 'picam_use_usb' or 'pivid_use_usb' is set to 'yes'.

      Also check the status.txt file in your 'log_directory'. It should confirm where it is recording too.
      From the command line run:-
      egrep "picam|pivid|recording" status.txt
      The first [dashcam] lines tell you where the USB is mounted, which services are enabled and what camera program is starting followed by the video file location when recording starts.

      Hope this helps and let me know what you find. Best regards,
      Alan.

      Delete
  18. global.rc is good. usb settings are correct

    Sometimes the disk is mounted and sometimes not.
    it looks like when i disconnect the network cable, then there is no recording.
    And in the car there is no network cable.

    On my desk i have attached a network cable.
    but strange things are going on.

    I think i have to make everything from scratch again. and that is a lot of work

    ReplyDelete
  19. Do you have a SD image of the working setup, so I can copy it to a SD card. I am having issues getting it to work on debian/Rpi-2. Appreciate you excellent work.

    ReplyDelete
    Replies
    1. I have created an Arch Linux image you can try. Please check under the Arch Linux install guide.

      Delete
    2. Thank you for the image file. The project you've worked on is amazing. I was able to get the image working on a Pi3, I am using a USB GPS (Bus 001 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port)
      [root@carpi logs]# dmesg|grep ttyU
      [ 6.444252] usb 1-1.2: pl2303 converter now attached to ttyUSB0

      but the gps is unable to get a fix.
      [root@carpi logs]# tail -f status.txt
      23:47:22 [dashcam]: motion:yes - GPS:yes - Pi camera:picam - power:yes - audio:no - pico:no
      23:47:22 [dashcam]: Starting gps_logger
      23:47:22 [dashcam]: Starting pwr_butt
      23:47:22 [dashcam]: Starting picam
      23:47:22 [gps_logger]: Started (v2-2.27)
      23:47:23 [gps_logger]: Waiting for GPS fix...
      23:47:26 [dashcam]: Starting motion_camera
      23:47:26 [dashcam]: Disk space threshold is set to 95% for /home/camera and 95% for /home/camera/usb
      23:47:34 [dashcam]: up 0 min, 0 users, load average: 0.33, 0.08, 0.03, 600Mhz, 61.2'C (60148)
      23:47:34 [dashcam]: Capacity of /home/camera is 24%, /home/camera/usb is 3%
      23:48:50 [dashcam]: up 1 min, 1 user, load average: 0.22, 0.09, 0.03, 600Mhz, 58.0'C (57996)
      23:48:50 [dashcam]: Capacity of /home/camera is 24%, /home/camera/usb is 3%
      23:49:50 [dashcam]: up 2 min, 1 user, load average: 0.08, 0.07, 0.03, 600Mhz, 56.9'C (56382)
      23:49:50 [dashcam]: Capacity of /home/camera is 24%, /home/camera/usb is 3%
      23:50:44 [motion_camera]: Timed out waiting for GPS
      23:50:45 [picam]: Timed out waiting for GPS
      23:50:50 [dashcam]: up 3 min, 1 user, load average: 0.03, 0.06, 0.02, 600Mhz, 55.3'C (55843)

      if I run gpsmon /dev/ttyUSB0 it works.
      The front video has the gps overlay but no data(log/lat/speed/sat)

      Any help/suggestion is appreciated.

      Delete
    3. Hi Cyril,

      I'm glad you like the project and good to hear the image works okay.
      Just double checking but did you update the global.rc file with the device path for your GPS? So it looks like this:-
      .
      .
      GPS_device /dev/ttyUSB0 [/dev/ttyAMA0] Name of the GPS device gpsd will use
      .
      .

      The gps_logger program uses gpsd. To check the GPS device is recognised by gpsd first stop the dashcam program and make sure that gpsd has also stopped then start it from the command line with:-

      /usr/sbin/gpsd -F /var/run/gpsd.sock /dev/ttyUSB0

      Then try running just gpsmon or cgps -s (without your GPS's device name). If gpsd is working correctly you should start seeing some data coming in.

      Hope this helps. Let me know how you get on.

      Best regards,
      Alan.

      Delete
    4. Dear Alan,

      Thanks for the quick help. I had made the changes in global.rc like you suggested, however the /etc/gpsd file had devices="", changed it to devices"/dev/ttyUSB0" and every started working fine, thanks a lot. is the /etc/gpsd files supposed to get the device path from global.rc ? or should this be manually set if the GPS is USB based ?

      Thanks for the great effort you've put in.

      Delete
    5. Great!

      The gps_logger program reads the GPS_device variable from global.rc and then starts gpsd using that GPS_device variable name. It should not be necessary to change /etc/gpsd but I haven't used a USB GPS so could not say for sure. I would think the dashcam program would work fine if you made 'devices' empty again in /etc/gpsd and had GPS_device as /dev/ttyUSB0 in global.rc.

      I'd be interested to know either way :)

      Delete
    6. Alan,

      I will try what you mentioned and see what happens. I'll keep you posted.

      Delete
    7. Alan,

      I removed the /etc/gpsd devices="/dev/ttyUSB0" and restarted, but gpsd would not recognize the GPS.
      So for USB GPS we have to manually add the device path in /etc/gpsd.

      Delete
  20. First off - excellent work. This is my first real RaspPi project (Kodi media centers don't count) where I'll need to so some coding so your blog is extremely helpful. I'm using your solution as a template and modifying a few things to fit my needs.

    Did you experiment with recording directly to a usb flash drive? I was thinking that might enable retrieving the files easier while on-the-go. You could unplug the flash drive and view the files on a mobile device with an otg cable. I read the snippet in the Raspbian guide about the global.rc file being in the 'usb_directory root mount point'...could you elaborate on that?

    Also, i noticed the url to get the scripts is different on the Arch Linux guide and Raspbian guide? Is there a difference in the scripts?

    Thanks!

    ReplyDelete
    Replies
    1. Thanks Kyle, i'm glad you are finding the blog useful. The Raspbian guide was a bit of a rush job and does not really contain as much information as the Arch build. But, for my setup I record the front camera video and the log data to a USB flash drive and the rear video onto the Pi's SD card. As you say, it makes it much handier to simply unplug the flash drive to check the video or GPS data etc. Any of the variables in the global.rc file that have '_use_usb' at the end can save data to a USB drive. The USB storage will be mounted where the 'usb_directory' is set to, by default it is /home/camera/usb but could be anywhere. The 'usb_mount' variable needs to be set to yes and that's it. It is possible to have another copy of the global.rc file at the top level of your USB drive with different video settings and so on. This takes priority so effectively you can have a different profile when you have the USB drive plugged in or not.

      The main difference between the Arch and Raspbian scripts is the C programs have different library locations and are compiled on each system. Sadly, I never got the cross-compiling to work properly although I really should put more effort into it :p

      All the best and good luck with your project,

      Alan.

      Delete
  21. Hi,

    Great stuff! I'm using your Arch Linux image, but I'm unable to find the username and password to log in... alarm alarm doesn't work. Thanks

    ReplyDelete
    Replies
    1. Hi Chris,

      Due to a mistake on my part the passwords were, erm, forgotten. I have created a new image which can be downloaded from: https://drive.google.com/open?id=0B3C9fv6-yJclT0t4VV9vd0YyOXM

      The accounts are for root, camera and alarm. The passwords are the same as the user names. Sorry for the inconvenience and let me know how you get on.

      Rgds,
      Alan.

      Delete
  22. Great blog.
    But there is problem with `.img` file(atleast for me). It doesn't boot up the raspberry. I am using OSX. Just heads up for other people.

    ReplyDelete
    Replies
    1. I downloaded the .img file and did not have any issues booting. I used pi filler (utility) on mac OS X to write the image, give this a shot, I did this multiple times and no issues.

      Delete
  23. Late to the party but I've just ordered the additional stuff I need to add to my collection of bits n bobs to attempt to run this project as a permanent fixture to my motorbike.

    ReplyDelete
  24. This is a great blog. I just can't get past the second boot screen.
    I make the partition changes and then sync;reboot. It reboots and I'm left with a screen that says "end Kernal panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,2)".

    If you've got any idea what that means, I'd love to know. I've tried 2 difference SD cards, 2 PI3s, 3 power supplies, and I've flashed the SD card on Windows, Linux and Mac.

    I don't know what to do :(

    Jamie

    ReplyDelete
    Replies
    1. Hi Jamie,

      When you first install the image on the SD card and before any changes does the Pi boot up without problem?

      From what you say it sounds like the partition table is not correct from the resize.
      The start sector numbers must have exactly the same value as they were before the change, it's just the end sector number that changes to incorporate the whole card. Send me (hmm.tricky@gmail.com) your 'fdisk -l' output before a resize and I can double check what I think it should be.

      Delete
  25. Hi Alan,

    is there a way to get the whole gps annotation stuff working too inside your picam.py instead of the pivid.sh?

    The background of this is that with running the recording set to "picam" i´m getting again this message and the pi-camera is getting no connection:

    06:54:44 [dashcam-samba]: Starting nmbd and smbd
    06:54:45 [dashcam]: up 0 min, 0 users, load average: 0.40, 0.10, 0.03, 1200Mhz, 45.1'C (45084)
    06:54:45 [dashcam]: picam not running, restarting
    06:54:45 [dashcam]: Capacity of /home/camera is 10%, /home/camera/usb is 2%
    06:54:56 [pico]: Battery at 100%
    06:56:01 [dashcam]: up 1 min, 0 users, load average: 0.18, 0.09, 0.03, 600Mhz, 44.0'C (44007)
    06:56:01 [dashcam]: picam not running, restarting
    06:56:01 [dashcam]: Capacity of /home/camera is 10%, /home/camera/usb is 2%
    06:56:14 [pico]: CPU: 44 ^zC BC: 44 ^zC SOT-23: 33 ^zC TO-92: 33 ^zC
    06:57:01 [dashcam]: up 2 min, 1 user, load average: 0.15, 0.10, 0.04, 600Mhz, 44.0'C (44007)
    06:57:02 [dashcam]: picam not running, restarting
    06:57:02 [dashcam]: Capacity of /home/camera is 10%, /home/camera/usb is 2%
    06:57:41 [pico]: CPU: 44 ^zC BC: 43 ^zC SOT-23: 33 ^zC TO-92: 33 ^zC

    There seems to be some kind of bug when using the picam recordingmode.
    When switching to "Pivid" in global.rc, the pi-camera is working every reboot without any issue - but unfortunately there is no GPS annotation integrated :-(

    Due to using two Raspberry Pies (each for Front/Rear) with using two pi-cameras for this, i´m very reliant to get the GPS annotation working for the pi-cameras only.
    I have cross-tested the hardware to exclude there is no hardware issue here.
    The powersupply is genuine one with 5.1V @2,5A and in /boot/config.txt is set: gpu_mem=512 and current_limit_override=0x5A000020.


    I really hope you could have a look into this...

    Kind regards,
    EarthberryPi



    ReplyDelete
  26. Hi again,

    i found out that when putting this line into /root/scripts/picam.py the picam is temporary recording again but with no gps data shown:
    gps_text = dt.datetime.now().strftime('%d/%m/%Y %H:%M:%S ')

    But when doing this line it won´t record anymore:
    gps_text = dt.datetime.now().strftime('%d/%m/%Y %H:%M:%S ') + " Speed: {0:3.0f} ".format(float(current_speed)) + GPS_speed + " Climb: {climb} m/s".format(**fix.TPV) + " Hd: {track} deg".format(**fix.TPV) + " Alt: {alt} m".format(**fix.TPV)())

    I have changed the order of the shown gps elements to my needs. Could you plz tell me what the end of the second non working line should look like? I mean this ()) thing. What else could be the problem inside the whole line for suppressing the picam recording ? Or is the problem withing the gps logger itself, which lets the picam recording crash? This is so strange.

    ReplyDelete
    Replies
    1. EarthberryPI,

      I have been using this on a Pi2 for more than a year now and it works like a charm (with GPS Anotation in picam video), I had issues with GPS not working but if you see my posts above I was able to fix it. Do see GPS data output from gpsmon, your problem could be similar to mine, please see my post above from 15 July 2016 at 23:54
      try this
      run gpsmon /dev/ttyUSB0 to see if you get GPS data.

      Delete
  27. Has anyone here tried the image on Pi Zero?

    ReplyDelete
  28. EarthberryPi,

    I had same issue "06:54:45 [dashcam]: picam not running, restarting" and changed my global.rc and dashcam.sh files. Check if your files have these settings that work for me.


    [root@carpi scripts]#

    I have these setting in global.rc, check yours.

    [root@carpi scripts]# egrep "pica|gps" global.rc
    pi_camera_method picam [pivid] / picam / off
    picam
    picam_use_usb yes [yes] / no Write Pi camera video to USB device
    picam_time 300 [900] Recording time in seconds, default is 15 mins
    picam_annotate_size 23 [32] Valid sizes are from 6 - 160
    picam_text_background black [none] Text annotation background colour
    picam_width 1296 [1296] Examples... 960, 1296, 1296 (4:3), 1920
    picam_height 972 [730] Examples... 540, 730, 972 (4:3), 1080
    picam_framerate 24 [24]
    picam_quality 15 [25] Video encoder quality, values 10 - 40 (10 = high, 40 = low)
    motion_GPS_annotate no [yes] / no Add GPS data to video (requires gps_logger)
    gps_logger
    GPS_device /dev/ttyUSB0 [/dev/ttyAMA0] Name of the GPS device gpsd will use
    [root@carpi scripts]#



    Check if you have these line in your dashcam.sh

    root@carpi scripts]# egrep "picam|gps" dashcam.sh
    pi_camera_method="picam"
    picam_enabled="yes"

    ReplyDelete
    Replies
    1. Hi Cyril,

      thank you for replying so fast.

      Gps is already working so i can get correct output data when doing "gpsmon".

      Can you plz go in detail please where to exactly edit pi_camera_method="picam" and
      picam_enabled="yes in dashcam.sh? I thought that if "picam" is selected in global.rc everything else will switch to the right place too???

      Here are the outputs of my current settings so you can read in:

      [root@bikedashfront scripts]# egrep "pica|gps" global.rc
      pi_camera_method picam [pivid] / picam / off
      picam
      picam_use_usb yes [yes] / no Write Pi camera video to USB device
      picam_time 900 [900] Recording time in seconds, default is 15 mins
      picam_annotate_size 32 [32] Valid text sizes are from 6 - 160
      picam_text_background black [none] Text annotation background colour
      picam_width 1920 [1296] Examples... 960, 1296, 1296 (4:3), 1920
      picam_height 1080 [730] Examples... 540, 730, 972 (4:3), 1080
      picam_framerate 24 [24]
      picam_quality 10 [25] Video encoder quality, values 10 - 40 (10 = high, 40 = low)
      picam_split_on no yes / [no] Make a separate copy of the camera feed, for streaming etc.
      picam_split_type image [image] / video / both
      picam_split_width 640 [640]
      picam_split_height 480 [480]
      picam_split_directory /dev/shm [/dev/shm]
      motion_GPS_annotate no [yes] / no Add GPS data to video (requires gps_logger)
      gps_logger
      GPS_device /dev/ttyACM0 [/dev/ttyAMA0] Name of the GPS device gpsd will use


      [root@bikedashfront scripts]# egrep "picam|gps" dashcam.sh
      picam_enabled="no"
      rm -f /tmp/*.pid /tmp/gps_fix.tmp
      elif [ "$pi_camera_method" = "picam" ]; then
      pkill --signal SIGTERM -f picam.py
      pkill --signal SIGTERM gps_logger
      if [ "$tmp_glob" = "picam" ]; then picam_enabled="yes"; fi
      printf "pwr_butt | gps_logger | [ pivid | picam ] | motion | audio | pico\n\n"
      elif [ "$args" = "gps_logger" ]; then GPS_enabled="yes";
      elif [ "$args" = "picam" ]; then pi_camera_method="picam";
      if [ ! -z "`pgrep gps_logger`" ]; then
      printf "`date +%T` [dashcam]: gps_logger is already running\n" >> $status_out
      printf "`date +%T` [dashcam]: Starting gps_logger\n" >> $status_out
      /root/scripts/gps_logger > /dev/null 2>&1 &
      elif [ "$pi_camera_method" = "picam" ]; then
      if [ ! -z "`pgrep -f picam.py`" ]; then
      printf "`date +%T` [dashcam]: picam is already running\n" >> $status_out
      printf "`date +%T` [dashcam]: Starting picam\n" >> $status_out
      ### sleep 4 ; /root/scripts/picam.py > /dev/null 2>&1 &
      sleep 6 ; /root/scripts/picam.py > /dev/null 2>&1 &
      if [ "$GPS_wait" = "no" -o -f /tmp/no_gps_fix.tmp ] || [ "$GPS_wait" = "yes" -a -f /tmp/gps_fix.tmp ]; then
      if [ "$pi_camera_method" = "picam" ] && [ -z `pgrep -f picam.py` ]; then
      printf "`date +%T` [dashcam]: picam not running, restarting\n" >> $status_out
      /root/scripts/picam.py > /dev/null 2>&1 &

      Delete
  29. I have changed where i assumed and now i have this output:

    [root@bikedashfront scripts]# egrep "picam|gps" dashcam.sh
    pi_camera_method="picam"
    #picam_enabled="no"
    picam_enabled="yes"
    rm -f /tmp/*.pid /tmp/gps_fix.tmp
    elif [ "$pi_camera_method" = "picam" ]; then
    pkill --signal SIGTERM -f picam.py
    pkill --signal SIGTERM gps_logger
    if [ "$tmp_glob" = "picam" ]; then picam_enabled="yes"; fi
    printf "pwr_butt | gps_logger | [ pivid | picam ] | motion | audio | pico\n\n"
    elif [ "$args" = "gps_logger" ]; then GPS_enabled="yes";
    elif [ "$args" = "picam" ]; then pi_camera_method="picam";
    if [ ! -z "`pgrep gps_logger`" ]; then
    printf "`date +%T` [dashcam]: gps_logger is already running\n" >> $status_out
    printf "`date +%T` [dashcam]: Starting gps_logger\n" >> $status_out
    /root/scripts/gps_logger > /dev/null 2>&1 &
    elif [ "$pi_camera_method" = "picam" ]; then
    if [ ! -z "`pgrep -f picam.py`" ]; then
    printf "`date +%T` [dashcam]: picam is already running\n" >> $status_out
    printf "`date +%T` [dashcam]: Starting picam\n" >> $status_out
    ### sleep 4 ; /root/scripts/picam.py > /dev/null 2>&1 &
    sleep 6 ; /root/scripts/picam.py > /dev/null 2>&1 &
    if [ "$GPS_wait" = "no" -o -f /tmp/no_gps_fix.tmp ] || [ "$GPS_wait" = "yes" -a -f /tmp/gps_fix.tmp ]; then
    if [ "$pi_camera_method" = "picam" ] && [ -z `pgrep -f picam.py` ]; then
    printf "`date +%T` [dashcam]: picam not running, restarting\n" >> $status_out
    /root/scripts/picam.py > /dev/null 2>&1 &

    ReplyDelete
  30. When doing this line for gps annotation (which is only showing date and time) in /root/scripts/picam.py :
    gps_text = dt.datetime.now().strftime('%d/%m/%Y %H:%M:%S ')

    the picam is recording again every time.

    When changing to this line it´s not recording anymore:
    gps_text = dt.datetime.now().strftime('%d/%m/%Y %H:%M:%S ') + "Lat: {0:2.6f} ".format(float(lat_float)) + "Long: {0:2.6f} ".format(float(lon_float)) + "Sp: {0:3.0f} ".format(float(current_speed)) + GPS_speed + " Sats: {0[1]:2d} / {0[0]:2d}".format(fix.satellites_used())

    So it seems that somthing of the annotation-import from the gps logger is preventing the picam recording somehow.

    ReplyDelete
  31. EarthberryPi, thanks for the details. for some values the dashcam.sh doesnt pick up values from global.rc in mine. can you tell me what is the expected output you want see on the video for the annotation? Please give me the text.
    Let me try the annotation you are trying see what results I get.

    ReplyDelete
  32. Earthberrypi, I comapred what I have in my picam.py and yours, its almost the same. can you try this line, this is what I have and it works. (with the right indentation) notice I have day and month swapped.

    gps_text = "Car_Dashcam " + dt.datetime.now().strftime('%m/%d/%Y %H:%M:%S ') + "Lat: {0:2.6f} ".format(float(lat_float)) + "Long: {0:2.6f} ".format(float(lon_float)) + "Sp: {0:3.0f} ".format(float(curr
    ent_speed)) + GPS_speed + " Sats: {0[1]:2d} / {0[0]:2d}".format(fix.satellites_used())

    ReplyDelete
  33. EarthberryPi, I used your gps_text line in my picam.py and I did not have any issues, I was able to record video with out crashing , I now have ~30 minutes of video recorded in 3 consecutive files.

    ReplyDelete
  34. Hi Cyril, thank you for helping me with this. I´ve tested your gps-line and it is not working here - picam not running, restarting.
    But it is working again (every reboot) when doing again this line: gps_text = dt.datetime.now().strftime('%d/%m/%Y %H:%M:%S ')
    This is quite strange, because of this, it can´t be any hardware issue due to camera etc. I have 4 Raspberry Pies laying arround and tested with each, so Raspberry is not the problem. Also i have two pi-cameras (one genuine one and another SainSmart 5MP Camera Module Wide Angle). No matter what camera i connect its always the same behaviour. I also tried multiple new different flat ribbon cabels for the picam.
    The powersupply is genuine one with 5.1V @2,5A and in /boot/config.txt is set: gpu_mem=512 and current_limit_override=0x5A000020. I have no idea what the problem is. When switching back to "Pivid" in global.rc, the picam is recording too without any problems. But then no GPS overlay is possible and thats not the way i like to go. Could you do ma a favour and upload your image with Win32DiskImager.exe so i can try out your working one? I believe this is the only way to really find out whats going on here. That would be really awsome man if you were able to do this somehow. This "little" finally issue here is preventing me to start building this whole stuff into my motorcycle. I´m really going crazy... ;-)

    ReplyDelete
  35. EarthberryPi, sad it didn't work, lets do this, I'll share the SD image I have that works. Burn it on a 16GB SD card and try it out it should work. I'll upload the file and share the link shortly.

    ReplyDelete
  36. try this link
    https://24.7.46.182:8443/public.php?service=files&t=1081ab906b6605f07e44c8df0b012983
    accept the security warnings, its 7.9gb file. but wont fit on a 8GB SD. I was able to download it. root/root

    ReplyDelete
  37. I have enabled saving to USB flash dive, so the /dev/sda (device name) might change in yours. I have USB drive on left top and GPS on right top USB ports (when ethernet is on you left, with USB ports facing you)

    ReplyDelete
    Replies
    1. Cyril, i was trying to download the file and it seems it was taken down. I would love to be able to test this file. I'm having a little problem getting the rest set up.

      Thanks!

      Delete
  38. I have already downloaded but can configure and test it only this weekend. Thank you so much for uploading this and your time! Can´t wait to get your image running on my hardware :-)
    I´ll give you a feedback as soon as i got it working.

    Kind regards,
    EarthberryPi

    ReplyDelete
  39. Sure EarthberryPi, good luck.

    ReplyDelete
  40. Hi Cyril,

    everything is working now! Thank you very much for your help and your time for uploading your image! Now i´m going to start building all the stuff into my bike and can´t wait to see the results :-)

    Kind regards,
    EarthberryPie

    ReplyDelete
  41. Awesome! glad it worked, I just helped you make it work but all hard work and credit goes to Alan the original developer. do share me your results.

    ReplyDelete
  42. Hi Cyril,
    yes your´re right of course. Without Alan´s great work, my project never has been come so far. So big thank you for creating this! I´m in contact with Alan too an he still helped me a lot. Lets see if i can upload some recorded videos if all the stuff is mounted waterproof inside my bike. Still a lot to do get this done...

    Thanks to all of you for helping with my issues :-)

    Kind regards,
    EarthberryPi

    ReplyDelete
  43. Hi Cyril,

    can you tell me plz which exactly USB GPS device you are running and if you are happy with it? Because my Navilock NL-602U is refreshing the gps data once every 5 minutes in the overlay!!! So it is not usable at the moment. I don´t know if it is an incompatibility with my device in general or simply some wrong settings inside somewhere. In the gps_log the data seems to be refreshed well every two seconds but not in overlay of the recording. I have read that you had some trouble with configuration too...

    Kind regards,
    EarthberryPie

    ReplyDelete
  44. This is probably a rather simple question. I have installed the .img file and on boot, it always request to login. I have checked the file and the permitrootlogin is set to yes. I have not been able to get past this to autoboot to run. Any advise is appreciated.

    ReplyDelete
    Replies
    1. Hi Nathan,

      I am not quite sure what you wish to do. The console will always request a login. If you want to log in from another machine without a password it would be best to copy its ssh key to your Pi (for example see, http://pidashcam.blogspot.nl/2016/01/setting-up-file-transfer-via-wifi.html)

      If you are trying to do something else can you give me a bit more information?

      Thanks,
      Alan,

      Delete
    2. Alan,
      Thanks for the reply. I was hoping that when connected, it would boot straight into the recording rather than having to log in. Maybe I missed a step? It doesn't seem like it would be a good idea when implemented in the car to have to log in on each key on. Again, I think i'm missing a step.

      Delete
  45. Hi, I'm getting lot's of video judder and pixelation. What can cause this?
    Running your setup with only a RPI camera (nightvision wide angle) on a PI 3+ b but when i play back the video it judders as if the unit cant keep up.

    ReplyDelete
  46. @tricky - Thank you very much for all the work you've done here with this project and the extensive documentation that you've made public. Having never used Arch before, your guides have been exceptional. I have taken your updated April 2018 Arch image and have it running on a Pi 3b+ (I have many of those sitting around but no Pi 2b). I expanded the partition and updated Arch, however, it seems that the GPIOs are not seen for some reason, the GPS is not coming through ttyAMA0 and it is ignoring pin 18 for the power button. I have tested the wiring with Raspbian and it works as expected. What may need to be tweaked in your Arch build? Your expertise on this would be greatly appreciated.

    Also, I found a dead link you posted to a recompiled version of your build that is for a Pi 1, I wanted to test that build to see if it works on a Pi Zero. If you still have that build available, I'd like to try it.

    ReplyDelete
  47. This would be a great project with IP cameras.

    Just sayin...
    Right now I have a similar project on my motorcycle useing a NVR software, everything goes to a 1tb SSD that is boot and everything, but I would prefer real black box features like GPS and speed...
    The use of ONVIF IP cameras would allow for better wireing and even Wifi cameras.
    I use >$20 cameras in my setup.

    I dont have the tech capacity to adapt this project myself tho :)

    ReplyDelete