starting a Processing+Fadecandy script on startup with a Raspberry Pi

836 views
Skip to first unread message

Ben Mesiti

unread,
Feb 9, 2015, 8:05:45 AM2/9/15
to fade...@googlegroups.com
Hi all,
I've written a basic processing sketch for the fadecandy on my raspberry pi B+.

I exported the script as an application, which works as expected when started from the console.

For the LED installation I'm building, I need the RasPi to be headless, so the script needs to run automatically at startup.

I've tried everything I can google: init.d script, rc.local, lightdm.conf and a few others. Nothing seems to work as I need it to.

I can get it to start but it seems to run in the background, or it only starts when I SSH in. My linux is pretty rusty so can't figure out exactly whats wrong.

Does anyone have a sure fire way to start a script automatically, so the fadecandy outputs correctly?

I'm running the latest rasbian, processing 2.2.1, java 1.8.0

Thanks in advance

Ben

Steve Upton

unread,
Mar 8, 2015, 3:59:30 AM3/8/15
to fade...@googlegroups.com
Did you get this working? I need to do the same.

Steve

Matt Pinner

unread,
Mar 8, 2015, 8:11:19 AM3/8/15
to Steve Upton, fade...@googlegroups.com
i've had some success with this technique:

any luck? what are you seeing?

--matt

On Sat, Mar 7, 2015 at 11:59 PM, Steve Upton <ste...@gmail.com> wrote:
Did you get this working? I need to do the same.

Steve

--
You received this message because you are subscribed to the Google Groups "Fadecandy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fadecandy+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nickw...@gmail.com

unread,
Apr 28, 2015, 12:29:05 PM4/28/15
to fade...@googlegroups.com, ste...@gmail.com, mpi...@gmail.com
I am trying to get a processing app to run on a headless pi automatically when it is turned on.

I can get it to run from ssh by running

#!/bin/bash

tightvncserver :42

export DISPLAY=:42

cd /home/pi/oilyMidiControllerListMidi/application.linux32/

sudo ./oilyMidiControllerListMidi &

cd /


Using the link you provided I have executed this file using cron, added a link in cron to the profile file in the home folder to define stuff
gives me USER not defined
adding USER=:pi gets me closer, now I get error 

You will require a password to access your desktops.


Password: Password too short


so  I need a way to supply a password for the vnc screen (I know what it is, but not how to supply it here)


SO tantilisingly close

nickw...@gmail.com

unread,
Apr 29, 2015, 3:56:54 AM4/29/15
to fade...@googlegroups.com, ste...@gmail.com, mpi...@gmail.com
I managed to get it working.

contents of the file are now

#!/bin/bash


su -l pi -c tightvncserver 

export DISPLAY=:1

su -l pi -c <fullpathtoapp> &


Not using anything with graphics with the one I have got to launch so far, but it is hooking up to the vnc instance so is able to launch as it still opens a small window. Successfully reading a Numark orbit, controlling its lights and sending data over OSC to another computer. Now on to the two pis that control the lights to try out there.

nickw...@gmail.com

unread,
Apr 29, 2015, 4:08:18 AM4/29/15
to fade...@googlegroups.com, ste...@gmail.com, mpi...@gmail.com
path to the file can be relative to the home folder of the user pi (replace pi with name of user if you are using a different user account)

Steve Upton

unread,
Apr 29, 2015, 12:18:03 PM4/29/15
to nickw...@gmail.com, fade...@googlegroups.com, mpi...@gmail.com
So this works whether you have something that is displaying the window or not? My thought is most of the time I just want to see the pattern on the LED display but for debugging it would be useful to see the window. 

Steve


Eric Lin

unread,
May 7, 2020, 2:33:56 AM5/7/20
to Fadecandy
Did you ever get this working?

Carter Hickman

unread,
Sep 11, 2020, 9:53:15 AM9/11/20
to Fadecandy
I have done this a couple times, and it was quite a process to figure it out. Processing is a little bit harder than a typical start upon boot program for Pi's because it relies on the GUI booting up before the program is called. The reason rc.local and other startup procedures don't work is because they all are called before the GUI finishes booting.

 You need to create a .desktop file that calls a python script, and that python script calls the processing program to start (convoluted, I know) From what I've researched, this is the only way to do this. You also need to turn HDMI_hotplug on if you're using the GUI on your Pi without the Pi actually connected to a monitor. Go to /boot/config.txt. Open the text file and find the command  "hdmi_force_hotplug=1". Uncomment this command. This forces your Pi to think it is connected to an HDMI. Since processing maps from the screen, we had to emulate the HDMI connection to trick the Pi into thinking the GUI is there. 

The contents of the desktop file should look like this: 

 [Desktop Entry]
Type=Application 
Name=StartUp 
Exec=/usr/bin/python3 /home/pi/Desktop/StartUp.py    
#Obviously  at execute you would put the file path to your python script. 

Your python file should look like this 

import os # Use operating system
import subprocess # Use subprocess calls from time
import sleep # Use sleep 
os.system('cd /home/pi/Desktop/LaserCannonProcessing/fadecandy-master/bin && sudo ./fcserver-rpi server.json')     #Here I am starting the fadecandy server. Again, obviously you will use your own file path. 
sleep(5) #Sleep time in seconds  
child = subprocess.Popen('sudo processing-java --sketch=/home/pi/Desktop/LaserCannonProcessing/LaserCannonProto --run', shell=True) # Open a new terminal and run the processing file. Use your own file path 

You don't need to export the processing file to an executable. Hope this helps 

Carter

Julian Butler

unread,
Sep 12, 2020, 5:44:53 AM9/12/20
to Fadecandy, Carter Hickman
Hey I went through this problem too. During the development of my lava lamp I needed to run Processing headless on a Rasp Pi, talking to fadeCandy.
I ran into the same issues with attempting to launch Processing before the GUI was fully present.

I ended up using the solution posted here: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=219952 

If you want to read about this project in more detail it’s here in 3 parts:  https://blog.julianbutler.com/2018/12/my-digital-lavalamp-or-mki-epilepsy.html

Good luck and I hope it worked out for you.

-julian

stephenfo...@gmail.com

unread,
Feb 10, 2021, 12:38:14 AM2/10/21
to Fadecandy
Carter -- THANK YOU.   I'm trying to get a Processing sketch to run on boot on a (soon to be) headless Pi -- UNDER A DEADLINE -- and your post saved my life.
Reply all
Reply to author
Forward
0 new messages