/ Software

X11 Forwarding with RPi, PuTTY, and Android

I have a particular need to use my Raspberry Pi as a headless system while still getting information from a GUI application. There are plenty of tutorials for using VNC or ssh with X Forwarding to accomplish this, but for my situation I needed:

  1. The Raspberry Pi to remain headless (not connected to a display)
  2. To edit and execute python scripts
  3. A way to see the GUI generated by those python scripts (hard to do without a display)
  4. Monitor the image onscreen near the headless unit (very hard to do without a display)

With these needs in mind, VNC and X11 forwarding to my stationary computer were not going to work. I found a tutorial on X11 forwarding using JuiceSSH and an X11 server app on my Android phone, but the port forwarding setup never seemed to direct it back to the device properly, and I would have had to rely on using the soft keyboard to start the python script each time anyway.

While going back through the motions of setting up X11 forwarding in PuTTY, I thought about what would happen if I forwarded to someplace other than my desktop.
As it turns out, that gave me exactly what I needed to work in my situation.

I'll walk you through how I did that:

*Disclaimer, this is geared towards windows users with android phones. As in it won't work for anybody with any other combination of devices.

  1. Download the X server application from Google Play .
  • Once installed, open the application and wait for the blue screen to show up with your device's info.

Android X Server window

  • Open up PuTTY on your Windows machine.
  • Fill in the Host Name field with your Pi's IP address.

Raspberry Pi IP address

  • Configure PuTTY to forward all X11 traffic to your Android phone by entering the IP address shown after the DISPLAY= on your phone (include the display number after the colon, as shown below)

Forwarding Config

  • Open the connection (or click back to the Session screen to save it as a preset) and log in to your pi.
  • Type startlxde & in the command line and wait for all of the warning messages to flood through and the Raspberry Pi's desktop to appear on your phone. In case you are wondering if/why the ampersand is important - This instructs the system to execute the command in the background. This allows you to continue typing commands even if the last one is still running.
  • Run any command you want, and have the GUI appear on your phone. If the command you run has no GUI element to it, it will not show up on the screen. If the command you run has a GPU dependent GUI, it probably won't work. Here is an example of a pygame application started over SSH.

This pygame application was sent all over the place

  • Check out the configuration options of the X server on the Google Play page. There are steps to turn off the annoying mouse gyroscope control there. To change the screen resolution/text size, restart the app and tap on the black loading screen when prompted.

That should get you started in viewing your Raspberry Pi X session on an Android phone. The benefits of this procedure are:

  • Versatility of a physical keyboard
  • Access to Windows at your desk/couch/wherever
  • Mobility of the display

A great guide on using PuTTY to forward X11, which this was based off of, can be found on the UT Dallas wiki.