Jul 21, 2014

Make a copy of your SD card: Raspberry Pi drive recorder with GPS logger

With previous steps, we installed required hardware/software and finished basic configuration so we can now take photo, shoot video, output data to external touchscreen and fetch location data. Before writing some Python code to let those modules work together, I think we should take some time to make a copy of the disk we worked on. This way, even if you make a huge mistake in the near future and everything is messed up, you can install this saved disk image and start from where we are now. It's just like playing your favorite RPG. You don't wanna start from scratch, right?

Making a copy

Just like when we installed Raspbian OS to empty SD card, we use dd command to make a disk image. You insert your SD card to your iMac and hit `diskutil list` to see which disk we are going to use. Then execute `sudo dd if=/dev/disk1 of=Odyssey-Mk1_20140721.dmg`. You should change 'if(input file)' and 'of(output file)' value to suit your environment and preference. My 8GB SD card took 20-30 minutes to complete. It will be longer if you have SD card with larger space.
Oklahomer@Oklahomers ~ » diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 999.3 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *8.1 GB disk1
1: Windows_FAT_32 boot 58.7 MB disk1s1
2: Linux 8.0 GB disk1s2
Oklahomer@Oklahomers ~ » cd proj
Oklahomer@Oklahomers ~/proj » sudo dd if=/dev/disk1 of=Odyssey-Mk1_20140721.dmg
Password:
15759360+0 records in
15759360+0 records out
8068792320 bytes transferred in 1534.748566 secs (5257403 bytes/sec)
Oklahomer@Oklahomers ~/proj » ls -lh Odyssey-Mk1_20140721.dmg
-rw-r--r-- 1 root staff 7.5G 7 21 14:59 Odyssey-Mk1_20140721.dmg
Oklahomer@Oklahomers ~/proj » diskutil eject /dev/disk1
Disk /dev/disk1 ejected

Installing

When you want to install the saved disk image, the process is almost the same as when we installed Raspbian to a fresh SD card. First you insert an SD card that you want to install this disk image to. Then unmount this just like the initial installation. Then `sudo dd if=Odyssey-Mk1_20140721.dmg of=/dev/disk1`. Again, you must set 'if ' and 'of' value to suit your environment.
Oklahomer@Oklahomers ~/proj » sudo dd if=Odyssey-Mk1_20140721.dmg of=/dev/disk1
Password:
15759360+0 records in
15759360+0 records out
8068792320 bytes transferred in 6044.582938 secs (1334880 bytes/sec)
Oklahomer@Oklahomers ~/proj » diskutil eject /dev/disk1
Disk /dev/disk1 ejected
It takes longer than making an OS image. In my case it took me more than 2 hours. You must be really patient.

My trick

If your SD card has larger space and you have chosen to 'Expand Filesystem' on the initial configuration, both steps take longer time to complete. So I make my 8GB SD card to be a master and make a copy of it. This way it doesn't have to copy each and every byte of 64GB. Then I install this to Micro SD card with larger volume. Right after this installation, this Micro SD card only utilizes 8GB of the entire space because I made a copy of 8GB SD card.
Oklahomer@Oklahomers ~/proj » ssh pi@192.168.0.4
pi@192.168.0.4's password:
Linux raspberrypi 3.6.11+ #26 PREEMPT Tue Nov 26 18:19:51 SGT 2013 armv6l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 21 04:55:04 2014 from 192.168.0.2
pi@raspberrypi ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 7.4G 2.3G 4.8G 33% /
/dev/root 7.4G 2.3G 4.8G 33% /
devtmpfs 180M 0 180M 0% /dev
tmpfs 38M 216K 38M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 75M 0 75M 0% /run/shm
/dev/mmcblk0p1 56M 21M 36M 38% /boot
view raw gistfile1.txt hosted with ❤ by GitHub
So I `sudo raspi-config` again and choose 'Expand Filesystem' to utilize all spaces left.
pi@raspberrypi ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 59G 2.3G 54G 5% /
/dev/root 59G 2.3G 54G 5% /
devtmpfs 180M 0 180M 0% /dev
tmpfs 38M 216K 38M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 75M 0 75M 0% /run/shm
/dev/mmcblk0p1 56M 21M 36M 38% /boot
view raw gistfile1.txt hosted with ❤ by GitHub

Jul 20, 2014

Setting up GPS module: Raspberry Pi drive recorder with GPS logger

Previously we attached PiTFT and finished touchscreen configuration. Now we are going to add GPS module to fetch location data.

For my project, I chose Adafruit's Ultimate GPS Breakout. I searched some GPS modules on the web and Adafruit's one have detailed official guide and many reference article by users. Spec. seemed good, too:

Freeing UART

2 ways of connection are introduced on the official guide:

The former seems easier and the guide recommends this way, but I chose the later one because I didn't want to use one of two USB ports. To do it some extra steps are required.

First you need to edit /boot/cmdline.txt
--- /boot/cmdline.txt.20140720 2014-07-19 15:20:01.000000000 +0000
+++ /boot/cmdline.txt 2014-07-19 15:20:47.000000000 +0000
@@ -1 +1 @@
-dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
+dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
view raw cmdline.diff hosted with ❤ by GitHub

You need to remove those parts that include console=ttyAMA0 because we are going to use ttyAMA0 from now. I added rpitestmode=1 because other users' blog entries seem to include it.

Second you edit /etc/inittab
--- /etc/inittab.20140720 2014-07-19 15:27:14.575100326 +0000
+++ /etc/inittab 2014-07-19 15:27:54.784636660 +0000
@@ -69,4 +69,4 @@
#Spawn a getty on Raspberry Pi serial line
-T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
+#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
view raw inittab.diff hosted with ❤ by GitHub

Then reboot and activate your change. This step is done.

Installing required packages

