Jul 19, 2014

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?


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.
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.

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.

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.
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.

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.

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.

May 5, 2014

Failed plenv install-cpanm and ended up installing curl with --with-openssl option

Today I tried `plenv install-cpanm` and it failed. I do remember it worked fine a couple of month ago and the only thing I can think of was that I did `yum update openssl` last month. I'm pretty sure I didn't do anything else nasty.

I searched and found someone with same problem. I followed what he did as shown below: Then I succeeded to run plenv install-cpanm
% plenv install-cpanm      
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   303    0   303    0     0    509      0 --:--:-- --:--:-- --:--:--  7973
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  262k  100  262k    0     0   113k      0  0:00:02  0:00:02 --:--:-- 3012k
--> Working on App::cpanminus
Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7004.tar.gz ... OK
Configuring App-cpanminus-1.7004 ... OK
Building and testing App-cpanminus-1.7004 ... OK
Successfully installed App-cpanminus-1.7004
1 distribution installed

May 3, 2014

Facebook::OpenGraph Ver.1.21 supports API versioning

On 2014-04-30 Facebook announced API versioning to improve its stability. Each version is guaranteed to work 2 years so we do not have to be afraid of 90 day breaking change policy anymore. The version we were using prior to this introduction is called version 1.0 while the new version introduced along with API versioning policy is called version 2.0.

Versioned Request

Making versioned request is pretty easy. Just like other major platform APIs, you prepend version number to the end point like below:
/v2.0/me/friends
Unversioned request is also supported. Just don't prepend version number and it's considered "unversioned." The document says "An unversioned call will default to the oldest available version of the API," but here is one tricky part:
For apps that existed before April 30th 2014, making an API call without specifying a version number ('unversioned') is equivalent to making a call to the v1.0 of the API.
For apps created on or after April 30th 2014, making an API call without a specifing a version number is equivalent to making a call to v2.0 of the API.
So when you are making unversioned request, just be careful when the request app was created.

Facebook::OpenGraph 1.21

I implemented versioning support to Facebook::OpenGraph and launched it as Ver. 1.21. This change is backward compatible. If you update module and don't make any change to your code it makes unversioned request, which is exactly the same as previous version of this module.

API Versioning

With this version, you can specify default version on initialization as follows:
my $fb = Facebook::OpenGraph->new(+{
    app_id  => 12345,
    secret  => 'qwerty',
    version => 'v2.0',
});
If you don't specify any version,  version is left undef and each request becomes unversioned request.
You can still set version on each request by specifying versioned path such as /v1.0/me/friends. This will override the version configuration given on initialization.
my $fb = Facebook::OpenGraph->new(+{version => 'v2.0'});
$fb->get('/zuck');      # Use version 2.0 by accessing /v2.0/zuck
$fb->get('/v1.0/zuck'); # Ignore the default version and use version 1.0
 
my $fb = Facebook::OpenGraph->new();
$fb->get('/zuck'); # Unversioned API access since version is not specified
                   # on initialisation or each reqeust.

Dialog Versioning

Facebook Platform also supports dialog versioning. If you specify version -- let's say v2.0 -- on initialization, $fb->auth_uri() will return versioned Login dialog URL like https://www.facebook.com/v2.0/dialog/oauth.

If you have any enhancement idea, bug fix or question. Feel free to add an issue.