Creating a headless Raspberry
Pi for collecting muon data
Page | 1
Creating a headless Raspberry Pi for collecting muon data.
During the session we will use various free software tools and a RaspberryPi 4 for demonstrations
purposes. The following list of hardware and software is for reference and indicates where the
various programmes can be found and downloaded. If you are using a windows version earlier than
Windows 10 please take care to download an appropriate version of the software.
Table of Contents
Creating a headless Raspberry Pi for collecting muon data. .................................................................. 2
REQUIREMENTS – Essential and / or Optional........................................................................................ 3
Required hardware (essential):........................................................................................................... 3
Required hardware (optional): ........................................................................................................... 3
Required Software (essential):............................................................................................................ 3
Required Software (optional): ............................................................................................................ 3
Required information (optional): ........................................................................................................ 3
Required Code Editor for Python Tutorials ......................................................................................... 3
Objectives of this session ........................................................................................................................ 4
Prior Knowledge .................................................................................................................................. 4
Running Order ..................................................................................................................................... 4
Installing Raspberry Pi OS onto the MicroSD Card ................................................................................. 5
Installing PuTTY on your PC .................................................................................................................. 19
Installing WinSCP .................................................................................................................................. 23
Turn on your Raspberry Pi and connect to it with PuTTY ..................................................................... 28
Installing VNC viewer on your PC.......................................................................................................... 38
Connecting to your RPi using VNC Viewer ............................................................................................ 43
Installing Visual Studio Code on your PC .............................................................................................. 47
Simple configuration of Visual Studio Code on your PC ....................................................................... 51
First python code on your PC ................................................................................................................ 55
Connecting Visual Studio Code on your Raspberry Pi........................................................................... 58
Page | 2
REQUIREMENTS – Essential and / or Optional
This is for a windows installation – other operating systems are available.
Required hardware (essential):
1. Raspberry Pi 4 Model B (2GB) https://thepihut.com/products/raspberry-pi-4-model-b
2. Official UK Raspberry Pi 4 Power Supply (5.1V 3A) https://thepihut.com/products/raspberry-
pi-psu-uk
3. SanDisk MicroSD Card (Class 10 A1) 32GB https://thepihut.com/products/sandisk-microsd-
card-class-10-a1
4. Mini USB 2. MicroSD Card Reader https://thepihut.com/products/mini-usb-2-0-microsd-
card-reader
Required hardware (optional):
1. Official Raspberry Pi 4 Case https://thepihut.com/products/raspberry-pi-4-case
Connecting to home Wi-Fi network:
1. Nothing more
Connecting to home LAN network:
1. RJ45 Cat5e Ethernet LAN Cable 2m https://thepihut.com/products/rj45-cat5e-ethernet-lan-
cable-2m-black
Required Software (essential):
1. Raspberry Pi Imager https://www.raspberrypi.com/software/
2. PuTTY https://www.putty.org/
3. RealVNC viewer https://www.realvnc.com/en/connect/download/viewer/
Required Software (optional):
1. Notepad++ https://notepad-plus-plus.org/
2. Advanced IP Scanner https://www.advanced-ip-scanner.com/
3. WinSCP https://winscp.net/eng/index.php
Required information (optional):
1. Your WiFi SSID – name of WIFI
2. Your WiFi password
Required Code Editor for Python Tutorials
1. Visual Studio Code https://code.visualstudio.com/
Page | 3
Objectives of this session
By the end of this session you will be able to:
1. Understand and use a "headless" RPi
2. Make a RPi operating system microSD card ready for remote access
3. Connect your RPi to your home network and identify its address on the network – using both
wired and wireless connections.
4. Set up and use RealVNC Viewer on your RPi and remote computer
5. Set up and use SSH access to your RPi from a remote computer
6. Download python script to the RaspberryPi and run it.
Prior Knowledge
Some prior knowledge will be helpful to you to gain the maximum value from the session. It is
assumed that:
You can download and install software from the internet onto your computer
Know your Wi-Fi passwords and can connect new devices.
Running Order
1. Creating an SD Card
a. Configuring WiFi and remote access
b. Which RaspberryPi OS version?
2. Power up the RaspberryPi
a. Identify the device on your network
3. Using RealVNC Viewer
4. Using WinSCP
5. Introduction to Linux
a. Some basic commands
b. Running a Python Script
Page | 4
Installing Raspberry Pi OS onto the MicroSD Card
1. Use the following link to access Raspberry Pi Imager:
https://www.raspberrypi.com/software/.
2. Scroll down page to get to “Install Raspberry Pi OS using Raspberry Pi Imager”, then click on
the tab “Download for Windows” – this will go from blue to red as you move your mouse
over it.
3. Go to your Downloads folder and locate the imager file you just downloaded.
4. Double click on the imager_x.x.x.exe file to run and you will be presented with a Windows
confirmation screen. Move your mouse over the “Yes” and click your left mouse button to
select.
Page | 5
5. You will now have the Raspberry Pi Imager installer screen. Move your mouse over the
“Install” and click your left mouse button to select.
6. When the install is complete, ensure that “Run Raspberry Pi Imager” is checked and move
your mouse over the “Finish” and click your left mouse button to select.
Page | 6
7. The Raspberry Pi Imager screen will now be displayer
8. We are firstly going to select our Raspberry Pi Device by moving our mouse over “CHOOSE
DEVICE” and clicking the left mouse button to select
Page | 7
9. We will now have a list of Raspberry Pi Devices to select from. We are going to select the
“Raspberry Pi 4” by moving our mouse over “Raspberry Pi 4” and clicking the left mouse
button to select.
10. This will return us to the Raspberry Pi Imager screen, now there is “RASPBERRY PI 4” in the
Raspberry Pi Device window
Page | 8
11. We are secondly going to select our Operating System by moving our mouse over “CHOOSE
OS” and clicking the left mouse button to select
12. We will now have a list of Operating Systems to select from. We are going to select the
“Raspberry Pi OS (64 bit)” by moving our mouse over “Raspberry Pi OS (64 bit)” and clicking
the left mouse button to select.
Page | 9
13. This will return us to the Raspberry Pi Imager screen, now there is “RASPBERRY PI 4” in the
Raspberry Pi Device window and “RASPBERRY PI OS (64-BIT)” in the Operating System
window
14. Plug your microSD card into your computer using a suitable adapter if needed.
15. We are lastly going to select our Storage by moving our mouse over “CHOOSE STORAGE”
and clicking the left mouse button to select
Page | 10
16. We will now have a list of storage options to select from. We are going to select the “Mass
Storage Device USB Device – 31.9 GB” by moving our mouse over “Mass Storage Device
USB Device – 31.9 GB” and clicking the left mouse button to select.
17. This will return us to the Raspberry Pi Imager screen, now there is “RASPBERRY PI 4” in the
Raspberry Pi Device window and “RASPBERRY PI OS (64-BIT)” in the Operating System
window and MASS STORAGE DEVICE USB DEVICE in the Storage window. Move your mouse
over “NEXT” and click the left mouse button to select
Page | 11
18. We will now have the option to apply a customised operating system. We will want to do
this so we are going to select the “EDIT SETTINGS” by moving our mouse over “EDIT
SETTINGS” and clicking the left mouse button to select.
19. This will bring us to the first of three pages that we can use to customise our operating
system.
Page | 12
20. On the first page “GENERAL” we are going to use the following options
a. Set hostname: “MuonPi”
b. Set username and password
i. Username : “pi”
ii. Password : “PassWord”
c. Configure wireless LAN
i. SSID: “for your own Wi-Fi”
ii. Password : “for your own Wi-Fi”
d. Set Local settings
i. Time zone : “Europe/London”
ii. Keyboard layout : “gb”
Page | 13
21. On the second page “SERVICES” we are going to use the following options
a. Enable SSH
i. Select Use password authentication
Page | 14
22. On the third page “OPTIONS” we are going to use the following options
a. Play sound when finished
b. Eject media when finished
c. Enable telemetry
We will now have the option to save the customisations we have made. We do this by
moving our mouse over “SAVE” and clicking the left mouse button to select.
Page | 15
23. We return to “Use OS customisation?” screen and now have the option to use the
customisations we have made. We do this by moving our mouse over “YES” and clicking the
left mouse button to select.
24. We now get a warning message about erasing the ‘Mass Storage Device’. Make sure you
are going to write the Raspberry Pi operating system to the correct device, we do this by
moving our mouse over “YES” and clicking the left mouse button to select.
Page | 16
25. The Raspberry Pi Imager will now write the operating system to the mass storage device.
For a 32GB microSD card this takes about 7 minutes.
26. The Raspberry Pi Imager will now verify the operating system on the mass storage device.
For a 32GB microSD card this takes about 7 minutes.
Page | 17
27. The Raspberry Pi Imager will confirm what it has done. We can now remove the SD card
from the computer and close the Raspberry Pi Imager by moving our mouse over
“CONTINUE” and clicking the left mouse button to select.
28. And then closing the Raspberry Pi Imager main window with the X button in the top right
hand corner
Page | 18
Installing PuTTY on your PC
1. Use the following link to access PuTTY: https://www.putty.org/.
Click on the link “Download PuTTY”
2. Select the appropriate package file from the list provided – in this case 64-bit x86.
Page | 19
3. Go to your Downloads folder and locate the PuTTY file you just downloaded.
4. Double click on the putty-64bit file to run and you will be presented with a PuTTY release
Setup window. Move your mouse over the “Next” and click your left mouse button to select
Page | 20
5. You will be asked where you want PuTTY installed – go with default. Move your mouse over
the “Next” and click your left mouse button to select.
6. You will be asked about Product Features for PuTTY. Select “Add shortcut to PuTTY on the
Desktop” – will be installed on local hard drive. Move your mouse over the “Install” and
click your left mouse button to select.
Page | 21
7. You will be presented with a Windows confirmation screen. Move your mouse over the
“Yes” and click your left mouse button to select.
8. PuTTY will finish installing and present the following window when complete. Move your
mouse over the “Finish” and click your left mouse button to select. You can deselect the
View README file if desired.
9. There should now be a short-cut icon on your desktop for PuTTY
Page | 22
Installing WinSCP
1. Use the following link to access WinSCP: https://winscp.net/eng/index.php.
Click on the link “Download Now”.
This will download an installation programme. Double click on the file to execute it.
Page | 23
Page | 24
Next Launch the installed WinSCP programme. The next screenshots are a brief introduction to
WinSCP and show how to connect to a RaspberryPi.
Enter the host name, user name and password. This is either be the host name
configured on the microSD card or the RaspberryPi’s ip address. This screen uses the
device’s host name.
Page | 25
Enter the host name, user name and password. This is either be the host name
configured on the microSD card or the RaspberryPi’s ip address. This screen shows the
device’s ip address
Accept the security screen
Page | 26
The left panel shows the windows pc user’s documents directory. Navigation is similar
to Windows Explorer.
The right panel is the home directory on the RaspberryPi. Navigation is similar to
Windows Explorer.
Page | 27
Turn on your Raspberry Pi and connect to it with PuTTY
1. Insert the microSD card into your Raspberry Pi
2. If using Ethernet – connect CAT5 cable from your home network to the Raspberry Pi.
3. Connect suitable power supply to your Raspberry Pi.
4. Turn power on – we should see solid red LED on Raspberry Pi illuminated (correct power) as
well as flashing green LED (program running).
5. Let us connect to the Raspberry Pi using PuTTY.
6. Open PuTTY using the desktop shortcut
7. We see the PuTTY Configuration window. We are going to enter the name we gave to the
Raspberry Pi into the Host Name box – for us it was MuonPi.local, next we are going to
connect to the Raspberry Pi by moving your mouse over the “Open” and click your left
mouse button to select.
Page | 28
8. We will now get a PuTTY Security Alert window, as this is the first time we have accessed
the Raspberry Pi. We are going to accept the notice and connect to the Raspberry Pi by
moving your mouse over the “Accept” and click your left mouse button to select.
9. This will bring us to a terninal window. We are going to login as “pi” and press return
Page | 29
10. We will then enter the password for the pi – PassWord, and now we are in the Raspberry Pi.
11. Two commands to start with
a. Type “sudo apt update” – to update the Raspberry Pi
Page | 30
b. There may be some packages that need to be updated and this will occur
automatically. You will also be informed if there are any packages that need
upgrading – in this case 20
c. Type “sudo apt upgrade” – to upgrade the packages
Page | 31
d. You will be asked if you want to continue – type Y and press enter to continue. The
packages will be downloaded automatically and installed on the Raspberry Pi
e. When upgrade has finished you may be informed that there are some packages that
are no longer needed – in this case none
Page | 32
12. We now need to set the Raspberry Pi up to be accessible through a Virtual Network
Connection “VNC”. We do this through the raspberry pi configuration program
13. Type “sudo raspi-config” and press enter
14. This command will open the Raspberry Pi Software Configuration Tool
Page | 33
15. We can use the arrow keys on the keyboard to move the red highlighted curser up or down
(mouse does not work). We want to highlight “3 Interface Options” and press enter
16. We now see the various interfaces available on the Raspberry Pi. We enabled SSH when we
configured the operation system on the microSD card. We now need to enable VNC.
Page | 34
17. We can use the arrow keys on the keyboard to move the red highlighted curser up or down
(mouse does not work). We want to highlight “I2 VNC” and press enter
18. You will then be asked if you wish to enable VNC Server – press the “tab” key to move the
red cursor over the <Yes> and press enter
Page | 35
19. You will then get a notification window to inform you that VNC server is enabled. Press enter
to proceed.
20. This takes you back to the Raspberry Pi Software Configration Tool main menue – use the
tab key to move the red cursor to <Finish> and press enter
21. We have now finished with PuTTY.
Page | 36
22. It is a good idear to reboot the pi. Enter the following command – sudo reboot and press
enter
23. We will get a message from PuTTY that we have lost connection with the Raspberry Pi – this
is okay
moving your mouse over the “OK” and click your left mouse button to select
24. You can also close the open PuTTY terminal window as this is no longer needed.
Page | 37
Installing VNC viewer on your PC
1. Use the following link to access VNC viewer:
https://www.realvnc.com/en/connect/download/viewer/
2. Move your mouse over “Download RealVNC Viewer” and double click
3. You may be asked, at this point, if you are human
Page | 38
4. Go to your Downloads folder and locate the VNC-viewer file you just downloaded.
5. Double click on the VNC-Viewer file to run and you will be presented with a VNC Viewer
Installer window. Select your appropriate language then move your mouse over the “OK”
and click your left mouse button to select
6. You will be presented with a VNC Viewer Setup window. Move your mouse over the “Next”
and click your left mouse button to select.
Page | 39
7. You will be presented with another VNC Viewer Setup window. Confirm you accept the End
License Agreement then move your mouse over the “Next” and click your left mouse button
to select.
8. You will be presented with another VNC Viewer Setup window. To install a Desktop
Shortcut, move your mouse over the red “X”click your left mouse button and select “Will be
installed on local harddrive”, then move your mouse over the “Next” and click your left
mouse button to select.
Page | 40
9. You will then be asked to confirm installation, move your mouse over the “Install” and click
your left mouse button to select.
10. You will be presented with a Windows confirmation screen. Move your mouse over the
“Yes” and click your left mouse button to select.
Page | 41
11. VNC Viewer Setup will finish installing and present the following window when complete.
Move your mouse over the “Finish” and click your left mouse button to select.
12. VNC Viewer will have made a short-cut desktop icon for you :
Page | 42
Connecting to your RPi using VNC Viewer
1. Let’s connect to the Raspberry Pi using VNC Viewer.
2. Open VNC Viewer using the desktop shortcut
3. We now have the VNC Viewer home page – we want to make a new connection so we select
“File” then “New Connection” or Ctrl-n short-cut
Page | 43
4. This will bring up the following properties window- we are only going to enter information in
the “General” tab
a. VNC Server: MuonPi.local
b. Name: “RPi4-muon”
Page | 44
5. You should now have a connection on your VNC workspace. Double click the icon
6. Similar to PuTTY – we now get an Identity Check message for our first connection to the
Raspberry Pi by VNC. We select “Continue”
Page | 45
7. We now have to enter the Raspberry Pi
c. Username: “pi”
d. Password: “PassWord”
e. Select “Remember password”
f. Select “OK”
8. You are now in your Raspberry Pi
9. Time to explore
10. To end VNC session – there are controls that appear when your mouse is moved to the top
of the screen. Selecting “X” will close the VNC session.
11. To get back to the pi, just double click on the shortcut in VNC workspace
Page | 46
Installing Visual Studio Code on your PC
1. Use the following link to access Visual Studio Code: https://code.visualstudio.com/
2. Move your mouse over “Download for Windows Stable Build” and double click (use the
down arrow head to select alternative operating systems)
3. Go to your Downloads folder and locate the VSCodeUserSetup file you just downloaded.
Page | 47
4. Double click on the VSCodeUserSetup file to run and you will be presented with a Microsoft
Visual Studion Code (User) License Agreement window. Click the radial buttom “I accept
the agreement” then move your mouse over the “Next” and click your left mouse button to
select
5. You will be presented with a Microsoft Visual Studion Code (User) Select Destination
Location window. Move your mouse over the “Next” and click your left mouse button to
select.
Page | 48
6. You will be presented with a Microsoft Visual Studion Code (User) – Select Start Menu
Folder window. Move your mouse over the “Next” and click your left mouse button to
select.
7. You will be presented with a Microsoft Visual Studion Code (User) – Select Additional
Tasks Window. Check the square “Create a desktop icon” then move your mouse over the
“Next” and click your left mouse button to select.
Page | 49
8. You will be presented with a Microsoft Visual Studion Code (User) – Ready to install
Window. Move your mouse over the “Install” and click your left mouse button to select.
9. Microsoft Visual Studion Code (User) will now be installed on your PC. When completed
you will be presented with a Microsoft Visual Studion Code (User) – Completing the Visual
Studion Code Setup Wizard Window. Move your mouse over the “Finish” and click your left
mouse button to select. This will run VS Code.
10. You can also run VS Code by double clicking on the desktop icon
Page | 50
Simple configuration of Visual Studio Code on your PC
1. double clicking the VS Code icon on your desktop
2. You should get a screen similar to the following
Page | 51
3. We want to add Python to Visual Studio, so we move our mouse over the extension ison on
the LHS and left click our mouse
4. You can type the name into the Search bar – for me Python is already showing – I am going
to select the Microsoft Python extension by moving the mouse over it and left click mouse.
Page | 52
5. This will install the Python extension
6. I now need to set up a workspace. Move your mouse over the Explorer icon on the left hand
side and left click your mouse
Page | 53
7. I now want to open a folder where I will have my python code. I have a folder on my
desktop called “Python_Code”. I move my mouse over the Open Folder tab and left click
mouse I navigate
to my folder and select “Select Folder”.
8. I will be asked if I trust the authors of the files in this folder – I am going to select “Yes, I trust
the authors”
9. I am now ready to start programming in python.
Page | 54
First python code on your PC
1. Move your mouse over PYTHON_CODE and some icons will appear
Move your
mouse over the New File icon and left click your mouse.
2. You will be asked to give your python code a name – test.py
Page | 55
3. We can now type some code into the new window and Ctrl S to save it.
4. To run the code we move our mouse over the run icon at the top right hand side and press
left mouse
Page | 56
5. If all goes well we will have a terminal window appear with the results of our python code
6. First program done.
Page | 57
Connecting Visual Studio Code on your Raspberry Pi
1. We need to install an additional extension to enable us to remotely connect to our
Raspberry Pi over our home network.
2. From inside VS Code, we need to install the Remote SSH extension. Select the Extension tab
from the sidebar menu, then search for Remote development. Select the Remote
Development extension, and select the Install button
3. Next we can connect to our Raspberry Pi. Launch the VS Code command palette using
Ctrl+Shift+p. Search for and select Remote SSH: Connect current window to host.
Page | 58
4. Enter the SSH connection detail, using user@host – e.g. pi@MuonPi.local. The first time you
connect, it will validate the fingerprint to ensure you are connecting to the correct host.
Select “Linux” and press enter.
5. Enter your Raspberry Pi’s password when prompted.
6. VS Code will then install relevant tools on the Pi and configure the remote SSH connection.
7. You should now be set up and ready to go
Page | 59