Before connecting GPS module, install required packages. It includes some interface that you can later use to interact with GPS data from python code.
pi@raspberrypi ~ $ sudo apt-get install gpsd gpsd-clients python-gps
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgps20 python-cairo python-gobject-2 python-gtk2
Suggested packages:
python-gobject-2-dbg python-gtk2-doc
The following NEW packages will be installed:
gpsd gpsd-clients libgps20 python-cairo python-gobject-2 python-gps python-gtk2
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,605 kB of archives.
After this operation, 8,113 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgps20 armhf 3.6-4+deb7u1 [233 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main gpsd armhf 3.6-4+deb7u1 [110 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-gps armhf 3.6-4+deb7u1 [124 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-cairo armhf 1.8.8-1 [68.6 kB]
Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-gobject-2 armhf 2.28.6-10 [475 kB]
Get:6 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-gtk2 armhf 2.24.0-3 [1,450 kB]
Get:7 http://mirrordirector.raspbian.org/raspbian/ wheezy/main gpsd-clients armhf 3.6-4+deb7u1 [144 kB]
Fetched 2,605 kB in 7s (328 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libgps20:armhf.
(Reading database ... 71303 files and directories currently installed.)
Unpacking libgps20:armhf (from .../libgps20_3.6-4+deb7u1_armhf.deb) ...
Selecting previously unselected package gpsd.
Unpacking gpsd (from .../gpsd_3.6-4+deb7u1_armhf.deb) ...
Selecting previously unselected package python-gps.
Unpacking python-gps (from .../python-gps_3.6-4+deb7u1_armhf.deb) ...
Selecting previously unselected package python-cairo.
Unpacking python-cairo (from .../python-cairo_1.8.8-1_armhf.deb) ...
Selecting previously unselected package python-gobject-2.
Unpacking python-gobject-2 (from .../python-gobject-2_2.28.6-10_armhf.deb) ...
Selecting previously unselected package python-gtk2.
Unpacking python-gtk2 (from .../python-gtk2_2.24.0-3_armhf.deb) ...
Selecting previously unselected package gpsd-clients.
Unpacking gpsd-clients (from .../gpsd-clients_3.6-4+deb7u1_armhf.deb) ...
Processing triggers for man-db ...
Processing triggers for menu ...
Setting up libgps20:armhf (3.6-4+deb7u1) ...
Setting up gpsd (3.6-4+deb7u1) ...
Setting up python-gps (3.6-4+deb7u1) ...
Setting up python-cairo (1.8.8-1) ...
Setting up python-gobject-2 (2.28.6-10) ...
Setting up python-gtk2 (2.24.0-3) ...
Setting up gpsd-clients (3.6-4+deb7u1) ...
Processing triggers for python-support ...
Processing triggers for menu ...

Connecting GPS module

This time we use the cobbler cable I introduced in my previous article about PiTFT. It looks like the capture below.



As shown in the second capture, you should connect GPS module's VIN to Pi's 5v, GND to GND, RX to TXD and TX to RXD. Note that TX and RX are cross wired since module's input is Pi's output and vise versa.

Check and debug

You execute `sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock` and now gpsd is running. Check if you can properly read the receiving data by `cgps -s`. If it's working, the output is something like below.
┌───────────────────────────────────────────┐┌─────────────────────────────────┐
│ Time: 2014-07-10T12:26:33.000Z ││PRN: Elev: Azim: SNR: Used: │
│ Latitude: XX.XXXXXX N ││ 193 84 327 28 Y │
│ Longitude: XXX.XXXXXX E ││ 4 67 049 30 Y │
│ Altitude: XX.X ft ││ 6 61 335 40 Y │
│ Speed: 0.3 mph ││ 10 59 261 21 Y │
│ Heading: 7.5 deg (true) ││ 13 50 096 00 Y │
│ Climb: 0.0 ft/min ││ 2 30 303 36 N │
│ Status: 3D FIX (6 secs) ││ 12 14 300 36 N │
│ Longitude Err: +/- 59 ft ││ 38 00 000 00 N │
│ Latitude Err: +/- 118 ft ││ │
│ Altitude Err: +/- 73 ft ││ │
│ Course Err: n/a ││ │
│ Speed Err: +/- 161 mph ││ │
│ Time offset: 0.530 ││ │
│ Grid Square: PM95ur ││ │
└───────────────────────────────────────────┘└─────────────────────────────────┘
view raw cgps.txt hosted with ❤ by GitHub

In my case it didn't work at the first place and I had to go through debug process.
To add debug option to gpsd you add -D followed by a number that indicate debug level. e.g. `sudo gpsd /dev/ttyAMA0 -N -D3 -F /var/run/gpsd.sock`. I saw messages like below. It kept saying 'Satellite data no good (1 of 1).'
pi@raspberrypi ~ $ sudo gpsd /dev/ttyAMA0 -N -D3 -F /var/run/gpsd.sock
gpsd:INFO: launching (Version 3.6)
gpsd:ERROR: can't create IPv6 socket
gpsd:INFO: listening on port gpsd
gpsd:INFO: NTPD ntpd_link_activate: 1
gpsd:INFO: stashing device /dev/ttyAMA0 at slot 0
gpsd:INFO: running with effective group ID 20
gpsd:INFO: running with effective user ID 65534
gpsd:INFO: startup at 2014-07-08T12:42:12.000Z (1404823332)
gpsd:INFO: opening GPS data source type 2 at '/dev/ttyAMA0'
gpsd:INFO: speed 9600, 8N1
gpsd:INFO: speed 9600, 8O1
gpsd:INFO: speed 9600, 8N1
gpsd:INFO: gpsd_activate(): activated GPS (fd 7)
gpsd:INFO: /dev/ttyAMA0 identified as type Generic NMEA (0.735407 sec @ 9600bps)
gpsd:DATA: GGA: hhmmss=124252.084 lat=nan lon=nan alt=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|STATUS|PACKET|DRIVER}
gpsd:DATA: GPGSA: mode=1 used=0 pdop=0.00 hdop=0.00 vdop=0.00
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|MODE|DOP|PACKET|USED}
gpsd:DATA: RMC: ddmmyy=080714 hhmmss=124252.084 lat=nan lon=nan speed=nan track=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:INFO: detaching 127.0.0.1 (sub 0, fd 6) in detach_client
gpsd:WARN: Satellite data no good (1 of 1).
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: RMC: ddmmyy=080714 hhmmss=124259.084 lat=nan lon=nan speed=nan track=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: RMC: ddmmyy=080714 hhmmss=124306.084 lat=nan lon=nan speed=nan track=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:WARN: unknown sentence: "$PMTK705,AXN_2.10_3339_2012072601,5223,PA6H,1.0*6A\x0d\x0a"
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|DEVICEID|PACKET}
gpsd:DATA: GGA: hhmmss=124307.084 lat=nan lon=nan alt=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|STATUS|PACKET|DRIVER}
gpsd:DATA: GPGSA: mode=1 used=0 pdop=0.00 hdop=0.00 vdop=0.00
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|MODE|DOP|PACKET|USED}
gpsd:DATA: RMC: ddmmyy=080714 hhmmss=124307.084 lat=nan lon=nan speed=nan track=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: GGA: hhmmss=124308.084 lat=nan lon=nan alt=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|STATUS|PACKET}
gpsd:DATA: GPGSA: mode=1 used=0 pdop=0.00 hdop=0.00 vdop=0.00
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|MODE|DOP|PACKET|USED}
gpsd:DATA: RMC: ddmmyy=080714 hhmmss=124308.084 lat=nan lon=nan speed=nan track=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|PACKET}
gpsd:DATA: GGA: hhmmss=124309.084 lat=nan lon=nan alt=nan mode=0 status=0
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|STATUS|PACKET}
gpsd:DATA: GPGSA: mode=1 used=0 pdop=0.00 hdop=0.00 vdop=0.00
gpsd:DATA: packet from /dev/ttyAMA0 with {ONLINE|MODE|DOP|PACKET|USED}
gpsd:WARN: Satellite data no good (1 of 1).

I couldn't really tell if the wiring connection has a problem or the GPS module is not receiving data. So I checked what's in /dev/ttyAMA0.
pi@raspberrypi ~ $ sudo cat /dev/ttyAMA0
$GPGGA,140935.879,,,,,0,0,,,M,,M,,*44
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,140935.879,V,,,,,0.00,0.00,080714,,,N*4B
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,140935.879,,,,,0,0,,,M,,M,,*44
????$GPGSA,A,1,,,,,,,,,,,,,,,*1E
,,M,,*44
????$GPRMC,140935.879,V,,,,,0.00,0.00,080714,,,N*4B

The GPS module was set by a window, soldering seemed O.K. and it looked like my GPS module was receiving some partial data. I couldn't really tell what to do so I posted to Adafruit's forum. As shown on the forum topic, they were kind and helped me well. Now my GPS module works perfect and I can receive consistent data.

Recommended

I didn't know GPS module is so sensitive until I faced the problem. Now I have my external antenna attached. You can set this antenna on the roof of your car to receive better data. To do this you'll need:
Basically we installed all required packages and attached all modules we need. We are going to make a copy of OS before making any mistake and being forced to start all over again.

Jul 19, 2014

Setting up touchscreen: Raspberry Pi drive recorder with GPS logger

Since PiTFT itself is already setup in the last step, now I continue to setup touchscreen. This step is also documented on the official document so you should read though this first.

Basic setup

To start with, we make udev rule for the touchscreen.
pi@raspberrypi ~ $ sudo touch /etc/udev/rules.d/95-stmpe.rules
pi@raspberrypi ~ $ echo 'SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"' | sudo tee -a /etc/udev/rules.d/95-stmpe.rules
SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
view raw gistfile1.txt hosted with ❤ by GitHub
Then remove and re-install touchscreen package. Then check if current setup went O.K. Now touchscreen should refer to eventN where N is number.
pi@raspberrypi ~ $ sudo rmmod stmpe_ts; sudo modprobe stmpe_ts
pi@raspberrypi ~ $ ls -l /dev/input/touchscreen
lrwxrwxrwx 1 root root 6 Jul 19 13:22 /dev/input/touchscreen -> event0
view raw gistfile1.txt hosted with ❤ by GitHub

Calibration

