Google+ Followers

Tuesday, September 23, 2014

54. Raspberry Pi set up to continually display a dynamic web page

23,000 page views!!
The task is to have a screen displaying a web page continually.  The web page contains the ‘live’ data from a specific sailing club windguru station.  This data is displayed in graphical form and is updated every minute:
The windguru station is an anemometer which has been positioned at the top of a 10 metre flag pole, to measure wind speed and direction.  A temperature probe is included.  The device is positioned so that its calibrated direction is pointing to true north.  The signals from the anemometer are transmitted wirelessly from a battery-powered  transmitter beside the anemometer, to a unit in the club house which is wired to the wi-fi router.  Information is sent to the windguru server which delivers the above information to the web.
The Raspberry Pi and associated cables, WiFi dongle, case and ultra mini wireless keyboard and trackpad were purchased from Pimoroni for less than £100.  It’s a Model B+ which has a 700MHz CPU, 512MB RAM, micro SD slot, 4 USB ports and a full size HDMI port.  The NOOBS software allows a choice of Linux operating systems and resides on an 8 GB micro SD card. I chose the Raspbian Debian Wheezy version of Linux.  The Pi is powered via USB connection to the TV to which it is connected.  The video signals are sent to the TV via an HDMI connection.  The VESA mount allows the Pi in its case to be mounted at the back of a TV, thereby being totally concealed.
Normally the Pi will boot up to the command line prompt, requiring a username and password to be entered, followed by a command like startx to start a Windows-like desktop, or other application.  To display web pages, the on-board lightweight web browser, Midori, would normally have to be started manually and prompted with the required web address.
The requirement here is to by-pass the login process and the manual starting of Midori.

Steps to take are as follows:

a.    Download and install programs using the following commands:
sudo apt-get install matchbox
matchbox is a “very lightweight fullscreen-only kiosk-specialized window manager” which is needed to ensure that the Midori web browser displays in full screen.
sudo apt-get install x11-xserver-utils
This contains useful utilities which can be invoked, as shown below.

b.    Edit existing system files (using nano):
1.  /etc/network/interfaces
2.  /etc/profile/
3.  /etc/inittab
c.    Write a script:
The script I wrote is called autowindguru and it can be executed with the command line
xinit ./autowindguru
which is executed within the profile file.
1. interfaces contains the Wireless network/SSID and the wireless key.
An example of the content of this file is:

auto lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0

iface wlan0 inet dhcp
wpa-ssid ###########
wpa-psk ##########  (actual codes are hidden here)
2. profile
I added, at the last line of this (quite long) file,
xinit ./autowindguru
to run the  autowindguru  script (see below) which I wrote to run the web page.
3. inittab
The following link was where I got the instructions to modify the inittab file:
4. autowindguru
I created a script which I named autowindguru  as follows:
xset –dpms
xset s off
#unclutter &
matchbox-window-manager &
while true; do
midori –e Fullscreen –a

The url included above points to the web page windguruPageLarge.htm  which I developed and uploaded to the server.
The xset lines invoke the x11-xserver-utils utility which was downloaded and installed earlier.  They prevent screen blanking due to inactivity.
unclutter has been commented out, but could be used to remove the mouse cursor if it became a nuisance.
The while true; do………done code opens the browser in a loop, so that “it will re-start itself if something crashes”.
Some of these tips came from the following link:

The Web Page

The web page to be displayed consists of a 2 x 2 table, with the top row containing the basic windguru web page on the left, and the specific windguru 8-day forecast on the right.

The bottom row includes Javascript for current moon phase (from MoonConnection) on the left and local tide times from tidetimes on the right.
There are 2 versions of the web page:
1.    one for 1366 x 768 pixel screens (windguruPage.htm), and
2.    one for 1920 x 1080 screens (windguruPageLarge.htm) – shown below:

The panels on the left hand side of this page are dynamic (live), while those on the right need to be refreshed daily.  Daily refreshing can be done by switching the TV off and on, to re-boot the Pi.

Here is a photo of the Raspberry Pi in its PiBow case, with optional VESA mounting plate (right), and the Rii Portable 2.4GHz ultra mini handheld rechargeable keyboard with touchpad (it even includes a laser pointer!):

The Pi Model B+ looks great in it's PiBow case

The wireless mini keyboard - a brilliant piece of kit - only 6 inches long!

PS - this all runs beautifully, but if you need to get in to the command line (LXTerminal), you have to enter Ctrl-Alt-F3, and then log in as usual, and run startx.


No comments:

Post a Comment