Thursday 20 June 2013

Running the Raspberry Pi from another PC using the Pi Console

In my previous post I explained how to connect to the GPIO serial port so that the another computer can be connected to the Raspberry Pi either directly using its serial port or via a USB to serial interface (I've used both methods and the end result is the same). This opens up the possibility of running the Raspberry Pi remotely via the Pi console, but to do this requires some software to be installed on the host computer.

For Windows users...

If you're running Windows XP (or earlier) you should already have a program called "HyperTerminal" which you can use but I'll assume you are running a later version of Windows...

I would suggest you download and install PuTTY (available here), but there are other similar programs you could use. When you install and run PuTTY you should see the following screen:


Change the "Connection type" to "Serial" and then specify the serial port you want to use (in my case COM1) and set the speed to 115200. Note that if you are using a USB to serial interface connected to your host computer you'll probably need to have a look at "Devive Manager" to see what port number has been assigned to it. If you are using a physical serial port then it's probably going to be COM1 or COM2.


OK, once you've specified the com port and speed click on "Open" and you should see a blank console window (remember the Raspberry Pi isn't connected yet!):


With your Raspberry Pi powered down, connect it to the host computer by plugging the female 9 pin D connector (see my previous post...) into a free serial port, or into a USB to serial interface if you're using one. Now power up your Raspberry Pi. You should see the now familiar boot up text scrolling up the console window, and eventually you should be prompted to login:


Notice the line just above the login prompt - the address "ttyAMA0" refers to the serial interface on the GPIO header. Go ahead and login as normal and you'll get to the command line interface, just as you would when working directly on the Raspberry Pi.


For Linux users...

Again, I would suggest you download and install PuTTY from your repository, but there are other similar programs you could use. When you've installed PuTTY, login to your Linux system and type "groups" at the command line prompt and press Enter:

tom@mylaptop: ~ $ groups_

Please note that my username is "tom", and my Linux system is called "mylaptop" - you will obviously see your own user and system names here. The "groups" will display a list of groups which you (as a user of the system) belong to. Look for one called "dialout". If it isn't listed type the following at the command line prompt and press Enter (remembering to replace "tom" with your username):

tom@mylaptop: ~ $ sudo usermod -a -G dialout tom_

This will add you to the "dialout" group which is a necessary requirement for you to use PuTTY. Now launch the PuTTY application. Change the "Connection type" to "Serial" and then specify the name of the serial port you want to use. If you are using a physical serial port the port name should be "/dev/ttyS0" (or "/dev/ttyS1" if you have more than one physical serial port). If (like me) you are using a USB to serial interface the port name should be "/dev/ttyUSB0". Finally set the speed to 115200:


Now click "Open" to connect to the serial port, and you should see a blank console window. Proceed as described above for Windows users (i.e. connect your Rasperry Pi and power it up), and you should be able to login to your Raspberry Pi from your Linux system.

So now what?

Well you can use the command line interface on your Raspberry Pi as you normally would, although the interface will be text only (no graphics). You won't be able to use the GUI by entering the "startx" command, but who needs a graphical user interface anyway....

It does make your Raspberry Pi a lot more portable when you don't have a keyboard, screen and mouse connected to it. The only connections you need are a power source and the serial connection, which consists of only three wires.

I took advantage of this portability and took my Raspberry Pi outside and placed it in front of my cat's bowl and waited until he came to feed. I was then able to remotely take photos of him eating out of his bowl using the Raspberry Pi camera module.


In my next post I'll take the portability one stage further by using a wireless serial link.

2 comments:

  1. I am getting the boot-up messages, but not the login prompt.

    ReplyDelete
    Replies
    1. It sounds as if you may have disabled console access. Have a look at the file /etc/inittab and make sure that the following line appears in the file:

      T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

      If there is a "#" character at the beginning of the line delete it, save the file, and reboot your Raspberry Pi.

      Delete