Sunspot Home

more notes for a bad memory - - -

Setting up the Raspberry Pi with a 3.5 inch colour LCD and Epiphany browser in Kiosk mode

Show a web page in full screen (Kiosk mode) that is controlled by CGI scripts to show solar water heater performance etc.

I bought a 3.5 inch 320x400 display for a Pi for under £9 from eBay

It is pin sharp and colorful - I thought that 1 or 2 pixels were dead (hence the price?)
but their location is random - perhaps a data comms problem?

I loaded the img file -
from - code/

Load the image with Apple Pi-Baker

Set a fixed IP address in /etc/interfaces/network

# The loopback network interface - always needed here
auto lo
iface lo inet loopback

# this one for dhcp
# auto eth0
# iface eth0 inet dhcp

# this one for WIFI D-Link DWL-G122
# allow-hotplug wlan0
# iface wlan0 inet static
# pre-up ifconfig wlan0 up
# pre-up iwconfig wlan0 mode Managed
# pre-up iwconfig wlan0 essid "225"

# The primary network interface - use this for ethernet cable if WIFI above not used
# in that case disable the WIFI above with # before each line
allow-hotplug eth0
iface eth0 inet static

# set these for the LAN address

# set this for the Internet modem gateway to the LAN
gateway 192.168.0.yyy
# dns-* options are implemented by the resolvconf package, if installed

# my gateway acts as a local dns-nameserver (not needed?)
dns-nameservers 192.168.0.yyy

Do not change the bootloader during the update
sudo apt-mark hold raspberrypi-bootloader

Update/upgrade the PI image
sudo apt-get update && sudo apt-get upgrade -y

Create a webserver that will be used to create the local web page at for the Kiosk mode
sudo apt-get install apache2 -y

Note - I tried to load PHP at various point in this procedure. After all seeming to work I backed up the image with PiBake (Mac).
On the next boot I could not see the GUI screen - just a black screen tha accepted typing from the keyboard.
This happend several times.

Epiphany browser - Boot to a web page and set Kiosk mode,

Create full screen as if key F11 pressed
sudo aptitude install xautomation

create -

#! /bin/sh
# /home/pi/

# launch the web page of choice (this one is the default that Apache creates in /var/www
sudo -u pi epiphany-browser -a --profile ~/.config --display=:0 > /dev/null 2>&1 &
sleep 15s;

# this does the same job as pressing the F11 key to force Kiosk mode
xte "key F11" -x:0 &

then do -

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi

# kill the screen saver
#@xscreensaver -no-splash


sudo reboot

and the Pi will show the normal GUI followed by the Apache default web page in full screen mode at /var/www/index.html

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

There are no borders and no way to poweroff cleanly other than hitting the "Windows" key on the keyboard.
I aim to create the page from a script and add a poweroff button.

First prepare the Raspberry Pi
I need a ramdisk for changing data so as to not burn out the flash memory
Place this with 755 permissions into

Every time the Raspberry Pi is booted the temporary RAM disk will be created - 2M means 2 Mega Bytes
it could be much larger - I use it for the output of bash scripts and the input of Blassic basic programs.

(Blassic basic acts as great glue to hold together other software including C, bash etc and can save and read files as needed.
It handles and manipulates text string in ways I can understand and remember - (unlike C !!!!).
Learn Python and C++ if you can but if you only program a couple of times a year consider Blassic as a tool to get the job done.
See a few notes at pull down menu item 12 at -> )

#! /bin/sh
# My startup script at
# /etc/init.d/

# note, when changed do the following at a ssh command line-
# update-rc.d -f remove
# update-rc.d -f defaults 99

# Now carry out specific functions when asked to by the system
case "$1" in

# make a ramdisk to save the flash
mkdir /var/www/ramdisk
mount -o size=2M -t tmpfs tmpfs /var/www/ramdisk

echo "Usage: /etc/init.d/ {start|stop}"
exit 1

exit 0

Setting up the Pi as a webserver

Get the latest software and links
apt-get update

install Apache
apt-get install apache2

There should be a simple webpage index.html in /var/www/

see it at

CGI scripting in bash

in :-

put :-
echo -e "Content-type: text/html\n\n"
echo "<h1>Hello World</h1>"

then create a link to cgi-bin in the www folder :-
ln -s /usr/lib/cgi.bin /var/www/cgi-bin

see it at

Add PHP - works - but it was not stable. . . .

sudo apt-get install php5 libapache2-mod-php5 -y

To test PHP put into /var/www/php_test.php

<title>PHP test</title>

echo "<b>Hello World!</b><BR><BR>The date is ";
echo date('Y-m-d'), "<BR>and the time is ", date('H:i:s');
echo "<BR><BR>Now for some information about PHP :-<BR><BR>", phpinfo();


see it at

If there are several Raspis on the network change their host names

sudo nano /etc/hosts
sudo nano /etc/hostname
sudo /etc/init.d/
sudo reboot

Please email me if you want to swap notes
- especially if you do a better job !!!!
add i2c port expanders, thermometers, displays etc
(my next learning exercise)


more to come . . .