Login

Headless Setup of Raspberry Pi

Objectives

  • Enabling the server configuration of Raspberry Pi
  • Connect to Raspberry Pi via Secure Shell (SSH)
  • Connect to Raspberry Pi via PuTTY
  • Access Raspberry Pi from a remote computer

Things

For this project we will be needing the following components and software

  1. Raspberry Pi 3B (quantity: 1 no.)
  2. microSD card (quantity: 1 no.)
  3. 5V power adapter and Micro USB cable A to B (quantity: 1 no.)
  4. WiFi router / mobile hotspot (quantity: 1 no.)
  5. Raspibian Stretch
  6. SD Card Formatter software and BalenaEtcher software
  7. Wireless Network Watcher.
  8. VNC Viewer software
  9. PuTTY.

Let’s Begin!

The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote teaching of basic computer science in schools and in developing countries.

It does not include peripherals (such as keyboards and mice) and cases. However, some accessories have been included in several official and unofficial bundles.

Now let us get started with setting up the Raspberry Pi.

SD Card Formatter

In the following units we prefer using the Raspbian OS as it is more flexible and preferred OS for the Raspberry Pi (RPi).

To install the Raspbian OS on the sd card make sure the sd card is formatted as it already has the NOOBs OS installer in it, if the sd card came along with the RPi. Here we will use the SD Card Formatter to format the sd card and install the Rasbian OS.

Step 1: Preparing SD Card: Go to this link and click on “accept” to download “SD Card Formatter”.

Step 2:  Extract and Install the “SD Card Formatter” by running the downloaded “.exe” file.

Step 3: Connect a 8 GB/16 GB/32 GB SD card with your Laptop using an SD Card Holder, run the “SD Card Formatter” and format completely.

 

Next step is to flash the SD card with the Raspbian software. To  do that follow the steps below:

Step 1: Downloading Operating System for Raspberry Pi: Click on this link and download the latest version of Raspbian OS. Save the zip file.

Step 2: Once the file is downloaded, right click on it and extract. You will find an “.img” file in it named similar to “2018-11-13-raspbian-stretch.img”.

Step 3: Burning the image onto the SD Card: Run “Etcher”, click on “Select Image” and select the “2018-11-13-raspbian-stretch.img” file mentioned above.

Step 4: Once you select the Image, it automatically selects the SD card. If the selected card is not correct you can change it by clicking on “change” option.

Step 5: Now click on “Flash” to start the installation of Raspbian in the SD card.

Once the installation is compete, create “ssh” file for headless operation of RPi.

Step 1: Enabling SSH on Raspberry Pi: Create a file named “ssh” (the file does not expect any extension) in the boot partition, not the /boot directory in the main partition of the SD card. When the Pi is first started, it checks if the file exists and activates the SSH accordingly.

Step 2: Configuring the Raspberry Pi to your Wi-Fi router: To configure the Wi-Fi connection when starting the Pi, connect the microSD card to your computer and create a wpa_supplicant.conf file in the boot disk. Enter the following lines in the file:

update_config=1
ctrl_interface=/var/run/wpa_supplicant
country=IN

network={
    scan_ssid=1
    ssid="SSID"
    psk="PASSWORD"
}

Step 3: Replace SSID and PASSWORD with the name and password of your WiFi network or hotspot.

Step 4: Now, your SD card is ready for the first boot.

Step 5: Insert SD card in the slot given in the Raspberry Pi.

Step 6: Power it on using micro USB adapter with appropriate rating – 5V, 2A.

Step 7: First boot might take a few minutes (usually 4-5 minutes).

Step 8: Upon its first boot, the Raspberry Pi would have got connected to your network.

Step 9: In order to check its IP address, use Wireless Network Watcher or any other software you are used to. Make sure that both your laptop and RPi are connected to the same network. Download

Step 10: Now, use PuTTY to SSH into your RPi. Download

Step 11: Type the IP address of the RPi into the ‘Host Name’ field and click the ‘Open’ button. Click “Yes” when the Security Window pops up.

Step 12:  You will now see the usual login prompt. Use the default login for Raspbian i.e. “pi” with the password “raspberry”.

Note: When you are typing your password, the screen will appear blank and no characters will appear on your screen. This feature exists to protect your password. So you type your password and press Enter even if nothing appears on screen beside “password”.

There you have it.

Remote Desktop using VNC

If you are not comfortable using Raspberry Pi from command line (Terminal), you can access the GUI desktop using VNC viewer.

Step 1: Since you have access to the Terminal of RPi using PuTTY, install VNC on it by typing following command.

sudo apt-get update
sudo apt-get install realvnc-vnc-server realvnc-vnc-viewer

Step 2: After installation, enable VNC Server at the command line using rasp-config

sudo raspi-config

Step 3: Now, enable VNC Server by doing the following:

  • Navigate to Interfacing Options.
  • Scroll down and select VNC > Yes.
  • Exit raspi-config by navigating to Finish.

Step 4: Next, On your Laptop/PC, you will need to download and install VNC Viewer so that you can access the desktop of the Raspberry Pi.

Step 5: Once installed, you need to start a New Connection

Step 6: Enter the IP address of your Raspberry Pi and click OK. Then double-click to open the newly created connection.

Once you open it, the graphical desktop will look like this

 

We would love to see what you build out of these learnings!

Click here to submit your projects, share it with the world and stand a chance to be rewarded.

top

Knowledge and Content by Li2 Technologies | © 2021 NASSCOM Foundation | All rights reserved

X