The kiosk project is running a web server on the Raspberry Pi, as well as a web browser which loads a locally hosted web site. The web browser will reload the page every 10 seconds, and if your page gets a new Like, you’ll see the number increase. There’s one more fun feature, and that’s the addition of a sound effect when you get a new Like. This can be a nice thing to display at your business or an event so people can interact with it.
You will want to make sure your Raspberry Pi boots up into the desktop environment, as you’ll need to have it fire up a browser automatically at each reboot.
We're going to need a few extra pieces of software not included with the default Raspian distribution. (You can use any distro you like, but we're going to assume Raspian for this project.)
If you're new to Linux, you'll want to get familiar with apt-get, which is the easy way to install software packages on Linux.
sudo apt-get updatesudo apt-get upgrade
Once those are done, let's get the Apache web server and the Chromium web browser installed. (We're also going to install some utilities to prevent the screen from going blank.)
sudo apt-get install apache2sudo apt-get install chromium-browsersudo apt-get install x11-xserver-utils
We're also going to install a few Perl Modules. Luckily, there's an easy way to get most of what we need, so we'll only have to manually install a few.
To get started type:
sudo apt-get install dh-make-perl
Since Raspbian is based on Debian Linux, this is the preferred method of installing modules.
We should now have the following modules installed:
Two of our needed modules would not install using dh-make-perl, so we'll take care of those next.
First we'll get JSON, as our main CGI script will need that. Here's the commands to run:
wget http://search.cpan.org/CPAN/authors/id/M/MA/MAKAMAKA/JSON-2.90.tar.gztar xfvz JSON-2.90.tar.gzcd JSON-2.90/perl Makefile.PLsudo makesudo make install
Next we'll get File::Modified, as we need this for determining when to play our sound file.
wget http://search.cpan.org/CPAN/authors/id/C/CO/CORION/File-Modified-0.07.tar.gztar xfvz File-Modified-0.07.tar.gzcd File-Modified-0.07/perl Makefile.PLsudo makesudo make install
Hopefully everything installed without issue. Installing Perl Modules can sometimes be tricky!
This step is completely optional, and you can skip it if you like, but honestly this is the fun part!
I found this nice celebratory sound at Freesound.org called CROWD YAY.wav courtesy of Freesound user mlteenie.
Put the audio file in /home/pi and if you want to test it type:
Hopefully you hear your file. Getting sound working on the Raspberry Pi can be a bit tricky sometimes. It's gotten better in more recent versions of Raspbian, and this time around I just had to make one change to get sound working.
sudo nano /boot.config
Find the line that says:
and uncomment it by removing the # at the beginning.
That got sound working fine via HDMI on my TV.
Now, our CGI file keeps track of how many Likes in the file at /home/pi/likealot.txt, so when that file changes we know we've got more Likes. That's our trigger to play the sound file. We have another script for that.
We'll have the Perl script checkchanged.pl running all the time, and it will play the sound whenever the likealot.txt file changes. We'll set up a cron job that gets our script running.
At the bottom add the line:
@reboot /usr/bin/perl /home/pi/checkchanged.pl
This will start our script when we boot up the Pi. (Note: There are other methods of running things at startup as proper system services, but we're keeping it simple for this project.)
At this point you could reboot your Pi and it should go right into the desktop environment, with Apache running, and our Perl script running, watching for our file to change, and if you launch Chromium it will load the site and it'll all work, but there's one more step to automate it all.
We need to edit the autostart file so the screensaver doesn't run and the screen doesn't go blank.
sudo nano /etc/xdg/lxsession/LXDE/autostart
Look for the screensaver line, and delete it or comment it out by putting a # at the start.
# @xscreensaver -no-splash
We'll then add a few more lines to make sure our screen does not go blank, and to make Chromium start up at launch time.
@xset s off
@xset s noblank
@chromium --kiosk --incognito http://127.0.0.1/
Once you've done all this, go ahead and reboot, and your kiosk should be ready to go!
I love making things and sharing with others. When I'm not busy building museum exhibits or teaching physical computing classes I'm hanging out at Milwaukee Makerspace and organizing Maker Faire Milwaukee.
When you buy through links on our site, we may earn an affiliate commission.
We'll assume you're ok with this, but you can opt-out if you wish.