When I first got started with Raspberry Pi, I got really frustrated about all the tutorials which skipped over steps and assumed knowledge.
Please find below the super simple step-by-step, no prior knowledge assumed, no steps skipped instructions.
I am using a Raspberry Pi 3a in the below example, but it should be the same for any of the Pi 3 or Pi 4.
The process is also the same on the Pi Zero, but note three things if you're buying the zero: it can be pretty slow so unless you are super cash constrained or building something which needs a tiny form factor, splash out for the 3; get the one with pre-soldered headers; make sure you get the Zero W (as it includes wifi).
Step 1: Download the Raspberry Pi OS to an SD CardOn your PC or Mac, download and run the Raspberry PI imager application.
Insert the SD card you want to install the Raspberry Pi operating system on.
Click on CHOOSE OS and select the default Raspberry Pi OS (note: this used to be called Raspbian, which is what you see in the image above - it is now called Raspberry Pi OS, which is the same thing, just a different name).
Click on CHOOSE SD CARD and select the SD card you have plugged in.
Click on WRITE. This may take a while.
Once it's done it will tell you to remove the SD card, which you should do. But then plug it back in as there's a few points of housekeeping you need to do first.
Step 2: Enable SSH on Your Raspberry Pi OS ImageOnce the OS has been written to the SD card, there are a few additional tasks you need to do.
We want to access the Raspberry Pi without plugging in a keyboard or monitor (aka "headless"), which we can do over our local network using our PC or Mac over a protocol called SSH. However, for security reasons SSH is disabled by default. We need to enable it.
We can do this by creating an empty file called:
ssh
in the SD card we just created. It's important that this doesn't have any sort of extension (eg.txt). The file itself doesn't need to contain any content - just its existence will enable SSH when the Pi boots up.
You can skip this step if you plan to wire your Raspberry Pi to your router by ethernet. (Although you might want to think hard about that decision - having it run over wifi makes life a lot easier in terms of positioning this - and note that if you subsequently change your mind and want to run it on wifi then your IP address will change)
Create a plain text file called wpa_supplicant.conf in the root directory of the SD card.
Insert the below text into the file:
country=gb
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="MyNetworkSSID"
psk="MyPassword"
}
Change the country as appropriate (gb is the UK, us is the US, de is Germany, etc)
Change the wifi credentials in there to be your actual wifi router details.
(Note that the SSID and password need to be inside quotes in the file)
Save the file to the SD card.
Safely eject the SD card.
(If you're having issues creating these files then you can download ready made versions here: https://github.com/hankhank10/raspi-headless-files/)
Step 4: Power Up Your Raspberry PiPut the SD card you just created into your Raspberry Pi.
Plug your Raspberry Pi into power via the USB cable. Wait a minute for it to boot up.
Step 5: Find the IP Address of Your Raspberry PiYou now need to find the IP address of the Raspberry Pi so you can connect to it. You can do this in two ways:
- via your router setup page - if you have a modern router like eero then this is super easy;
- or via a smartphone app available for iOS and Android called "fing" - download it, connect to your router and scan for devices - one of them should be called "Raspberry" or perhaps "Generic" - this will be the IP address you need.
Open Terminal on your mac (or if you're using Windows then download and use Putty).
Enter the following command:
ssh pi@YOUR.PI.IP.ADDRESS
Obviously changing the above YOUR.PI.IP.ADDRESS for your actual Pi IP address which will be something like 192.168.4.104.
Accept any security warnings you get. You will be prompted for the password for the default pi user which is
raspberry
Step 7: Set Up the Raspberry Pi OS GUI (optional)You are now connected to your Pi via the command line, which is great but you may also want to set it up so you can access the Graphical User Interface which we will access via VNC (Virtual Network Computing). Predictably, we also need to enable this.
First of all check your Pi software is up to date by entering the following commands (each followed by enter) into the command line:
sudo apt update
sudo apt upgrade
sudo apt install realvnc-vnc-server realvnc-vnc-viewer
Next, open up the Raspberry Pi settings menu by entering:
sudo raspi-config
Navigate to Interfacing Options > VNC > Yes.
Exit the config application by pressing the escape key and reboot the Pi from the command line by typing:
sudo reboot
Step 8: Connect to and Setup Your Raspberry Pi GUI (optional)Download and open VNC Viewer.
Type in the IP address for your Raspberry Pi and press connect. It will prompt you for username and password which are:
Username = pi
Password = raspberry
This should boot you up to the GUI.
It will prompt you to confirm your geography and keyboard layout.
It will then prompt you to change your password (good idea).
It will ask you to set your wifi details, but you can skip this as they're already working. (Although if you're running on ethernet and having second thoughts then now is your chance... but note your IP address may change)
It will then check for, download and install updates (might take a while).
Once you are through the setup wizard I would recommend changing the screen resolution as the default is pretty small. You can do this by clicking the Raspberry at the top left > Preferences > Raspberry Pi Configuration > Display > Set Resolution
You will need to reboot the Pi yet again to get this to take effect.
Step 8b: I've enabled VNC but it says it can't display the desktop?Sometimes when connecting via VNC for the first time it will boot up in a tiny window and say it can't display the desktop.
You can fix this by setting the resolution in raspi-config. Go back to your command line through SSH and type:
sudo raspi-config
Go to 7: Advanced Options > A5 Resolution and choose something reasonable for your screen like 1280x720. Then exit out of raspi-config and reboot using
sudo reboot
Congratulations!Your Raspberry Pi is now up and running in "headless" mode. You can connect to it in future using SSH (via Terminal or Putty) or VNC.
Enjoy!
Now you could try a couple of projects. I recommend:
Comments