Spectator board (Optional)

Pete at Linzt Cricket Club decided that just building one electronic scoreboard was no challenge at all, so him and the team decided to build two! The primary scoreboard is operated by the scorers with a keyboard and mouse plugged directly in to the Raspberry, with a second much smaller scoreboard is installed for the spectators to view that updates itself from the primary board.

These instructions show how to setup the primary scoreboard to automatically load the Westbury web interface when it boots, and when updated to store the current score in a file.  The instructions then show how to setup the spectator board to collect the score from the primary board every 10 seconds and update itself.

Please note these instructions are for setting up the Westbury on Severn web interface to support a spectator scoreboard.  While these instructions don’t apply to the Bradford interface, someone with Linux scripting experience could easily adapt the files on this page if required.

Setup the primary scoreboard to load the web interface automatically

To setup the Raspberry to load the web interface automatically when the device boots, we first need to make sure the Raspberry boots in to the UI as the pi user.  To do this open a console, and run:

sudo raspi-config

bootoptions

select option 3 for boot options

1

Then select option B4, and click OK several times to exit the tool and reboot the PI

Now we need to setup the Raspberry to load the web interface on boot.  To do this open the following file in a text editor:

nano /home/pi/.config/lxsessions/LXDE-pi/autostart

Add the following line to the bottom of the file: @/usr/bin/epiphany-browser http://localhost/index.htm

3

Save the file by pressing CTRL + O, and then exit with CTRL + X.

Now reboot the pi by typing

sudo reboot

The pi should now reboot, load the GUI and then open a browser to display the web interface.

Configure the primary board to save the score

In order for the spectator board to be able to automatically update, we must setup the primary scoreboard to save the score every time it is updated by the scorer.

To do this, we need to update the scoreboard.php and setup some permissions.  To start, download the spectatorv2.zip file, and transfer it to the Raspberry using WinSCP or similar.

4

Now open a terminal and unzip the spectatorv2.zip file with the following command

sudo unzip spectatorv2.zip

5

Now copy the scoreboard.php over the top of the existing one, with the following command:

sudo cp /home/pi/spectator/scoreboard.php /var/www/html/

Now we need to setup the save.txt which the new scoreboard.php writes to.  To do this type the following commands:

sudo touch /var/www/html/save.txt
sudo chown www-data: /var/www/html/save.txt
sudo chmod 664 /var/www/html/save.txt

Now when you change the score using the web interface, you should notice that the save.txt is updated.  You can check with the following command:

cat /var/www/html/save.txt

6

Setup the spectator board.

The spectator board will have its own Raspberry and Arduino, which should be setup in the exactly the same way as the main board, by following the instructions on the following pages:

https://buildyourownscoreboard.wordpress.com/setting-up-the-arduino/

https://buildyourownscoreboard.wordpress.com/setting-up-the-raspberry-jessie/

Once this is done, and you have tested the spectator board using the local web interface (to prove it works), you should add a wireless adapter to the spectator Raspberry (or use the built in one if you have a Raspberry 3B) and connect it to the wireless router in the primary board.  There are lots of tutorials on how to do this, and the exact steps vary depending on the router and wireless configuration, so they are not listed here.  Use the contact us page if you want some advice on this.

Once you have the spectator board working, we need to install some basic scripts to allow it to collect the save.txt from the primary board and update the spectator scoreboard.

To start, download the spectatorv2.zip file, and transfer it to the spectator Raspberry using WinSCP or similar.

4

Now open a terminal and unzip the spectatorv2.zip file with the following command

sudo unzip spectatorv2.zip

5

Now copy the spectator directory to the bin directory and set the permissions with the following commands:

sudo cp -r  /home/pi/spectator/spectator /usr/local/bin/
sudo chown -R root: /usr/local/bin/spectator

Now we need to edit the config file for the spectator script, so it knows the address of the primary board from which to get the score.  To do this type the following command:

sudo nano /usr/local/bin/spectator/spectator.conf

Edit the scoreboard_address line of the config file to set the IP address of the Raspberry in the primary scoreboard.

7

Save the file by pressing CTRL + O, and then exit with CTRL + X.  You can test the spectator script by running the following command:

sudo /usr/local/bin/spectator/spectator.sh

8

If this works without error, we now we need to setup the spectator scripts to run every 10 seconds.    To do issue the following command:

sudo crontab -u root -e

At the end of the file, add the following lines:

#added by iann to support the spectator board
* * * * * /usr/local/bin/spectator/spectator.sh > /dev/null 2>&1
* * * * * sleep 10; /usr/local/bin/spectator/spectator.sh > /dev/null 2>&1
* * * * * sleep 20; /usr/local/bin/spectator/spectator.sh > /dev/null 2>&1
* * * * * sleep 30; /usr/local/bin/spectator/spectator.sh > /dev/null 2>&1
* * * * * sleep 40; /usr/local/bin/spectator/spectator.sh > /dev/null 2>&1
* * * * * sleep 50; /usr/local/bin/spectator/spectator.sh > /dev/null 2>&1

9

Press [esc] [colon] [w] [q] to save and exit the file.  This will reload the crontab and run the spectator scoreboard update script every 10 seconds.  That should be it!  To test simply update the web interface on the primary scoreboard, wait 10 seconds and the spectator board should update.