Before calibration process I installed some handy tools that were introduced on the document.
pi@raspberrypi ~ $ sudo apt-get install evtest tslib libts-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libts-0.0-0' instead of 'tslib'
libts-0.0-0 is already the newest version.
libts-0.0-0 set to manually installed.
The following NEW packages will be installed:
evtest libts-bin
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 55.0 kB of archives.
After this operation, 219 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libts-bin armhf 1.0-11 [33.1 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main evtest armhf 1:1.30-1 [21.9 kB]
Fetched 55.0 kB in 1s (35.0 kB/s)
Selecting previously unselected package libts-bin.
(Reading database ... 71112 files and directories currently installed.)
Unpacking libts-bin (from .../libts-bin_1.0-11_armhf.deb) ...
Selecting previously unselected package evtest.
Unpacking evtest (from .../evtest_1%3a1.30-1_armhf.deb) ...
Processing triggers for man-db ...
Setting up libts-bin (1.0-11) ...
Setting up evtest (1:1.30-1) ...

Lastly

I installed mplayer for later preview use.
pi@raspberrypi ~ $ sudo apt-get install mplayer
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libaa1 libcdparanoia0 libdca0 libdvdnav4 libdvdread4 libenca0 libfribidi0 liblircclient0 liblzo2-2 libmpeg2-4 libopenal-data libopenal1 libpostproc52 libxvmc1
Suggested packages:
libdvdcss2 lirc libportaudio2 libroar-compat2 mplayer-doc netselect fping
The following NEW packages will be installed:
libaa1 libcdparanoia0 libdca0 libdvdnav4 libdvdread4 libenca0 libfribidi0 liblircclient0 liblzo2-2 libmpeg2-4 libopenal-data libopenal1 libpostproc52 libxvmc1 mplayer
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,383 kB of archives.
After this operation, 6,709 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libaa1 armhf 1.4p5-40 [59.3 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdvdread4 armhf 4.2.0+20120521-2 [55.2 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdvdnav4 armhf 4.2.0+20120524-2 [42.2 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libfribidi0 armhf 0.19.2-3 [35.6 kB]
Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main liblzo2-2 armhf 2.06-1 [56.0 kB]
Get:6 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libopenal-data all 1:1.14-4 [11.1 kB]
Get:7 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libopenal1 armhf 1:1.14-4 [177 kB]
Get:8 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libpostproc52 armhf 6:0.8.10-1+rpi1 [71.8 kB]
Get:9 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libcdparanoia0 armhf 3.10.2+debian-10.1 [50.9 kB]
Get:10 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdca0 armhf 0.0.5-5 [112 kB]
Get:11 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libenca0 armhf 1.13-4 [67.5 kB]
Get:12 http://mirrordirector.raspbian.org/raspbian/ wheezy/main liblircclient0 armhf 0.9.0~pre1-1 [35.1 kB]
Get:13 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libmpeg2-4 armhf 0.4.1-3 [61.9 kB]
Get:14 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libxvmc1 armhf 2:1.0.7-1+deb7u2 [23.4 kB]
Get:15 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mplayer armhf 2:1.0~rc4.dfsg1+svn34540-1 [2,524 kB]
Fetched 3,383 kB in 13s (255 kB/s)
Selecting previously unselected package libaa1:armhf.
(Reading database ... 71135 files and directories currently installed.)
Unpacking libaa1:armhf (from .../libaa1_1.4p5-40_armhf.deb) ...
Selecting previously unselected package libdvdread4.
Unpacking libdvdread4 (from .../libdvdread4_4.2.0+20120521-2_armhf.deb) ...
Selecting previously unselected package libdvdnav4.
Unpacking libdvdnav4 (from .../libdvdnav4_4.2.0+20120524-2_armhf.deb) ...
Selecting previously unselected package libfribidi0:armhf.
Unpacking libfribidi0:armhf (from .../libfribidi0_0.19.2-3_armhf.deb) ...
Selecting previously unselected package liblzo2-2:armhf.
Unpacking liblzo2-2:armhf (from .../liblzo2-2_2.06-1_armhf.deb) ...
Selecting previously unselected package libopenal-data.
Unpacking libopenal-data (from .../libopenal-data_1%3a1.14-4_all.deb) ...
Selecting previously unselected package libopenal1:armhf.
Unpacking libopenal1:armhf (from .../libopenal1_1%3a1.14-4_armhf.deb) ...
Selecting previously unselected package libpostproc52:armhf.
Unpacking libpostproc52:armhf (from .../libpostproc52_6%3a0.8.10-1+rpi1_armhf.deb) ...
Selecting previously unselected package libcdparanoia0.
Unpacking libcdparanoia0 (from .../libcdparanoia0_3.10.2+debian-10.1_armhf.deb) ...
Selecting previously unselected package libdca0.
Unpacking libdca0 (from .../libdca0_0.0.5-5_armhf.deb) ...
Selecting previously unselected package libenca0.
Unpacking libenca0 (from .../libenca0_1.13-4_armhf.deb) ...
Selecting previously unselected package liblircclient0.
Unpacking liblircclient0 (from .../liblircclient0_0.9.0~pre1-1_armhf.deb) ...
Selecting previously unselected package libmpeg2-4.
Unpacking libmpeg2-4 (from .../libmpeg2-4_0.4.1-3_armhf.deb) ...
Selecting previously unselected package libxvmc1.
Unpacking libxvmc1 (from .../libxvmc1_2%3a1.0.7-1+deb7u2_armhf.deb) ...
Selecting previously unselected package mplayer.
Unpacking mplayer (from .../mplayer_2%3a1.0~rc4.dfsg1+svn34540-1_armhf.deb) ...
Processing triggers for man-db ...
Processing triggers for mime-support ...
Setting up libaa1:armhf (1.4p5-40) ...
Setting up libdvdread4 (4.2.0+20120521-2) ...
Setting up libdvdnav4 (4.2.0+20120524-2) ...
Setting up libfribidi0:armhf (0.19.2-3) ...
Setting up liblzo2-2:armhf (2.06-1) ...
Setting up libopenal-data (1:1.14-4) ...
Setting up libopenal1:armhf (1:1.14-4) ...
Setting up libpostproc52:armhf (6:0.8.10-1+rpi1) ...
Setting up libcdparanoia0 (3.10.2+debian-10.1) ...
Setting up libdca0 (0.0.5-5) ...
Setting up libenca0 (1.13-4) ...
Setting up liblircclient0 (0.9.0~pre1-1) ...
Setting up libmpeg2-4 (0.4.1-3) ...
Setting up libxvmc1 (2:1.0.7-1+deb7u2) ...
Setting up mplayer (2:1.0~rc4.dfsg1+svn34540-1) ...
I downloaded video from and played it with the code below, which is exactly the same as documented.
pi@raspberrypi ~ $ mplayer -vo fbdev2:/dev/fb1 -x 240 -y 320 -framedrop bigbuckbunny320p.mp4
view raw gistfile1.txt hosted with ❤ by GitHub
Then I saw some scary message. I'll have to check this out later. I'm just going to add GPS module and see if it works.
************************************************
**** Your system is too SLOW to play this! ****
************************************************
Possible reasons, problems, workarounds:
- Most common: broken/buggy _audio_ driver
- Try -ao sdl or use the OSS emulation of ALSA.
- Experiment with different values for -autosync, 30 is a good start.
- Slow video output
- Try a different -vo driver (-vo help for a list) or try -framedrop!
- Slow CPU
- Don't try to play a big DVD/DivX on a slow CPU! Try some of the lavdopts,
e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.
- Broken file
- Try various combinations of -nobps -ni -forceidx -mc 0.
- Slow media (NFS/SMB mounts, DVD, VCD etc)
- Try -cache 8192.
- Are you using -cache to play a non-interleaved AVI file?
- Try -nocache.
Read DOCS/HTML/en/video.html for tuning/speedup tips.
If none of this helps you, read DOCS/HTML/en/bugreports.html.
view raw gistfile1.txt hosted with ❤ by GitHub

Setting up PiTFT: Raspberry Pi drive recorder with GPS logger

Since we are done installing RaspiCam, now we are going to attach PiTFT and install required software. Before setting up PiTFT you should read through the complete document because it covers pretty much everything. What we need to do is to solder hardware and install some software packages.

Hardware


When you open the PiTFT package you'll find extra 2x13 IDC socket for additional cobbler cable. PiFTF's female header covers Pi's all 26 GPIO header pins, but it actually uses 3 of them so it seems a good idea to connect cobbler cable to utilize the rest of 23 pins.
Cobbler breakout and cable package includes parts as shown below. You can stick the pins right to your breadboard so its really easy to add and test other modules like GPS and microphone amplifier module.


If you solder IDC socket, don't solder it on top of it. Do it on the reverse side.


And you make sure the white code, pin 1 indicator, goes right next to the female header.


When you solder female header and optional IDC socket, hardware part is done. Set the female header to your Pi's GPIO header pins.

Software

Software part needs a bit more work than RaspiCam. You'll need to get 5 packages as described on the document:
  • http://adafruit-download.s3.amazonaws.com/libraspberrypi-bin-adafruit.deb
  • http://adafruit-download.s3.amazonaws.com/libraspberrypi-dev-adafruit.deb
  • http://adafruit-download.s3.amazonaws.com/libraspberrypi-doc-adafruit.deb
  • http://adafruit-download.s3.amazonaws.com/libraspberrypi0-adafruit.deb
  • http://adafruit-download.s3.amazonaws.com/raspberrypi-bootloader-adafruit-112613.deb
And then use dpkg to install them. The install log is shown below. You need to reboot your Pi to activate this change.
pi@raspberrypi ~ $ mkdir pitft-setup
pi@raspberrypi ~ $ cd pitft-setup/
pi@raspberrypi ~/pitft-setup $ wget http://adafruit-download.s3.amazonaws.com/libraspberrypi-bin-adafruit.deb && \
> wget http://adafruit-download.s3.amazonaws.com/libraspberrypi-dev-adafruit.deb && \
> wget http://adafruit-download.s3.amazonaws.com/libraspberrypi-doc-adafruit.deb && \
> wget http://adafruit-download.s3.amazonaws.com/libraspberrypi0-adafruit.deb && \
> wget http://adafruit-download.s3.amazonaws.com/raspberrypi-bootloader-adafruit-112613.deb
--2014-07-21 04:28:16-- http://adafruit-download.s3.amazonaws.com/libraspberrypi-bin-adafruit.deb
Resolving adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)... 54.231.19.49
Connecting to adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)|54.231.19.49|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 184818 (180K) [application/octet-stream]
Saving to: `libraspberrypi-bin-adafruit.deb'
100%[=======================================================================================================================================>] 184,818 168K/s in 1.1s
2014-07-21 04:28:17 (168 KB/s) - `libraspberrypi-bin-adafruit.deb' saved [184818/184818]
--2014-07-21 04:28:17-- http://adafruit-download.s3.amazonaws.com/libraspberrypi-dev-adafruit.deb
Resolving adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)... 176.32.99.35
Connecting to adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)|176.32.99.35|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 672150 (656K) [application/octet-stream]
Saving to: `libraspberrypi-dev-adafruit.deb'
100%[=======================================================================================================================================>] 672,150 279K/s in 2.4s
2014-07-21 04:28:20 (279 KB/s) - `libraspberrypi-dev-adafruit.deb' saved [672150/672150]
--2014-07-21 04:28:20-- http://adafruit-download.s3.amazonaws.com/libraspberrypi-doc-adafruit.deb
Resolving adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)... 54.231.18.137
Connecting to adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)|54.231.18.137|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 31480442 (30M) [application/octet-stream]
Saving to: `libraspberrypi-doc-adafruit.deb'
100%[=======================================================================================================================================>] 31,480,442 931K/s in 29s
2014-07-21 04:28:50 (1.03 MB/s) - `libraspberrypi-doc-adafruit.deb' saved [31480442/31480442]
--2014-07-21 04:28:50-- http://adafruit-download.s3.amazonaws.com/libraspberrypi0-adafruit.deb
Resolving adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)... 54.231.8.185
Connecting to adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)|54.231.8.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 444188 (434K) [application/octet-stream]
Saving to: `libraspberrypi0-adafruit.deb'
100%[=======================================================================================================================================>] 444,188 58.8K/s in 7.4s
2014-07-21 04:28:57 (58.8 KB/s) - `libraspberrypi0-adafruit.deb' saved [444188/444188]
--2014-07-21 04:28:58-- http://adafruit-download.s3.amazonaws.com/raspberrypi-bootloader-adafruit-112613.deb
Resolving adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)... 54.231.12.161
Connecting to adafruit-download.s3.amazonaws.com (adafruit-download.s3.amazonaws.com)|54.231.12.161|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27410550 (26M) [application/octet-stream]
Saving to: `raspberrypi-bootloader-adafruit-112613.deb'
100%[=======================================================================================================================================>] 27,410,550 804K/s in 60s
2014-07-21 04:29:59 (443 KB/s) - `raspberrypi-bootloader-adafruit-112613.deb' saved [27410550/27410550]
pi@raspberrypi ~/pitft-setup $ sudo dpkg -i -B *.deb
Selecting previously unselected package libraspberrypi0-adafruit.
dpkg: considering removing libraspberrypi0 in favour of libraspberrypi0-adafruit ...
dpkg: yes, will remove libraspberrypi0 in favour of libraspberrypi0-adafruit
(Reading database ... 71274 files and directories currently installed.)
Unpacking libraspberrypi0-adafruit (from libraspberrypi0-adafruit.deb) ...
De-configuring libraspberrypi-doc, to allow removal of libraspberrypi0 ...
De-configuring libraspberrypi-dev, to allow removal of libraspberrypi0 ...
De-configuring libraspberrypi-bin, to allow removal of libraspberrypi0 ...
Selecting previously unselected package libraspberrypi-bin-adafruit.
dpkg: considering removing libraspberrypi-bin in favour of libraspberrypi-bin-adafruit ...
dpkg: libraspberrypi-bin is not properly installed; ignoring any dependencies on it
dpkg: yes, will remove libraspberrypi-bin in favour of libraspberrypi-bin-adafruit
Unpacking libraspberrypi-bin-adafruit (from libraspberrypi-bin-adafruit.deb) ...
Selecting previously unselected package libraspberrypi-dev-adafruit.
dpkg: considering removing libraspberrypi-dev in favour of libraspberrypi-dev-adafruit ...
dpkg: libraspberrypi-dev is not properly installed; ignoring any dependencies on it
dpkg: yes, will remove libraspberrypi-dev in favour of libraspberrypi-dev-adafruit
Unpacking libraspberrypi-dev-adafruit (from libraspberrypi-dev-adafruit.deb) ...
Selecting previously unselected package libraspberrypi-doc-adafruit.
dpkg: considering removing libraspberrypi-doc in favour of libraspberrypi-doc-adafruit ...
dpkg: libraspberrypi-doc is not properly installed; ignoring any dependencies on it
dpkg: yes, will remove libraspberrypi-doc in favour of libraspberrypi-doc-adafruit
Unpacking libraspberrypi-doc-adafruit (from libraspberrypi-doc-adafruit.deb) ...
Selecting previously unselected package raspberrypi-bootloader-adafruit.
dpkg: considering removing raspberrypi-bootloader in favour of raspberrypi-bootloader-adafruit ...
dpkg: yes, will remove raspberrypi-bootloader in favour of raspberrypi-bootloader-adafruit
Unpacking raspberrypi-bootloader-adafruit (from raspberrypi-bootloader-adafruit-112613.deb) ...
Adding 'diversion of /boot/bootcode.bin to /usr/share/rpikernelhack/bootcode.bin by rpikernelhack'
Adding 'diversion of /boot/fixup.dat to /usr/share/rpikernelhack/fixup.dat by rpikernelhack'
Adding 'diversion of /boot/fixup_cd.dat to /usr/share/rpikernelhack/fixup_cd.dat by rpikernelhack'
Adding 'diversion of /boot/fixup_x.dat to /usr/share/rpikernelhack/fixup_x.dat by rpikernelhack'
Adding 'diversion of /boot/kernel.img to /usr/share/rpikernelhack/kernel.img by rpikernelhack'
Adding 'diversion of /boot/kernel_cutdown.img to /usr/share/rpikernelhack/kernel_cutdown.img by rpikernelhack'
Adding 'diversion of /boot/kernel_emergency.img to /usr/share/rpikernelhack/kernel_emergency.img by rpikernelhack'
Adding 'diversion of /boot/start.elf to /usr/share/rpikernelhack/start.elf by rpikernelhack'
Adding 'diversion of /boot/start_cd.elf to /usr/share/rpikernelhack/start_cd.elf by rpikernelhack'
Adding 'diversion of /boot/start_x.elf to /usr/share/rpikernelhack/start_x.elf by rpikernelhack'
Setting up raspberrypi-bootloader-adafruit (1.20130902-4) ...
Memory split is now set in /boot/config.txt.
You may want to use raspi-config to set it
Removing 'diversion of /boot/bootcode.bin to /usr/share/rpikernelhack/bootcode.bin by rpikernelhack'
Removing 'diversion of /boot/fixup.dat to /usr/share/rpikernelhack/fixup.dat by rpikernelhack'
Removing 'diversion of /boot/fixup_cd.dat to /usr/share/rpikernelhack/fixup_cd.dat by rpikernelhack'
Removing 'diversion of /boot/fixup_x.dat to /usr/share/rpikernelhack/fixup_x.dat by rpikernelhack'
Removing 'diversion of /boot/kernel.img to /usr/share/rpikernelhack/kernel.img by rpikernelhack'
Removing 'diversion of /boot/kernel_cutdown.img to /usr/share/rpikernelhack/kernel_cutdown.img by rpikernelhack'
Removing 'diversion of /boot/kernel_emergency.img to /usr/share/rpikernelhack/kernel_emergency.img by rpikernelhack'
Removing 'diversion of /boot/start.elf to /usr/share/rpikernelhack/start.elf by rpikernelhack'
Removing 'diversion of /boot/start_cd.elf to /usr/share/rpikernelhack/start_cd.elf by rpikernelhack'
Removing 'diversion of /boot/start_x.elf to /usr/share/rpikernelhack/start_x.elf by rpikernelhack'
Setting up libraspberrypi0-adafruit (1.20130902-1) ...
Setting up libraspberrypi-bin-adafruit (1.20130902-1) ...
Setting up libraspberrypi-dev-adafruit (1.20130902-1) ...
Setting up libraspberrypi-doc-adafruit (1.20130902-1) ...
pi@raspberrypi ~/pitft-setup $
pi@raspberrypi ~/pitft-setup $
pi@raspberrypi ~/pitft-setup $
pi@raspberrypi ~/pitft-setup $ sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~
pi@raspberrypi ~/pitft-setup $ sudo reboot
Broadcast message from root@raspberrypi (pts/1) (Mon Jul 21 04:34:31 2014):
The system is going down for reboot NOW!
view raw setup-pitft.txt hosted with ❤ by GitHub

