Saturday, February 1, 2014

Connecting to Pi from Laptop's Ethernet Port

One of the aspects of Raspberry Pi that makes it incredible useful is its size. Due to its compact size, Pi can be used to provide computing power at locations where it would be impractical to locate a full desktop or laptop. Often the Pi is run as a headless unit, ie there is no monitor or keyboard connected to the Pi. All troubleshooting is done by connecting to the Pi over the network using SSH or any of the remote desktop protocols. However, there could be various scenarios, especially in outdoor projects, where there is no network connectivity. You still need to be able to connect to the Pi from a laptop for troubleshooting purposes. This post describes how you may connect to Pi from a Windows 7 laptop by connecting an ethernet cable from laptop's ethernet port to Pi's ethernet port. We utilize a feature of Windows 7 called we called internet connection sharing (ICS) to easily connect to the Pi. It is my understanding that internet connection sharing is a feature that is built into most linux desktop distributions and Mac OS. Therefore, you should be able to perform steps similar to the one described below, if you are attempting to connect to the Pi from a linux laptop and Mac OS.


Setup the Pi to run as a headless unit as described in Setting up truly portable Raspberry Pi System
A laptop with wireless network card and ethernet port

The true purpose of internet connection sharing is to share the internet connection of the laptop with a device connected through the ethernet port. We enable this feature so that your Windows 7 laptop will act as DHCP server and the Pi can automatically obtain an IP address from the Windows 7 laptop. The primary benefit of this approach is that one does not have to manually set any IP addresses or gateways on the laptop or the Pi. Therefore, this method is much less error prone. As an added bonus, the Pi also gets the share the internet connection of the laptop, if the laptop is connected to the internet through its wireless card.

Steps to enable internet connection sharing:

1) Connect the ethernet port of the laptop to the ethernet port of Raspberry Pi.
2) From the start menu on the laptop, search for "View Network Connections" and open it as shown below.

3) Atleast two network connections should be visible as below. One indicates you wireless network connection and the other indicates the ethernet connection. Right-click on the wireless network connection and select "properties".

4)  In the properties window, select the "Sharing" tab. Select both checkboxes, and click "OK".

5) Restart your laptop. Restarting is important as I have never got the internet sharing to work without restarting the laptop. The Pi will be automatically obtain an IP address from the DHCP server on the laptop upon restart.

In order to connect to the Pi using SSH, you need to know the IP address that is assigned to the Pi. You can easily find this out using the command

ping <hostname>

The default hostname of Raspberry Pi is "raspberrypi" . I have changed the hostname to "trasparent". See the IP address of the Pi received as a response to the ping command.

More details about finding the dynamically assigned IP address from any OS is described in the post Setting up truly portable Raspberry Pi System


Some users may have multiple network connections on your laptop. In that case you will have a drop down in the sharing tab of the wireless network connection. Make sure you select the Local Area Connection to which you have connected the Pi.

If you don't see the drop down or an incorrect connection is selected, you might have to uncheck the check boxes in sharing tab and restart and repeat the steps to see the drop down and select the right connection. 

Monday, August 12, 2013

Setting up a truly portable Raspberry Pi system

One of the salient features of Raspberry Pi is its portability. Being credit card sized, it is as portable as a smartphone. But it doesn’t have a built-in display, input mechanism, wifi connectivity or battery like a smartphone. After you plug in a monitor, keyboard, mouse, network cable and a power cable to the Pi, you lose most of the portability benefits. You can regain most of the portability benefits by setting up your Pi as a headless unit. In a headless setup, you do not have to plug in a monitor, keyboard or mouse. If you attach a wifi dongle you don’t even need the network cable. Just plug in the power cable and you are good to go. If you want complete portability you can even attach a small battery pack to Raspberry Pi case.

So how do you operate the Raspberry Pi computer without attaching any of the peripherals. The solution is remote access. You access the Pi through the network and make all changes through a shell or a remote desktop. You will have to connect all the peripherals like the monitor, keyboard, mouse and network cable for initial setup. But after you have setup your Pi correctly, you can connect your Pi to any network and control your Pi from any computer in the network.

Steps to setup Raspberry Pi for shell connectivity

1) Open a terminal and type

sudo raspi-config

It will open a nice config tool that allows you to configure various aspects of your Raspberry Pi system.

2) Enable SSH server
3) Connect to Raspberry using an SSH client.

There are various articles on the internet that describe how to connect to a linux system using an ssh client. Mac and Linux systems have built-in ssh clients. So it is as simple opening a terminal on your Mac and typing the command 

ssh <username>@<ip-address>

where username is the name of the account on Pi you are trying to connect to and ip-address is local IP address of your Pi. On windows systems, you can use the Putty tool as your ssh client.

You can find the local IP address of your Pi system using the command ifconfig. After you have tested ssh connectivity, you need to establish a mechanism to find the IP address of your Pi without a monitor attached. One solution would be to assign a static IP address to the Pi as described in Step 2 of this guide. But as the guide explains, this method is suitable only if you keep your Pi plugged into the same network all the time. But since our goal is a truly portable system, we need to keep the DHCP mechanism to obtain IP address and connect to the network. A flexible way to find the IP address of Pi system is to lookup the IP address by hostname.

IP Address lookup by Hostname

You can find the hostname of your Pi using the command


It would be a good idea to assign a unique hostname to your Pi to avoid hostname conflicts when you connect your Pi to different networks. This guide describes how to change the hostname of your Pi.

After you have assigned a unique hostname, install the samba server on your Pi. The samba server may be installed using the command

sudo apt-get install samba

Installing samba server allows windows clients to lookup the IP address by hostname.

To find the IP address of your Pi from windows or linux system, type the command

ping <hostname>

From a Mac system, type the command

ping <hostname>.local

The IP address will be returned in the response.

Connecting to Raspberry Pi Remote Desktop

While shell connectivity is sufficient to get most things done on the Pi, sometimes it is nice to have a GUI. You can achieve this by setting up remote desktop server on your Pi. Here is a guide to setup remote desktop on your Pi. In summary all you need to do is install the xrdp sofware using the command

sudo apt-get install xrdp

You may then use the IP address of Pi to connect to the remote desktop of Pi. On Windows systems you may use the built-in windows remote desktop connection tool to connect to remote desktop. On Mac systems you can install the remote desktop client for Windows. On Linux systems you may use any of the rdp clients such as Remmina or the Vinagre RDP client.

Thursday, February 28, 2013

Picasa for AVCHD

Google's Picasa software is very good for finding and organizing your picture and video collection. However, it doesn't natively AVCHD format for videos. The solution is to install K-lite codec pack that will add the necessary codecs for Picasa to read the AVCHD files.