autonomously projecting stuff sent from a remote computer by lucien bobo

Project : Autonomously projecting fancy stuff (say, text) sent by a remote computer (through the internet)

In the framework of a internship at in|situ|, I prototyped remote communication interfaces. This one allows transmitting text from a PC application (developped with Processing) to an autonomous projecting system (made of a tiny videoprojector and a Raspberry Pi, where another Processing application runs)

Step 1 : Installing Raspbian, connecting the Raspberry to the internet, and installing Processing on it
The use the Raspberry Pi, I installed the dedicated Raspbian operating system, following these instructions :
To have it able to connect to the internet, I had to declare its MAC address to the lab's staff and connect it to the network with a RJ45 wire.
Then, I installed Processing, in order to make nice stuff happen. I downloaded the .tgz file (installer for Linux 32bits, found here : ) from a web browser launched directly on the Raspberry Pi (needs a screen, a keyboard and a mouse plugged in)

Step 2 : Using the video-projector with the Raspberry Pi
We can use HDMI display to show stuff with the Rasp. But the pocket videoprojector hasn't got this option, so I used the composite (yellow RCA) output. It seems that there's sometimes some stuff to fix when using a composite display, but it worked fine in this case.
That said, working with such a tiny videoprojector is a pain in the ass, I rather used a HDMI screen to configure the Rasp.

Step 3 : Setting up a web server
We can easily have the Rasp perform HTTP requests. For this purpose, I made a php page that I put on a web server. This page then deals with a SQL database (that might need to be on a web server). If you don't have those, you should ask the staff to give you access to.
For this simple installation, a SQL table with one text field is enough. You can create it on the PhpMyAdmin interface you might have on your SQL database.
The php file can either read or update this field. In my situation, when a GET data is given to the php page (then called "http://[...]page.php?input=blablabla"), it updates the SQL text field with it. When no GET data is given ("http://[...]page.php"), it returns the data stored in the field.

Step 4 : Making fancy stuff with Processing
I developped two apps with Processing : one that is run by the Rasp, and one that is run by a remote computer. In both cases, I use the loadStrings() function to process an HTTP request (the function returns what the requested file returns).
In the writing case, the function is simply executed with the GET data ( loadStrings("http://[...]page.php?input="+data); ). In the reading case, a variable is set with the function's return value ( variable=loadStrings("http://[...]page.php"); ).
The idea here is to type text with the computer that shall be projected on the Rasp side. On both side, the text is displayed on real time. On the writing side, each time a (valid) key is pressed, a updating request is processed. On the reading side, the SQL data is requested each second (because we do not want to saturate the server by asking for stuff every milliseconds)

Step 5 : Automatic application launch when Raspberry powered on
To have a truly autonomous device, I set the Rasp to launch the application without needing any command from the user.
For that purpose, I firstly set Raspbian to login and open the window manager automatically (if you haven't set it when installing raspbian, you can still access the boot parameters by typing "sudo raspi-config" in a terminal).
Then, we want the application script to be executed with the opening of the window manager. Start up scripts are usually defined in the /etc/rc.local file, but in our case we need to edit the window manager start up file rather than rc.local. The file to be modified is /etc/lightdm/lightdm.conf, on the line where there's written "session-setup-script=" (in the SeatDefaults section).
The application script should be generated by exporting the Processing sketch on the Processing software (NB: we want a linux 32bits application). The path of the generated script ( "[...]/nameofyoursketch/application.linux32/nameofyoursketch" ) should then be added to the lightdm.conf, at the end of the line defined above.

If everything went well, that should work now. Just reboot the raspberry (only the videoprojector and the internet wire need to be connected now), and launch the application on your PC. Have fun !

( and if you have any questions concerning this work, feel free to send me an e-mail : lucienbobo [at] free [point] fr )

Here are the files I coded :

sketch for PC 
sketch for Rasp 
web server