View on GitHub

tbellembois.github.io

Thomas Bellembois

create an announcement screen with a raspberry pi

You can create a simple announcement screen with a monitor and a Raspberry Pi board. The Raspberry Pi is a “credit-card sized computer that plugs into your TV and a keyboard”.

RaspberryPi Announcement screen Raspberry Pi and screen

The system consists on:

I have developed a small Web application with the Web2py framework. Please refer to the Web2py site to install the framework. It is really easy (download, unzip and run).

Please email me for the source code of the application.

This application will give you the following interface.

Main screen Announcement add

An announcement has:

The announcements are stored in a sqlite database (other databases possibles, look at the Web2py documentation). A Web2py script scripts/generate_html.py generates the final page in the static/output directory.

I call this script every 3 minutes in a crontab and rsync the output directory to the Raspberry Pi.

# - "ecran" is the name of the Web2py application
# /var/www/web2py is the Web2py framework installation directory
# the "-a root" option provides the password of the Web2py administration interface, not used here, but his parameter is needed
# the "-S ecran -M" option ask Web2py to run a shell for the "ecran" application and load the models (databases)
# the "--run" option runs the script given in parameter
# "ecran-accueil.igfl.ens-lyon.fr" is the Raspberry Pi


*/3 * * * * root /var/www/web2py/web2py.py -a root -S ecran -M --run=/var/www/web2py/applications/ecran/script/generate_html.py > /dev/null 2>&1; rsync -avz /var/www/web2py/applications/ecran/static/output/* root@ecran-accueil.igfl.ens-lyon.fr:/home/pi/panneau/ > /dev/null 2>&1;

On the Raspberry Pi I launch a chromium browser in fullscreen mode at startup. We can achieve this with the .config/openbox/autostart file.

#! /bin/bash
# some cleanup
rm -rf /home.pi/.cache
rm -rf /home/pi/.config/chromium
# DISPLAY=:0 force chromium to use the principal display. There is a :1 display for the VNC server
DISPLAY=:0 chromium /home/pi/panneau/panneau_affichage.html &
sleep 10
# simulate a F11 to put chromium in fullscreen
DISPLAY=:0 xdotool key F11

We then need to refresh the screen regularly.

# simulate a F5 to refresh chromium
*/3 * * * * pi DISPLAY=:0 xdotool key F5