Test

After rebooting your Pi, you need to let your Pi install screen driver. Commands are below. This modprobe command lets you load kernel modules. In this case we load spi-bcm2708 and fbtft_device.
pi@raspberrypi ~ $ sudo modprobe spi-bcm2708
pi@raspberrypi ~ $ sudo modprobe fbtft_device name=adafruitts rotate=90
pi@raspberrypi ~ $ export FRAMEBUFFER=/dev/fb1
pi@raspberrypi ~ $ startx
X.Org X Server 1.12.4
Release Date: 2012-08-27
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-2-mx5 armv7l Debian
Current Operating System: Linux raspberrypi 3.6.11+ #26 PREEMPT Tue Nov 26 18:19:51 SGT 2013 armv6l
Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xd bcm2708.serial=0x8ed0b627 smsc95xx.macaddr=B8:27:EB:D0:B6:27 sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Build Date: 18 December 2013 05:20:52PM
xorg-server 2:1.12.4-6+deb7u2 (Julien Cristau <jcristau@debian.org>)
Current version of pixman: 0.29.3
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sat Jul 19 12:28:13 2014
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
view raw start-pitft.txt hosted with ❤ by GitHub
If it goes O.K., the desktop shows up.


From next boot, we want Pi to load those kernel modules automatically so we add some modifications to /etc/modules. The modules listed in /etc/modules are loaded on boot so we don't have to repeat the previous step to load them.
pi@raspberrypi ~ $ diff -u /etc/modules.20140719 /etc/modules
--- /etc/modules.20140719 2014-07-19 12:38:50.567608153 +0000
+++ /etc/modules 2014-07-19 12:39:07.797409722 +0000
@@ -5,3 +5,5 @@
# Parameters can be specified after the module name.
snd-bcm2835
+spi-bcm2708
+fbtft_device
view raw modules.diff hosted with ❤ by GitHub
And add new file: /etc/modprobe.d/adafruit.conf. rotate value indicate the rotation angle while frequency tells how fast it should drive the display. If the display acts weird document suggests you to drop this frequency value to 16000000.
pi@raspberrypi ~ $ sudo touch /etc/modprobe.d/adafruit.conf
pi@raspberrypi ~ $ echo 'options fbtft_device name=adafruitts rotate=90 frequency=32000000' | sudo tee -a /etc/modprobe.d/adafruit.conf
view raw gistfile1.txt hosted with ❤ by GitHub
Reboot and add some calibration setting.
pi@raspberrypi ~ $ sudo mkdir /etc/X11/xorg.conf.d
pi@raspberrypi ~ $ sudo vim /etc/X11/xorg.conf.d/99-calibration.conf
pi@raspberrypi ~ $ cat /etc/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
Identifier "calibration"
MatchProduct "stmpe-ts"
Option "Calibration" "3800 200 200 3800"
Option "SwapAxes" "1"
EndSection
view raw gistfile1.txt hosted with ❤ by GitHub
Add some setting to .profile for later convinience.
pi@raspberrypi ~ $ cp ~/.profile ~/.profile.20140719
pi@raspberrypi ~ $ vim /home/pi/.profile
pi@raspberrypi ~ $ diff -u ~/.profile.20140719 ~/.profile
--- /home/pi/.profile.20140719 2014-07-19 12:57:19.475273357 +0000
+++ /home/pi/.profile 2014-07-19 12:57:44.554983915 +0000
@@ -20,3 +20,6 @@
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
+
+# https://learn.adafruit.com/downloads/pdf/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi.pdf
+export FRAMEBUFFER=/dev/fb1
view raw gistfile1.txt hosted with ❤ by GitHub
Then run `startx` and desktop will show up.

