Return to Robotics Tutorials

Installing PiTFT on Raspberry Pi for GUIslice

This page details a step-by-step guide involved in setting up the Raspberry Pi with a PiTFT for use with the GUIslice library. The following walkthrough has recently been tested on a 2.8" PiTFT with the Raspberry Pi 3 but is expected to work on other versions as well.

Create a Boot Image

  • Download the JessieLite image
  • Burning boot image to SD card
  • Format the SD memory card
  • Burn boot image to SD card
    • Use Win32DiskImager
    • You may need to run with Administrator privileges, otherwise you may see an error: Unable to execute file: and CreateProcess failed; code 740. The requested operation requires elevation. In Windows 10, find the application, right-click on it and select Run as Administrator.
    • Select the image file, ensure the correct memory card device is selected and click Write.

Boot Up & Reconfiguration

PiTFT Boot Console
  • Connect up Pi TFT to Raspberry Pi (on GPIO headers)
  • Connect a USB keyboard to the RPi
  • Insert the imaged memory card into the RPi and power-up
  • During boot, you should see the PiTFT displaying the console boot log, but with the majority of the text cut-off due to the low resolution of the PiTFT -- this is expected. The reduced resolution willl make some of the following steps a bit more challenging until we have added WiFi access (wherein we can start logging in from our desktop PC with a full sized terminal screen).
  • You may see one line that reads [FAILED] Failed to start Config...UART, this is expected with this build.
  • With the external keyboard attached, log in with username: pi and default password: raspberry.
  • raspi-config on PiTFT
  • Assuming that you don't live in the UK, you will probably want to change the localization (country) settings. Otherwise you may find that your US keyboard appears to have remapped / changed a number of keys! For example " becomes @, @ becomes " \ becomes #, etc.
    • Enter the configuration system with sudo raspi-config
    • A full guide of how to change the localization / internationalisation settings to US can be found here.
    • Note that it may be harder to view these settings since the display has clipped some of the content due to the reduced resolution.
    • Reboot to see the new settings take effect. A reboot can be done with sudo halt -r now

How to Enable WiFi access to WLAN on Raspberry Pi

The following optional step enables you to control the Raspberry Pi from a remote device (such as a desktop PC or iPhone). By connecting to the RPi remotely, one can access the console (via SSH) with a much larger text windows, enable file download, installations and transfers between your computer and the RPi (via SCP, FTP or SFTP). This seciton assumes that you already have a wireless router configured.

This section also assumes that you are familiar with editing files in LINUX. The examples use the vi command, but those less familiar with LINUX may prefer other editors such as nano.

The wireless configuration here will set up a static IP address (rather than the default dynamic IP address). This should make future attempts at connecting to the Raspberry Pi much easier.

  • Edit wpa_supplicant.conf
    This file defines the wireless network and password that we will need to connect.
    • cd /etc/wpa_supplicant/
    • sudo cp -p wpa_supplicant.conf wpa_supplicant.conf.orig
    • sudo vi wpa_supplicant.conf
      • We will want to add the following text to the end of the file:
      • network={
            ssid="myssid"
            psk="mypassword"
            key_mgmt=WPA-PSK
        }
      • In the above, substitute myssid with your local WLAN ID (SSID) and mypassword with your wireless password.
    • Edit interfaces
      This file defines the wireless network card configuration. The steps below will change the RPi to use a static IP address instead of the dynamic (DHCP) IP address that is used by default. The benefit of a static IP address is that it becomes much easier for other devices to connect (eg. for SSH, FTP, etc.) as with dynamic IP addresses one must first determine which address was assigned.
      • cd /etc/network
      • sudo cp -p interfaces interfaces.orig
      • sudo vi interfaces
        • Comment out the following line by inserting a # at the start of the line:
          iface wlan0 inet manual
        • Add the following after the above commented-out line:
        • iface wlan0 inet static
          	address 192.168.1.196
          	netmask 255.255.255.0
          	gateway 192.168.1.1
        • The above attempts to assign a static IP address of 192.168.1.196 to the Raspberry Pi. Depending on your WLAN configuration, you may need to adjust the addresses accordingly.
    • Reboot
      sudo shutdown -r now

Testing Wireless Access from Raspberry Pi

Now that you have reconfigured the Raspberry for wireless access, it is important to confirm that it can indeed access the network.

  • Read IP address from ifconfig
    ifconfig wlan0 | grep "inet addr"
    The above command should report out the IP address assigned to your network interface. In most cases it should match the static IP address we requested above.
  • Read web page from Internet
    An easy test to confirm wireless access to the internet (before attempting to install/update packages on the RPi is to fetch a webpage such as google.com. This can be done with the following command. Note that the output will contain the raw HTML output from the Google homepage, so it is not expected to be readable.
    wget google.com

Connecting to Raspberry Pi via SSH

Now that wireless access is available, we can switch over to using a TTY terminal from a desktop computer. This allows for larger editing windows in a familiar environment (rather than trying to edit within the limited PiTFT resolution window).

  • Run PuTTY with the server set to the IP address seen in the ifconfig line above
  • Don't be surprised to see a PuTTY Security Alert appear. It may read: "The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is." This is an expected warning the first time you connect to your RPi via SSH. Click on Yes to save this connection information for future sessions.

 


Reader's Comments:

Please leave your comments or suggestions below!

 


Leave a comment or suggestion for this page:

(Never Shown - Optional)
 

Visits!