How to setup your Raspberry Pi, Headless!

Bought your Pi, but no Monitor, mouse or Keyboard. Make it Headless!

projectImage

Things used in this project

 

Hardware components

HARDWARE LIST
Raspberry Pi (Any Model)
USB Cable, USB Type C Plug
Flash Memory Card, MicroSDHC Card

软件应用程序和在线服务

 

Raspberry Pi Imager

 

NMap

 

VNC Viewer (REALVNC)

Story

 

Setting up your Raspberry Pi (RPi) can be excruciating. I know because I also experienced it. This method can save you a lot of money and make it easier to work on you RPi on the go. There are many articles in the internet about this. But this is the one that has it 'All in one place'.

READ: Read all the Information before starting to do this practically.

 

1. Installing Raspberry Pi OS to SD card.

 

Go to the RPi official webpage by the link below:

 

https://www.raspberrypi.com/software/

 

Scroll down till you find the 'Download' button below.

projectImage

Click the 'Download' button for your Computer's Operating System.

 

Install the RPi imager on your Computer.

 

2. Write the OS into your SD Card.

 

Connect your microSD card to your computer. (You might need to use a SD Card Adapter).

 

Open RPi installer, and Click 'Choose OS'.:

 

Click on 'Raspberry Pi OS (32-bit)'/The one on the top.

projectImage

Click 'Choose Storage' and select your SD Card reader.

 

In case a pop up saying that all data will be erased opens up, accept it, after saving necessary files.

 

Click 'Write', Then wait it writes and verifies the OS.

3. Preparations

 

'Eject' the MicroSD card and take it out of you computer, Immediately followed by inserting it to the computer again.

 

Make a file called 'wpa_supplicant.conf', in your computer.

 

Copy and Paste the Following code in the file.

CODE
ctrl_interface=DIR+/var/run/wpa_supplicant GROUP=netdev
update_conig=1
country=<Your country code eg:-US/GB>
network={
	ssid="Your Network Name (SSID)"
	psk="Your network password"
	scan_ssid=1
} 

Make a empty file named "ssh" without the quotation marks, and without a file extension in Notepad. For this, you should type as "ssh" (with quotations) in the 'File Name:' and 'All Files (*.*)' in 'Save as type' sections.

 

This will save the file extension-less and quotation-less.

 

Image:

projectImage

4. Connect RPi to the Internet.

 

Copy and Paste the two files, 'wpa_supplicant.conf' and ssh into the boot folder in your microSD card.

You will see that some files are already in the boot (The Operating System).

After the 2 files are in the boot, take out the SD card.

Still, do NOT insert it into the RPi.

 

 

5. Install NMap on your computer.

 

Go to the following link, download and install Nmap on your computer:

https://nmap.org/download.html

 

 

6. Install VNC Viewer on your computer.

 

Go to the following link, download and install VNC Viewer on your computer:

https://www.realvnc.com/en/connect/download/viewer/

Make sure you install 'VNC Viewer', and NOT 'VNC Server'

 

 

7. Insert your microSD card into your RPi

 

Go ahead and get your microSD card from your SD card Adapter, and plug it into your RPi.

projectImage

Then plug in your RPi into it's power source.

 

 

 

8. Find your RPi's IP Address.

 

Open your computer's terminal window.

 

I use 'Command Prompt', but you can use terminals such as 'Windows Powershell'.

 

Open Settings and go to:

 

Setting > Network and Internet > Wi-Fi > Properties > IPv4

 

In IPv4, you will find the IP address of your Computer.

 

It will look like: xxx.xxx.x.x (X's are numbers in reality)

 

In your terminal, type:

CODE
nmap -sn xxx.xxx.x.0/24

Use '0/24' instead of the last number after the last period (decimal point) of your IP, This will run through all the IP Addresses in your router, to find the RPi.

 

Hit Enter.

 

You will find your RPi's IP address, if you didn't find it, repeat it after a minute till you find the IP, listed next to an item, 'raspberrypi'.

projectImage

Note down the IP of your RPi, in this case, it's highlighted, xxx.xxx.x.14 (The X's are still numbers)

 

9. Get into you Pi

 

After that use your terminal to get into your RPi's terminal.

Type on your terminal:

CODE
ssh pi@'IP'

Use the RPi's IP that you got, instead of 'IP' (xxx.xxx.x.14 is the number that I got, your number can be different.) .

 

Then you will find a prompt asking for your password.

 

The default password is raspberry (You will not see it being typed for security reasons)

 

Type it in, hit Enter and:

projectImage

Voila!

 

10. View desktop of RPi (Finally!)

 

Launch VNC Viewer on your computer, type your RPi's IP:

projectImage

Press Enter.

 

Type in your username : pi

 

If you have not changed your RPi password yet, your Password is: raspberry

 

You should now see your Desktop:

projectImage

If I Don't see your desktop?

 

It is completely normal if you had an error message now, I got it too!

 

You might be thinking 'I did all of this for an error!'. But fixing it is relatively simple.

 

Option 1 (Recommended)

 

Get onto the RPi terminal using step 9, Then type:

CODE
sudo raspi-config

Go to 'Display options' and hit Enter:

projectImage

转到“ VNC 分辨率”,然后选择并确认“ 1280x720”(我不知道为什么,但该分辨率似乎适用于所有人):

projectImage

Go to 'Finish', enter it and it will ask you to reboot. Press Enter, when the pink selector is on 'Yes'.

 

Now the connection will be interrupted because of the reboot.

 

Now, try to do step 11.

 

Step 2 (If step 1 didn't work)

 

If it didn't work, it's completely normal. I didn't get the desktop too.

 

Redo step 9, to go to the RPi terminal, if it doesn't work, repeat after a minute.

 

On the RPi terminal, type:

CODE
sudo apt-get install lxsession

After LXSession is installed, type:

CODE
sudo reboot

to reboot your RPi.

 

Now, try to do step 11.

 

It should work by now and a 'Startup wizard' will appear.

 

Congratulations!

 

You finally opened the door to your Raspberry Pi, and it's many wonders.

 

If you got stuck after any step, please leave a comment.

 

Thank You for staying till the end.

The article was first published in hackster, November 27, 2021

cr: https://www.hackster.io/435738/how-to-setup-your-raspberry-pi-headless-8a905f

author: danushi13, 45132594

License
All Rights
Reserved
licensBg
1