Configuring your Raspberry Pi

This topic is applicable to Sonos owners only.

The Raspberry Pi was introduced in a previous topic, covering how it enhances AlbumPlays, what you need to get, and how to install it.

The aim of this step is to ………

1. Update RPi software to the latest levels

The software in your RPi has been loaded from a NOOBs card (aka “New Out Of the Box Software” btw). … We don’t know how old that card is. We should apply all of the latest fixes and features to the RPi’s operating system and suite of tools.

This step is highly recommended. It may avoid glitches.
Internet access required.

The following procedure runs on the RPi, analyses which updates are required, calculates the size of the download, and then requests confirmation before starting. … I have performed this with two NOOBS cars. One was a relatively small download, and the other was quite large (around 900mb I think) … anyway, you will be asked before it starts.

It is a simple procedure. The upgrades are automatically downloaded and installed following receipt of your approval to make the download.

click here details

Start a RPi terminal session from your PC, and then enter the two update commands as described on the Raspberry Pi site.

nb: a terminal session is started by double clicking on icon #3 shown in the following illustration

RPi GUI controls


2. Configure your RPi to auto-start the remote control server

The aim of this step make your RPi permanently in a state where it is ready to accept a login from your PC.

nb: This is just a convenience step. It has no impact on the normal operation of AlbumPlays, as its “Get” action does not need to log into the the RPi to collect fresh track play Spy observations. … You typically only login to the RPi when applying AlbumPlays upgrades. … If you skip this step you will need to manually restart the RPi’s remote control server before you can log into it.

click here details
  1. Discover your PC’s screen resolution.
    • use your PC’s ControlPanel|Appearance&Personalisation|Display|AdjustResolution menu
    • record your your screen’s resolution … it will something like 1280×1050
    • if you can’t find it, try this link, or just use 1280×1050
  2. Log into the RPi desktop
    • use the TightVNC viewer on your PC, which we configured in a previous step of this tutorial
  3. Copy a script into the RPi’s clipboard

    • browse to here using the RPi’s browser, and then open the following link, and copy the script file into the clipboard, everything starting from “#! /bin/sh” and ending with “exit 0”
Click to open script lines for copy & paste
    #! /bin/sh
    # /etc/init.d/vncboot
    # Provides: vncboot
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start VNC Server at boot time
    # Description: Start VNC Server at boot time.
    export USER HOME        
    case "$1" in
      echo "Starting VNC Server"
      #Insert your favoured settings for a VNC session
      su - $USER -c "/usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565"
      echo "Stopping VNC Server"
      /usr/bin/vncserver -kill :1
      echo "Usage: /etc/init.d/vncboot {start|stop}"
      exit 1
    exit 0


  • or the script is available here with some further explanation… ie. at
    • scroll down until you find the script which starts with “#! /bin/sh” and ends with “exit 0”
    • drag over the script, right click, and select copy

4: Create a script file on the RPi

  • start a terminal session (the black screen icon on the tool bar)
  • enter the following Linux commands

    • the first line puts your into a Administrator role
    • the second navigates to a directory; the RPI should respond with root@raspberrypi:/etc/init.d#
    • the last line starts Linux’s sorry excuse for a text editor, opens an empty file which will be named vncboot

      sudo su
      cd /etc/init.d
      nano vncboot
  • it should open an empty file (saying [ New File ] on the third to last line

  • right click at the top in the black area, and select *paste”
  • Raspberry Pi GUI controls
  • make sure that you copied everything starting from “#! /bin/sh” and ending with “exit 0”
  • [optional] look for the line (about 2/3 through the script) containing -geometry -geometry 1280×800 and replace the number with your own screen’s dimensions from step #1
  • the nano editor doesn’t support the mouse, so use the arrow keys to move the cursor to the dimensions to be altered
  • when complete, press Ctrl X to exit
  • respond y to save your changes

5: Make the script file executable

  • type the following command into the black terminal window, and press Enter

    chmod 755 vncboot

6: Trigger your RPi to run this file whenever it reboots up

  • type the following commands into the terminal, press the Enter key after each

    update-rc.d -f lightdm remove
    update-rc.d vncboot default 

7: Reboot your RPi

  • close the terminal window
  • trigger a reboot; press the Menu button (has the Raspberry icon), take option Shutdown with option set to Reboot

8: Check that the RPi’s remote control server auto-started

  • Relog onto the RPi desktop using the TightVNC Viewer on your PC


3. Localise your RPi

The aim of this step to setup the RPi to use your own region settings: time zone, date format, etc

click here details
  1. Log into the RPi desktop
    • use the TightVNC viewer on your PC, which we configured in a previous step of this tutorial
  2. Press Menu button (with the raspberry icon)
  3. Select Preferences, and then Raspberry Pi Configuration
  4. Open the Localisation tab
  5. Make you changes; a reboot will be required
  6. Reboot; Menu button, then Shutdown with Reboot radio option selected


4. Cut and Paste from Windows clipboard to your RPi

The aim of this step is to make it easy to cut & paste Linux command lines from this tutorial into a RPi terminal session.

click here details
  1. Open a terminal session (icon with black window)
  2. Install cross platform clipboard facility
    Type the following two lines, pressing the Enter key at the end of each

    sudo apt-get update
    sudo apt-get install autocutsel 
  3. Auto-start the cross platform clipboard facility
    Type the following plus the Enter key to open the editor

    nano /home/pi/.vnc/xstartup

    Move the cursor down to the end of the line after xsetroot -solid grey
    Press the Enter key to open up a new line, and type the following

    autocutsel -fork

    The file should now read as

    xrdb $HOME/.Xresources
    xsetroot -solid grey
    autocutsel -fork
    #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    #x-window-manager &
    # Fix to make GNOME work

    press Ctrl+X to close the editor
    type y to confirm that you want to save you change
    press Enter to overwrite the old file

  4. Reboot the RPi
    Menu (button with the raspberry icon), select Shutdown with the option Reboot

  5. Test
    Reconnect to the RPi, then try pasting something, eg. Menu|Accessories|TextEditor to open the RPi’s text editor … try to copy and paste something from Windows.


5. Reserve a fixed IP address for your RPi

The aim of this step is to assign a permanent predictable IP address for your RPi, so that we may create a permanent shortcut onto our Windows desktop or task bar to log into the RPi.

It is possible to assign a fixed IP address to the RPi, but it is safest to reserve a permanent address for it in your router|modem as described below.

click here details
  1. Find your RPi’s unique MAC Address (Media Access Control address)

    • log into your RPi from your PC (using TightVNC Viewer)
    • start a terminal session on the RPi
    • if your RPi is connected by WiFi, type the following

      ifconfig wlan0
    • or if you are connected via Ethernet, type the following

      ifconfig eth0
    • the MAC Address is listed as HWaddr … it will something like b8:27:eb:12:8c

    • the IP address is listed as inet addr it will be something like
    • record both the MAC addr and the current IP Address
  2. Find your router|modem’s IP address.

    • the default address is often printed on label attached to the botton of the unit. (it will look something like
    • otherwise open the command prompt on your PC (start button, and search for command)
    • type the following

    • the response will display the IP address, described as the Default Gateway

  3. Log into your modem|router (eg.
    • supply login credentials (the defaults will also be on a label attached to your device)
  4. Locate where your modem|router configures your local area network
    • it should be on a page titled LAN IP or LAN Setup, or something like that
    • there should be somewhere on that page where you can setup a DHCP Reservation Lease, or an Address Reservation, or DHCP Static Lease, or some similar name … sorry every device is different
    • what you are looking for is somewhere where you can supply a MAC Address & IP Address pairing, so that the device with that MAC Address is always given that IP address
  5. Record the reservation in your modem|router
    • add the MAC Address & IP Address pairing for your RPI
  6. Reboot your RPi
    • press the Menu button (has the Raspberry icon), take option Shutdown with option set to Reboot
    • recheck your RPi’s IP Address


6. Make a backup copy of your RPi’s SD card

The aim of this step is to make a backup copy of the equivalent of your RPi’s disk drive. You will be pleased to have this copy if (or when?) your SD card fails, or if you make a configuration error rendering your RPi inoperable.
Requires a USB card reader

Yes, SD cards do fail, or the data on them can become corrupted. It is said that the most common RPi problem is SD card failure.

Your best defence is:

  1. Buy a good quality SD card … better yet, purchase two, one for your backup copy
  2. Always close down your RPi before cutting the power
  3. Keep a backup copy of your SD card

What gets lost if my SD card becomes damaged?

If you are using the recommended database transfer option your fresh Spy observation will be safely stored on your NAS.

You may lose the following:

  • you may not be able to boot the RPi, so not able to detect new Sonos track plays
  • you may lose all of the configuration changes which you have made to your RPi
  • you may need to re-install the Spy module onto your RPi
  • unless you are using the database transfer option, you may lose all fresh track play obersations made since your last AlbumPlays Get action
How to make a backup copy of your SD card (click here details)

a. log into the RPi using the TightVNC Viewer on your PC
b. check whether the SD Card Copier accessory is installed
press Menu (red raspberry icon), Open Acessories, and look for the SD Card Copier

card copier accessory

Not found? ... then install it (click to open)
  1. Open a terminal session (icon with black window)

* Type the following two lines, pressing the Enter key at the end of each

    sudo apt-get update
    sudo apt-get install piclone        

3. Follow the instructions here .. scroll down until you see the heading “SD card Copier”



Next step: Preparing your Raspberry Pi for AlbumPlays

Previous step: Control your Raspberry Pi from your Windows PC
Site map: Index to my Raspberry Pi installation & support pages