Display STDOUT on PiTFT

If you wish to output standard output to PITFT on boot, make some change to /boot/cmdline.txt like below.
--- /boot/cmdline.txt.20140723 2014-07-23 13:59:38.000000000 +0000
+++ /boot/cmdline.txt 2014-07-23 13:59:53.000000000 +0000
@@ -1 +1 @@
-dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
+dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:VGA8x8
view raw gistfile1.diff hosted with ❤ by GitHub

Then hit some commands and PiTFT will display standard output.
pi@raspberrypi ~ $ ls /sys/class/gpio/
export gpiochip0 gpiochip250 unexport
pi@raspberrypi ~ $ sudo sh -c "echo 252 > /sys/class/gpio/export"
pi@raspberrypi ~ $ sudo sh -c "echo 'out' > /sys/class/gpio/gpio252/direction"
pi@raspberrypi ~ $ sudo sh -c "echo '1' > /sys/class/gpio/gpio252/value"
view raw gistfile1.txt hosted with ❤ by GitHub
When you want to turn it off you simply write 0 to /sys/class/gpio/gpio252/value.
sudo sh -c "echo '0' > /sys/class/gpio/gpio252/value"
view raw gistfile1.txt hosted with ❤ by GitHub

We are going to setup and calibrate touchscreen, now.

Shooting video with RaspiCam: Raspberry Pi drive recorder with GPS logger

In last article we connected RaspiCam and took photo. Now we are going to shoot video with it.

Shooting video is as easy as taking picture. Just execute `raspivid -o video.h264 -t 10000`. -o option decides the output file and if '-' is given, output goes to STDOUT. -t is time in millisecond(s). So the command above will give you a 10-second-video with a name of video.h264. To easily convert this to .mp4 you can install gpac and use MP4Box command.

