Skip to content

Auto-Launch Raspberry Pi Apps

For XDC 2016 I needed a way to demonstrate a Raspberry Pi app that used the GPIO and updated an LCD character display. But I didn’t really have access to a screen that I could use to show the desktop so that I could run the app. And I could not remotely connect to the Pi because I did not have a good way to get it on the wifi network in the first place.

I decided what would work for me is to have demo app automatically launch when the Pi boots. This would allow me to demo the app and project anywhere just by plugging in the Pi. There are several ways that a Pi can automatically start an app. After doing a bit of Google research I decided on this approach:

  1. Open the /etc/rc.local file (you’ll want to use sudo):
    sudo nano /etc/rc.local
  2. Add lines to automatically start the app you want. My app was a console app that used GPIO, so I added these two lines:
    export WIRINGPI_GPIOMEM=1
    /home/pi/Documents/Xojo/LCDPanel &

For reference, this is my rc.local file contents:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
 printf "My IP address is %s\n" "$_IP"
fi

export WIRINGPI_GPIOMEM=1
/home/pi/Documents/Xojo/LCDPanel/LCDPanel &

exit 0

You can develop and build console and desktop apps for the Raspberry Pi using Xojo 2019r1 or later for free.

Download Xojo today and get started!

Fun times at XDC: