Control Raspberry Pi Without Monitor.

by Harsh Dethe in Circuits > Raspberry Pi

10292 Views, 19 Favorites, 0 Comments

Control Raspberry Pi Without Monitor.

20190424_105344_0000.png

In previous instructable I shared a beginners guide to Raspberry Pi. There we saw how to boot Raspbian onto the Pi and use it as a desktop. But for that setup we require a lot of peripherals like monitor, HDMI cable, wireless keyboard and OTG adapter. Most of the time we don't need these peripherals after the first boot. To save some money we can use the Pi in Headless mode i.e accessing it without a monitor.
In Headless mode, we can access the Raspberry Pi over wireless network using SSH (Secured Shell Protocol). So without wasting anymore time, lets get right into it.

Requirements:

IMG_20190419_094643.jpg

Before getting started, we need to gather some hardware and software for this project.

Hardware Components:

1. Raspberry Pi

2. Micro SD card ...........................(Amazon US / Amazon EU / Banggood)

3. Micro SD card reader ................(Amazon US / Amazon EU / Banggood)

Software:

1. Raspbian OS

2. PuTTY for Windows

3. Fing App

Enabling SSH With Monitor:

This method is for those who have a monitor and other peripherals. You guys just have to install Raspbian on a SD card and insert it into a Pi. Check out this tutorial if you want to learn how to install Raspbian. After successfully installing the OS on the SD card, insert into the Pi and boot it up.

  1. After the Pi is booted, click on the the raspberry icon on top left corner. You will see a drop-down menu, from this menu select "Preferences". From the second drop-down menu, select "Raspberrypi configuration".
  2. A pop up window will appear, Select "Interface" tab.
  3. Next, enable Camera, I²C, GPIO and SSH. These are the features we will be using the most.
  4. The Pi is now ready to be controlled without monitor and keyboard.

Enabling SSH Without Monitor:

PicsArt_04-23-02.16.07.png

Now to enable SSH without a monitor, follow the steps below:

  • Install the Raspbian image onto the SD card similar to the previous tutorial.
  • After the image is burnt, do not plug out the card. Instead open the boot partition. Note that windows might ask you to format the drive, say no or cancel it. DO NOT FORMAT THE PARTITION.
  • In the boot partition, there are many files and folders. Do not edit or delete any files from here, or else it might cause system failure.
  • Here we have to add two files, SSH and wpa_supplicant.conf
  • Firstwe need to create the SSH file, right click in the boot partition and click on "new", from the list select "New text document". Name the file ssh and remove the ".txt" extension. Next save the file. This file will enable SSH allowing us to connect to the Pi using PuTTY.
  • Nextcreate a new text document and name it "wpa_supplicant.conf" and save the file.
  • Open the wpa_supplicant file in a text editor and add the following script:
country=IN 
ctrl_interface=DIR=/var/run/wpa_supplicant 
GROUP=netdev 
update_config=1 
network={ 
ssid="Your WiFi network name" 
scan_ssid=1 psk="WiFi password" 
key_mgmt=WPA-PSK 
}
  • In the script you have to make some changes. In the first line country=IN , I wrote IN because I am from India, and the ISO code for India is IN. You can find the code of your country from Wikiwand. Next add your ssid which is nothing but your WiFi name. Also add psk which is your WiFi password. When you're finished, be sure to save the file.
  • Now eject the SD card and insert it into the Pi. Power up the Pi and wait for a few minutes. It takes longer to boot for the first time.

Finding the IP Address:

PicsArt_04-24-01.24.45.jpg

Before we can SSH into Raspberry Pi, we need to know the IP address of the Pi. To find the IP address I prefer using an app called Fing. It is available for both Android and iPhone. To find the IP address:

  • First make sure your smartphone is connected to the same WiFi network as the Pi.
  • Open the Fing app, on the home page you will notice a list of devices connected to the router.
  • Note down the IP address of "raspberrypi". We will use this to establish connection with the Pi.

Now we will connect to the board using SSH in the next step.

SSH Into the Pi:

PicsArt_04-23-02.19.58.png
PicsArt_04-23-02.23.49.png
PicsArt_04-23-02.25.32.png

If you are using Windows, I recommend using PuTTY. Just download and install it as any other application. For Linux users, SSH is already available. Just open up a terminal window, and type the command "ssh" to see if it's working.

SSH using PuTTY For Windows Users:

  • First power up the Raspberry Pi using a 5v power supply. It should connect to your WiFi network within a couple of minutes.
  • Now open PuTTY and enter the IP address of Pi and click on “Open”.
  • In a few seconds a window will pop-up where we have to enter the username and password. The default username is “pi” and password is “raspberry”.
  • Note that you cannot see password in the terminal so type slowly or you will keep getting “Access denied”.
  • After successfully logging in you will see a terminal window. Now you can connect to your Raspberry Pi using SSH! say goodbye to that extra keyboard, mouse, and monitor!

For Unix Users: (Linux and macOS)

  • To create SSH connection in Linux, open terminal and enter the ssh command.
ssh pi@192.168.xx.xx
  • Here you will add your IP address and hit enter.
  • Next, you'll be asked if you want to connect to the device. Type y.
  • Then you will be asked to enter the password, type in the default password “raspberry”.

And that should get you into the Raspberry Pi terminal. Now one last thing to do is securing the Pi.

Securing the Raspberry Pi:

The Raspberry Pi boards have same username and password by default. Therefore, it can be vulnerable to hackers. To prevent any unauthorized access to our Pi, we will change the default password.

To change the password:

  • Type passwd and hit enter.
  • You will be asked to enter the current password for authentication. Enter the default password raspberry and hit enter.
  • Now you will be asked to enter new password, here enter a unique password with a combination of alphabets, numbers and special characters. When you type the password, nothing will be displayed on terminal, so make sure you type slowly and correctly.
  • After you enter new password, you will be asked to confirm the password. Here type the new password again and hit enter.
  • A success message will be displayed on terminal:
passwd: password updated successfully

This indicates that the new password is applied.
This process will make the Pi secure. If you want to learn more about Users and Passwords check out this post on Raspberry Pi's official website. It will give you more in depth instructions.

Final Note:

Now you are ready to use your Raspberry Pi with SSH. In next tutorial, we will see how to use the GPIO pins on our Pi to control LEDs.

Don't forget to check out my ebook "Mini WiFi Robot" if you haven't already. It will take you through all the steps to design your own custom robot.

Hope you find this tutorial informative. If you have any doubts, feel free to ask in the comments.