pi@raspberrypi ~/Desktop $ sudo apt-get install -y gpac
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
gpac-modules-base liba52-0.7.4 libavcodec53 libavformat53 libavutil51 libdirac-encoder0 libfaad2 libglu1-mesa libgpac2 libgsm1 libmp3lame0 libschroedinger-1.0-0 libspeex1
libswscale2 libtheora0 libva1 libvpx1 libx264-123 libxvidcore4
Suggested packages:
speex
The following NEW packages will be installed:
gpac gpac-modules-base liba52-0.7.4 libavcodec53 libavformat53 libavutil51 libdirac-encoder0 libfaad2 libglu1-mesa libgpac2 libgsm1 libmp3lame0 libschroedinger-1.0-0
libspeex1 libswscale2 libtheora0 libva1 libvpx1 libx264-123 libxvidcore4
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,715 kB of archives.
After this operation, 18.0 MB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libglu1-mesa armhf 8.0.5-4+deb7u2+rpi1 [152 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgpac2 armhf 0.5.0~dfsg0-1 [1,438 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgsm1 armhf 1.0.13-4 [30.9 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main liba52-0.7.4 armhf 0.7.4-16 [31.4 kB]
Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libavutil51 armhf 6:0.8.10-1+rpi1 [97.8 kB]
Get:6 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdirac-encoder0 armhf 1.0.2-6 [350 kB]
Get:7 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libmp3lame0 armhf 3.99.5+repack1-3 [384 kB]
Get:8 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libschroedinger-1.0-0 armhf 1.0.11-2 [299 kB]
Get:9 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libspeex1 armhf 1.2~rc1-7 [61.7 kB]
Get:10 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libtheora0 armhf 1.1.1+dfsg.1-3.1 [368 kB]
Get:11 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libva1 armhf 1.0.15-4 [35.8 kB]
Get:12 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libvpx1 armhf 1.1.0-1+rpi1 [201 kB]
Get:13 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libx264-123 armhf 2:0.123.2189+git35cf912-1+rpi1 [456 kB]
Get:14 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libxvidcore4 armhf 2:1.3.2-9 [311 kB]
Get:15 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libavcodec53 armhf 6:0.8.10-1+rpi1 [2,300 kB]
Get:16 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libavformat53 armhf 6:0.8.10-1+rpi1 [410 kB]
Get:17 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libfaad2 armhf 2.7-8 [177 kB]
Get:18 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libswscale2 armhf 6:0.8.10-1+rpi1 [104 kB]
Get:19 http://mirrordirector.raspbian.org/raspbian/ wheezy/main gpac-modules-base armhf 0.5.0~dfsg0-1 [277 kB]
Get:20 http://mirrordirector.raspbian.org/raspbian/ wheezy/main gpac armhf 0.5.0~dfsg0-1 [232 kB]
Fetched 7,715 kB in 14s (530 kB/s)
Selecting previously unselected package libglu1-mesa:armhf.
(Reading database ... 71087 files and directories currently installed.)
Unpacking libglu1-mesa:armhf (from .../libglu1-mesa_8.0.5-4+deb7u2+rpi1_armhf.deb) ...
Selecting previously unselected package libgpac2:armhf.
Unpacking libgpac2:armhf (from .../libgpac2_0.5.0~dfsg0-1_armhf.deb) ...
Selecting previously unselected package liba52-0.7.4.
Unpacking liba52-0.7.4 (from .../liba52-0.7.4_0.7.4-16_armhf.deb) ...
Selecting previously unselected package libavutil51:armhf.
Unpacking libavutil51:armhf (from .../libavutil51_6%3a0.8.10-1+rpi1_armhf.deb) ...
Selecting previously unselected package libdirac-encoder0:armhf.
Unpacking libdirac-encoder0:armhf (from .../libdirac-encoder0_1.0.2-6_armhf.deb) ...
Selecting previously unselected package libgsm1:armhf.
Unpacking libgsm1:armhf (from .../libgsm1_1.0.13-4_armhf.deb) ...
Selecting previously unselected package libmp3lame0:armhf.
Unpacking libmp3lame0:armhf (from .../libmp3lame0_3.99.5+repack1-3_armhf.deb) ...
Selecting previously unselected package libschroedinger-1.0-0:armhf.
Unpacking libschroedinger-1.0-0:armhf (from .../libschroedinger-1.0-0_1.0.11-2_armhf.deb) ...
Selecting previously unselected package libspeex1:armhf.
Unpacking libspeex1:armhf (from .../libspeex1_1.2~rc1-7_armhf.deb) ...
Selecting previously unselected package libtheora0:armhf.
Unpacking libtheora0:armhf (from .../libtheora0_1.1.1+dfsg.1-3.1_armhf.deb) ...
Selecting previously unselected package libva1:armhf.
Unpacking libva1:armhf (from .../libva1_1.0.15-4_armhf.deb) ...
Selecting previously unselected package libvpx1:armhf.
Unpacking libvpx1:armhf (from .../libvpx1_1.1.0-1+rpi1_armhf.deb) ...
Selecting previously unselected package libx264-123:armhf.
Unpacking libx264-123:armhf (from .../libx264-123_2%3a0.123.2189+git35cf912-1+rpi1_armhf.deb) ...
Selecting previously unselected package libxvidcore4:armhf.
Unpacking libxvidcore4:armhf (from .../libxvidcore4_2%3a1.3.2-9_armhf.deb) ...
Selecting previously unselected package libavcodec53:armhf.
Unpacking libavcodec53:armhf (from .../libavcodec53_6%3a0.8.10-1+rpi1_armhf.deb) ...
Selecting previously unselected package libavformat53:armhf.
Unpacking libavformat53:armhf (from .../libavformat53_6%3a0.8.10-1+rpi1_armhf.deb) ...
Selecting previously unselected package libfaad2:armhf.
Unpacking libfaad2:armhf (from .../libfaad2_2.7-8_armhf.deb) ...
Selecting previously unselected package libswscale2:armhf.
Unpacking libswscale2:armhf (from .../libswscale2_6%3a0.8.10-1+rpi1_armhf.deb) ...
Selecting previously unselected package gpac-modules-base:armhf.
Unpacking gpac-modules-base:armhf (from .../gpac-modules-base_0.5.0~dfsg0-1_armhf.deb) ...
Selecting previously unselected package gpac.
Unpacking gpac (from .../gpac_0.5.0~dfsg0-1_armhf.deb) ...
Processing triggers for menu ...
Processing triggers for man-db ...
Setting up libglu1-mesa:armhf (8.0.5-4+deb7u2+rpi1) ...
Setting up libgpac2:armhf (0.5.0~dfsg0-1) ...
Setting up liba52-0.7.4 (0.7.4-16) ...
Setting up libavutil51:armhf (6:0.8.10-1+rpi1) ...
Setting up libdirac-encoder0:armhf (1.0.2-6) ...
Setting up libgsm1:armhf (1.0.13-4) ...
Setting up libmp3lame0:armhf (3.99.5+repack1-3) ...
Setting up libschroedinger-1.0-0:armhf (1.0.11-2) ...
Setting up libspeex1:armhf (1.2~rc1-7) ...
Setting up libtheora0:armhf (1.1.1+dfsg.1-3.1) ...
Setting up libva1:armhf (1.0.15-4) ...
Setting up libvpx1:armhf (1.1.0-1+rpi1) ...
Setting up libx264-123:armhf (2:0.123.2189+git35cf912-1+rpi1) ...
Setting up libxvidcore4:armhf (2:1.3.2-9) ...
Setting up libavcodec53:armhf (6:0.8.10-1+rpi1) ...
Setting up libavformat53:armhf (6:0.8.10-1+rpi1) ...
Setting up libfaad2:armhf (2.7-8) ...
Setting up libswscale2:armhf (6:0.8.10-1+rpi1) ...
Setting up gpac-modules-base:armhf (0.5.0~dfsg0-1) ...
Setting up gpac (0.5.0~dfsg0-1) ...
Processing triggers for menu ...
pi@raspberrypi ~/Desktop $
pi@raspberrypi ~/Desktop $
pi@raspberrypi ~/Desktop $
pi@raspberrypi ~/Desktop $
pi@raspberrypi ~/Desktop $ MP4Box -fps 30 -add video.h264 video_out.mp4
AVC-H264 import - frame size 1920 x 1080 at 30.000 FPS
AVC Import results: 293 samples - Slices: 5 I 288 P 0 B - 0 SEI - 5 IDR
Saving to video_out.mp4: 0.500 secs Interleaving
Document for raspivid command can also be found at RaspiCam Documentation. Next we are going to attach PiTFT and finish basic configuration.

Setting up camera module: Raspberry Pi drive recorder with GPS logger

Currently we installed VNC server and client to emulate Raspberry Pi's screen on your PC. We are now going to take picture with RaspiCam and display the picture on the emulated screen.

Setting up Raspberry PI Camera Board is pretty easy. In the previous Raspbian update/upgrade process, all required software are installed so you only have to connect camera board properly, which takes less than one minute.

Connecting camera board

Camera board is as small as 25mm x 20mm. Just stick the end of the cable to your Raspberry Pi and all connection is done.




Taking a picture via CLI

Since we installed VNC server to Raspberry Pi and VNC client to iMac, we can emulate Pi's screen on iMac. So what I do here is to move to Pi's desktop with `cd ~/Desktop` and take a picture with `raspistill -o image.jpg`. Taken photo is saved as image.jpg on desktop and it appears on your VNC screen. Double click on image.jpg. You'll see your photo displayed.


Hitting `raspistill` without any option will show manual of raspistill command. Or you can find detailed document at at 'RaspiCam Documentation' and official document at raspberrypi.org.

Now we are going to shoot video.

Installing VNC server: Raspberry Pi drive recorder with GPS logger

With previous steps you installed Raspian, finished up initial configuration and update/upgraded Raspbian. So the minimum setup is all done now. Before connecting Raspicam to take picture and/or shoot video, I think we should now install VNC server and client. With this, you won't have to connect your Raspberry Pi to external display to see the screen output, but you can emulate the screen on your PC.

To display and interact with Raspberry Pi's screen on my iMac, I installed VNC server to my Raspberry Pi and VNC client to my iMac. This VNC client will emulate the screen on client PC so it's easier to debug camera module taking video and pictures.

Server on Raspberry Pi

All steps are covered in 'Take Control of Your Raspberry Pi Using Your Mac, PC, iPad or Phone' and are really straight forward so you should read this once. Basically what you need to do is just do `sudo apt-get install tightvncserver` and the server is ready. You only have to execute `tightvncserver` and type in password to run VNC server.

Client on iMac

Visit download page and install Chicken of the VNC. Then launch it. Default port is 5901, host IP is the one that you use for ssh connection and the password is the one you just set. You type them in and it's done. Remember not to check 'view only' or you won't be able to click on anything on the desktop on emulated display.


In next article we are going to connect RaspiCam and take a picture with it.

Update/Upgrade Raspbian: Raspberry Pi drive recorder with GPS logger

Since system configuration is done and SSH AcceptEnv problem is solved, I think it's a good time to update/upgrade Raspbian. It doesn't matter if you installed the latest version of Raspbian. Even if you do, you should still update/upgrade before going any further. Actually if you skip this step, camera module may not work. It's pretty easy as doing `sudo apt-get update` and `sudo apt-get upgrade`. Why not do it?

pi@raspberrypi ~ $ sudo apt-get update
Hit http://repository.wolfram.com stable Release.gpg
Hit http://repository.wolfram.com stable Release
Get:1 http://raspberrypi.collabora.com wheezy Release.gpg [836 B]
Get:2 http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]
Get:3 http://archive.raspberrypi.org wheezy Release.gpg [490 B]
Hit http://repository.wolfram.com stable/non-free armhf Packages
Get:4 http://raspberrypi.collabora.com wheezy Release [7,532 B]
Get:5 http://mirrordirector.raspbian.org wheezy Release [14.4 kB]
Get:6 http://archive.raspberrypi.org wheezy Release [7,227 B]
Get:7 http://archive.raspberrypi.org wheezy/main armhf Packages [18.0 kB]
Get:8 http://raspberrypi.collabora.com wheezy/rpi armhf Packages [2,214 B]
Get:9 http://mirrordirector.raspbian.org wheezy/main armhf Packages [6,890 kB]
Ign http://repository.wolfram.com stable/non-free Translation-en_US
Ign http://repository.wolfram.com stable/non-free Translation-en
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en_US
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en
Ign http://archive.raspberrypi.org wheezy/main Translation-en_US
Ign http://archive.raspberrypi.org wheezy/main Translation-en
Hit http://mirrordirector.raspbian.org wheezy/contrib armhf Packages
Get:10 http://mirrordirector.raspbian.org wheezy/non-free armhf Packages [49.3 kB]
Hit http://mirrordirector.raspbian.org wheezy/rpi armhf Packages
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Fetched 6,991 kB in 1min 7s (103 kB/s)
Reading package lists... Done
pi@raspberrypi ~ $
pi@raspberrypi ~ $
pi@raspberrypi ~ $
pi@raspberrypi ~ $
pi@raspberrypi ~ $
pi@raspberrypi ~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
cups-bsd cups-client cups-common dbus dbus-x11 gnupg gpgv libcups2 libcupsimage2 libdbus-1-3 libjpeg8 libsmbclient libwbclient0 libxml2 openssh-client openssh-server
rpi-update samba-common smbclient ssh tzdata
21 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.0 MB of archives.
After this operation, 65.5 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://archive.raspberrypi.org/debian/ wheezy/main rpi-update all 20140705 [4,408 B]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libxml2 armhf 2.8.0+dfsg1-7+wheezy1 [822 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libjpeg8 armhf 8d-1+deb7u1 [132 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libcupsimage2 armhf 1.5.3-5+deb7u2 [132 kB]
Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main cups-common all 1.5.3-5+deb7u2 [903 kB]
Get:6 http://mirrordirector.raspbian.org/raspbian/ wheezy/main cups-bsd armhf 1.5.3-5+deb7u2 [46.0 kB]
Get:7 http://mirrordirector.raspbian.org/raspbian/ wheezy/main cups-client armhf 1.5.3-5+deb7u2 [175 kB]
Get:8 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libcups2 armhf 1.5.3-5+deb7u2 [238 kB]
Get:9 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdbus-1-3 armhf 1.6.8-1+deb7u3 [153 kB]
Get:10 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libwbclient0 armhf 2:3.6.6-6+deb7u4 [92.1 kB]
Get:11 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libsmbclient armhf 2:3.6.6-6+deb7u4 [1,262 kB]
Get:12 http://mirrordirector.raspbian.org/raspbian/ wheezy/main ssh all 1:6.0p1-4+deb7u2 [1,248 B]
Get:13 http://mirrordirector.raspbian.org/raspbian/ wheezy/main smbclient armhf 2:3.6.6-6+deb7u4 [4,611 kB]
Get:14 http://mirrordirector.raspbian.org/raspbian/ wheezy/main samba-common all 2:3.6.6-6+deb7u4 [214 kB]
Get:15 http://mirrordirector.raspbian.org/raspbian/ wheezy/main gpgv armhf 1.4.12-7+deb7u4 [207 kB]
Get:16 http://mirrordirector.raspbian.org/raspbian/ wheezy/main gnupg armhf 1.4.12-7+deb7u4 [1,899 kB]
Get:17 http://mirrordirector.raspbian.org/raspbian/ wheezy/main tzdata all 2014e-0wheezy1 [458 kB]
Get:18 http://mirrordirector.raspbian.org/raspbian/ wheezy/main openssh-server armhf 1:6.0p1-4+deb7u2 [316 kB]
Get:19 http://mirrordirector.raspbian.org/raspbian/ wheezy/main openssh-client armhf 1:6.0p1-4+deb7u2 [952 kB]
Get:20 http://mirrordirector.raspbian.org/raspbian/ wheezy/main dbus armhf 1.6.8-1+deb7u3 [351 kB]
Get:21 http://mirrordirector.raspbian.org/raspbian/ wheezy/main dbus-x11 armhf 1.6.8-1+deb7u3 [58.2 kB]
Fetched 13.0 MB in 24s (536 kB/s)
Preconfiguring packages ...
(Reading database ... 70611 files and directories currently installed.)
Preparing to replace libxml2:armhf 2.8.0+dfsg1-7+nmu3 (using .../libxml2_2.8.0+dfsg1-7+wheezy1_armhf.deb) ...
Unpacking replacement libxml2:armhf ...
Preparing to replace libjpeg8:armhf 8d-1 (using .../libjpeg8_8d-1+deb7u1_armhf.deb) ...
Unpacking replacement libjpeg8:armhf ...
Preparing to replace libcupsimage2:armhf 1.5.3-5+deb7u1 (using .../libcupsimage2_1.5.3-5+deb7u2_armhf.deb) ...
Unpacking replacement libcupsimage2:armhf ...
Preparing to replace cups-common 1.5.3-5+deb7u1 (using .../cups-common_1.5.3-5+deb7u2_all.deb) ...
Unpacking replacement cups-common ...
Preparing to replace cups-bsd 1.5.3-5+deb7u1 (using .../cups-bsd_1.5.3-5+deb7u2_armhf.deb) ...
Unpacking replacement cups-bsd ...
Preparing to replace cups-client 1.5.3-5+deb7u1 (using .../cups-client_1.5.3-5+deb7u2_armhf.deb) ...
Unpacking replacement cups-client ...
Preparing to replace libcups2:armhf 1.5.3-5+deb7u1 (using .../libcups2_1.5.3-5+deb7u2_armhf.deb) ...
Unpacking replacement libcups2:armhf ...
Preparing to replace libdbus-1-3:armhf 1.6.8-1+deb7u1 (using .../libdbus-1-3_1.6.8-1+deb7u3_armhf.deb) ...
Unpacking replacement libdbus-1-3:armhf ...
Preparing to replace libwbclient0:armhf 2:3.6.6-6+deb7u3 (using .../libwbclient0_2%3a3.6.6-6+deb7u4_armhf.deb) ...
Unpacking replacement libwbclient0:armhf ...
Preparing to replace libsmbclient:armhf 2:3.6.6-6+deb7u3 (using .../libsmbclient_2%3a3.6.6-6+deb7u4_armhf.deb) ...
Unpacking replacement libsmbclient:armhf ...
Preparing to replace smbclient 2:3.6.6-6+deb7u3 (using .../smbclient_2%3a3.6.6-6+deb7u4_armhf.deb) ...
Unpacking replacement smbclient ...
Preparing to replace samba-common 2:3.6.6-6+deb7u3 (using .../samba-common_2%3a3.6.6-6+deb7u4_all.deb) ...
Unpacking replacement samba-common ...
Preparing to replace gpgv 1.4.12-7+deb7u3 (using .../gpgv_1.4.12-7+deb7u4_armhf.deb) ...
Unpacking replacement gpgv ...
Processing triggers for man-db ...
Setting up gpgv (1.4.12-7+deb7u4) ...
(Reading database ... 70611 files and directories currently installed.)
Preparing to replace gnupg 1.4.12-7+deb7u3 (using .../gnupg_1.4.12-7+deb7u4_armhf.deb) ...
Unpacking replacement gnupg ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Setting up gnupg (1.4.12-7+deb7u4) ...
(Reading database ... 70611 files and directories currently installed.)
Preparing to replace tzdata 2014a-0wheezy1 (using .../tzdata_2014e-0wheezy1_all.deb) ...
Unpacking replacement tzdata ...
Setting up tzdata (2014e-0wheezy1) ...
Current default time zone: 'Etc/UTC'
Local time is now: Sat Jul 19 08:09:56 UTC 2014.
Universal Time is now: Sat Jul 19 08:09:56 UTC 2014.
Run 'dpkg-reconfigure tzdata' if you wish to change it.
(Reading database ... 70614 files and directories currently installed.)
Preparing to replace openssh-server 1:6.0p1-4+deb7u1 (using .../openssh-server_1%3a6.0p1-4+deb7u2_armhf.deb) ...
Unpacking replacement openssh-server ...
Preparing to replace openssh-client 1:6.0p1-4+deb7u1 (using .../openssh-client_1%3a6.0p1-4+deb7u2_armhf.deb) ...
Unpacking replacement openssh-client ...
Preparing to replace dbus 1.6.8-1+deb7u1 (using .../dbus_1.6.8-1+deb7u3_armhf.deb) ...
Unpacking replacement dbus ...
Preparing to replace dbus-x11 1.6.8-1+deb7u1 (using .../dbus-x11_1.6.8-1+deb7u3_armhf.deb) ...
Unpacking replacement dbus-x11 ...
Preparing to replace rpi-update 20140321 (using .../rpi-update_20140705_all.deb) ...
Unpacking replacement rpi-update ...
Preparing to replace ssh 1:6.0p1-4+deb7u1 (using .../ssh_1%3a6.0p1-4+deb7u2_all.deb) ...
Unpacking replacement ssh ...
Processing triggers for man-db ...
Setting up libxml2:armhf (2.8.0+dfsg1-7+wheezy1) ...
Setting up libjpeg8:armhf (8d-1+deb7u1) ...
Setting up libcups2:armhf (1.5.3-5+deb7u2) ...
Setting up libcupsimage2:armhf (1.5.3-5+deb7u2) ...
Setting up cups-common (1.5.3-5+deb7u2) ...
Setting up cups-client (1.5.3-5+deb7u2) ...
Setting up cups-bsd (1.5.3-5+deb7u2) ...
Setting up libdbus-1-3:armhf (1.6.8-1+deb7u3) ...
Setting up libwbclient0:armhf (2:3.6.6-6+deb7u4) ...
Setting up libsmbclient:armhf (2:3.6.6-6+deb7u4) ...
Setting up samba-common (2:3.6.6-6+deb7u4) ...
Setting up smbclient (2:3.6.6-6+deb7u4) ...
Setting up openssh-client (1:6.0p1-4+deb7u2) ...
Setting up openssh-server (1:6.0p1-4+deb7u2) ...
[ ok ] Restarting OpenBSD Secure Shell server: sshd.
Setting up dbus (1.6.8-1+deb7u3) ...
[ ok ] system message bus already started; not starting..
Setting up dbus-x11 (1.6.8-1+deb7u3) ...
Setting up rpi-update (20140705) ...
Setting up ssh (1:6.0p1-4+deb7u2) ...

Now that basic configuration and update/upgrade is done, we can install VNC server/client to emulate Raspberry Pi's screen on your PC.

Fixing SSH locale problem: Raspberry Pi drive recorder with GPS logger

In my previous article I finished initial configuration with SSH login. This article helps to fix issues with language setting that occur during SSH login.

While I went through raspi-config in the previous step, I saw a lot of warning messages like below.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "ja_JP.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
view raw gistfile1.txt hosted with ❤ by GitHub
To fix this simply edit /etc/ssh/sshd_config and comment out "AcceptEnv LANG LC_*". My iMac is sending some language settings, but this modification will let my Raspberry Pi ignore it.

pi@raspberrypi ~ $ diff -u /etc/ssh/sshd_config.2014-07-19 /etc/ssh/sshd_config
--- /etc/ssh/sshd_config.2014-07-19 2014-07-19 07:22:27.407144977 +0000
+++ /etc/ssh/sshd_config 2014-07-19 07:22:46.766325295 +0000
@@ -71,7 +71,7 @@
#Banner /etc/issue.net
# Allow client to pass locale environment variables
-AcceptEnv LANG LC_*
+#AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
It's done.
Now we can update/upgrade Raspbian before going any further.

Initial SSH login and configuration: Raspberry Pi drive recorder with GPS logger

Installing Raspbian to SD card is done. In this article I cover how to boot Raspbian and finish initial configuration with SSH login.

After successfully installing OS to your SD card, now it's time to stick this to your Raspberry Pi and do the initial configuration. Connect LAN cable to Raspberry Pi, insert the SD card to it and connect power cable. Raspberry Pi starts up and several seconds later it can be accessed with ssh. IP address should be found with iNet or some other equivalent app/method. Initial username and password are set to pi and raspberry.
Oklahomer@Oklahomers ~ » ssh pi@192.168.0.3
pi@192.168.0.3's password:
Linux raspberrypi 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'

raspi-config

Do `sudo raspi-config` and start configuration. When you hit `sudo raspi-config` you will see a console like below.


1. Expand Filesystem

Usually you wanna expand filesystem. The OS distribution images are normally around the size of 2GB and when your SD card has unused portion, it will expand to fill the rest of the SD card so you can use more space. If you can't find any particular reason not to do this, you should do this. You must reboot before enabling this modification.

2. Change User Password

It changes password for pi user. As I wrote above, the initial password is set to raspberry. You should change this.

3. Enable Boot to Desktop/Scratch

I left it with default value.

4. Internationallization Options

Locale

en_GB.UTF-8 is sellected as default so I unchecked this and checked en_US.UTF-8. You hit space key to switch. Then hit Tab and choose OK.

Timezone

Since I visit a lot of places including Japan, the U.S., Australia and other countries for road trip, it's kind of pointless to set a particular timezone. And my GPS module gives me UTC time so I chose 'None of the above > UTC', anyway.

Change keyboard layout

I used U.S. keyboard so I didn't have to do anything about it.

5. Enable Camera

Default is 'Disabled', but this project is going to use camera for sure so I enabled it.

6. Add to Rastrack

It has nothing to do with my project, but it's fun. You might wanna do it when you have internet connect now.

7. Overclock

No.

8. Advanced Options

Some advanced settings. For this project, make sure SSH and SPI are enabled.

It's done. When you choose to finish, it asks you if it should reboot now. To activate changes you should let it reboot. After reboot, it's all activated. During this configuration process, you might have seen some warning messages like below.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "ja_JP.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
view raw gistfile1.txt hosted with ❤ by GitHub
If so, you can change some setting with the next article. If you didn't have trouble you can ignore the next one and go on to update/upgrade Raspbian.

Installing OS: Raspberry Pi drive recorder with GPS logger

On my previous article I described why I'm working this project and what this project goal is. This article covers how to install OS and get your Raspberry Pi ready to boot.

To install OS, you need to get an SD card or Micro SD card with adaptor. You are going to install your choice of OS image to it and stick this SD card to Raspberry Pi. Some starter kits offer Raspberry Pi with OS installed SD card. It's easy to get started with one of those, but as you work on your project you'll want to make a copy of your OS image before making a huge modification. You don't wanna mess up your entire work and start all over again, right? So sooner or later you'll have to know how to install OS on your SD card and make copies of it. I think it is nice to learn it at first place.


I did it with the items below:
I also recommend:

1. Download OS Image

Visit official download page and download the latest version of Raspbian. There are some other distributions listed on that page, but I think choosing Raspbian is the easiest for beginners since we can find many reference articles on the web. I downloaded the .zip archived file. We are going to unzip and install this OS image to the SD card.

2. Unmount SD Card

Insert your SD card to iMac and launch terminal. Type `df -h` and see what appears. When I did it SD card wasn't recognized so I launched disk utility and formatted this card. Then hit `df -h` and the file systems show up like below. Check which to unmount and do `sudo diskutil unmount /dev/********`. '********' should be replaced depending on your environment. You should remember what this device name was since you are going to use it later.

Oklahomer@Oklahomers ~ » df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk0s2 931Gi 556Gi 375Gi 60% 145733288 98247454 60% /
devfs 186Ki 186Ki 0Bi 100% 644 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk1s2 59Gi 150Mi 59Gi 1% 38290 15352162 0% /Volumes/Raspberry Pi
Oklahomer@Oklahomers ~ » sudo diskutil unmount /dev/disk1s2
Password:
Volume Raspberry Pi on disk1s2 unmounted

3. Flash disk image

After unmounting your SD card on the previous step, it won't appear on `df -h` again. You unzip your downloaded OS image and then flash this to the unmounted SD card with dd command. On dd command you must be careful what you give to 'of' because it is a bit different from what you remembered on the previous step. You need to omit the last 's1' and replace "disk" with "rdisk". e.g. '/dev/disk1s1' becomes '/dev/rdisk1'. This process may take a while and this doesn't give us visual feedback to indicate progress so you must be patient.

Oklahomer@Oklahomers ~ » df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk0s2 931Gi 556Gi 375Gi 60% 145733311 98247431 60% /
devfs 186Ki 186Ki 0Bi 100% 644 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
Oklahomer@Oklahomers ~ » cd ~/Downloads
Oklahomer@Oklahomers ~/Downloads » unzip 2014-06-20-wheezy-raspbian.zip
Archive: 2014-06-20-wheezy-raspbian.zip
inflating: 2014-06-20-wheezy-raspbian.img
Oklahomer@Oklahomers ~ » sudo dd bs=1m if=/Users/Oklahomer/Downloads/2014-06-20-wheezy-raspbian.img of=/dev/rdisk1
Password:
2825+0 records in
2825+0 records out
2962227200 bytes transferred in 273.245411 secs (10840904 bytes/sec)
Oklahomer@Oklahomers ~ » df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk0s2 931Gi 558Gi 372Gi 61% 146458697 97522045 60% /
devfs 187Ki 187Ki 0Bi 100% 646 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk1s1 56Mi 9.5Mi 46Mi 17% 512 0 100% /Volumes/boot
Installing OS is done now so you can eject SD card and stick it to Raspberry Pi. If you are going to bring your Raspberry Pi with you like I do, I really recommend you to buy a low-profile Micro SD adaptor for Raspberry Pi.

Now we are going to boot Raspberry pi, connect with SSH and finish initial configuration.

Introduction: Raspberry Pi drive recorder with GPS logger

Every year my wife and I go on a road trip with no detailed schedule or motel reservation; Just book our flight and rental car and the rest is up to us. Last time we started from L.A. airport, stayed one night at Las Vegas and won $15 at casino, stopped by some national parks, visited our college in Oklahoma, saw rodeo in Fort Worth and arrived at Dallas/Fort Worth airport.


We usually drive 2000 to 3000 miles in a week, which means we must spend most of the time in a mid-class rental car. We don't have time to pull over every time when my wife finds some fancy view. So, before the last trip in June, I came up with the idea of having a drive recorder record everything. If it works, we can concentrate on what we see and don't have to do something nonsense like looking into a tiny camera finder right in front of a great wilderness passing by.


It, however, didn't work well. I bought a cheap drive recorder with GPS module to start with, but it broke in 2 days. It was a shock. A tool that must have assisted my annual trip just became a piece of junk in a couple of days. This night at Anasazi Inn, my second idea came up: making a drive recorder myself.

After this trip I searched on the web and found out that Raspberry Pi and some handy peripherals can make cheap drive recorder with GPS logger. Raspberry Pi itself and peripherals are less expensive and easily obtainable so even when something breaks I can fix it myself, which I think is a great advantage after experiencing that terrible breakage.

I named my project Odyssey. I thought it would make perfect sense thinking about our unplanned annual trip. My favorite part is that Odyssey is attributed to Homer while my name is Oklahomer and people call me Homer. Coincidence? I don't think so.

This project includes features below:
  • Photo taking
  • Video/audio recording
  • GPS logging
  • Live preview
Later articles will cover my project. They should help beginners get used to Raspberry Pi since I am one, too. In next article we install Raspbian OS to SD card with Mac OSX.