The initial steps to set up the Pi are to get a copy of Raspbian installed on an SD card of at least 4 GB (although 8 GB or larger is preferable), as described in Chapter 1, Raspberry Pi Pirate Radio, and if desired, connect the Pi to your Wi-Fi network. This project will keep the Pi outside the display enclosure so that Wi-Fi is only really needed if a wired connection is not available.
You may wish to rotate the display to use the mirror in a portrait orientation, in which case the video output of the Pi will also need to be rotated. Fortunately, this is done by a simple change to a configuration file:
sudo nano /boot/config.txt
N
with one of the options described in the next screenshot:display_rotate=N
The configuration file looks similar to the following screenshot:
sudo reboot
The possible options that can be given for N
are:
0
: Normal display1
: Rotate 90 degrees clockwise2
: Rotate 180 degrees clockwise3
: Rotate 270 degrees clockwiseNow that the Pi is set up, we can go ahead with the deployment of the web application on the Pi. Once again, this is a Flask application, so the procedure will be very similar to that used in the previous projects:
config_files
and mirror_webapp
directories to the /home/pi
directory on the Raspberry Pi.sudo apt-get update sudo apt-get upgrade sudo apt-get install python-pip git gunicorn supervisor nginx sudo pip install requests pytz feedparser
git clone https://github.com/mitsuhiko/flask.git cd flask sudo python setup.py install cd
sudo cp config_files/nginx/mirror.conf /etc/nginx/sites-available/mirror.conf sudo ln -s /etc/nginx/sites-available/mirror.conf /etc/nginx/sites-enabled/ sudo rm /etc/nginx/sites-enabled/default sudo nginx -t sudo service nginx restart
sudo cp config_files/supervisor/mirror_webapp.conf /etc/supervisor/conf.d/mirror_webapp.conf
cp config_files/mirror_app.conf ~ cp -r config_files/widgets/ widget_configs/
sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start mirror_webappp
Once this has been done, you should be able to browse the web application using the IP address of the Pi from any PC on the same network. On doing so, you should be greeted with a page similar to that shown in the following screenshot:
Don't worry if the page looks badly rendered, as the default widget configuration is designed to be shown on a portrait monitor and the font sizes are set relative to the width of the screen. When displayed on the Pi, this looks a lot better.
Now that we have the web application set up, we can move on to install the Chromium browser. We will use the browser in the kiosk mode to display the web application on the PI automatically, when it boots. To set up Chromium, perform the following steps:
sudo raspi-config
sudo apt-get install chromium x11-xserver-utils unclutter
autostart
script so that Chromium automatically starts and browses to the web application page when the Pi boots:sudo nano /etc/xdg/lxsession/LXDE/autostart
@xscreensaver -no-splash
@xset s off @xset -dpms @xset s noblank @chromium --kiosk --incognito http://localhost
By this point, the autostart
file should look similar to the following screenshot:
sudo reboot
All being well, you should see the Pi boot into LXDE (indicated by the Raspberry Pi logo shown on a white background) and shortly after that, Chromium should start and browse to the web application.
3.22.74.160