logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Raspberry Pi

Introduction to Raspberry Pi 4: Mastering the Use of the Raspberry Pi 4 in Headless Mode!

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at May 25, 2020
Categories
  • Raspberry Pi
Tags
connecting raspberry pi

In this series, we are using the latest, high-performance Raspberry Pi 4 Model B to review once again everything from the Raspberry Pi setup to the fundamentals of electronic kits.

In this lesson, we will setup a screenless (headless) remote connection, which we will frequently use going forward. This will enable us to use the Raspberry Pi anywhere and learn the basic commands of the Raspberry Pi.

Items needed for this article

Raspberry Pi 4 Model B
raspberry pi4

For other necessary components, refer to the first lesson article.

Steps in this article:

1. Directly installing Raspbian Buster on the Raspberry Pi 4
2. Setting up the Raspberry Pi in a completely headless mode
3. Configuring the Raspberry Pi environment settings from the command tool
4. Summary

1. Directly installing Raspbian Buster on the Raspberry Pi 4

Placing NOOBS on the SD card and ran the Raspberry Pi setup from there while viewing the screens over an HDMI connection is the most intuitive way to use the Raspberry Pi in a simple manner like a PC. However, it is convenient to know how to operate the Raspberry Pi remotely from another PC or iPad, etc. to take advantage of its compact size to program it from anywhere or implement active electronic kits. A method for setting up the Raspberry Pi in a completely screenless (headless) mode will be explained in detail below.

We will go to the Downloads screen on the official Raspberry Pi page. This time, we will choose the Raspbian option on the right side instead of NOOBS.
https://www.raspberrypi.org/downloads/
downloading raspbian

This Raspbian option allows you to download what is called an OS image file. This option includes three different packages. There is the full OS which was also installed with NOOBS (upper left of the image below), the Desktop version (upper right), and the Lite version (lower left) which does not come with a Desktop. The size of the Full OS is 2.5 GB while the Lite version is 430 MB. Using the Lite version allows you to build a lightweight Raspberry Pi which uses absolutely no screens and the smallest size SD card.
raspbian options

Select the full OS ZIP file here and download it to your PC, etc.
Next, open the archive using Unzip, etc. to extract the image file (.img).
extracting image file

We will write this image file to the SD card. Insert the SD card into the PC, etc. Here we are using a 32 GB micro SD card which is not the same card used for the NOOBS install. (Be careful not reuse the same card, because the contents will be overwritten!)
SD card

Writing the image file on a Mac:

When using a Mac, open the Console and enter the following command (blue text).
First, confirm the location where the SD card is recognized with the diskutil command. In this example, the SD card is recognized as the 32 GB disk under /dev/disk2 (yellow text).
checking micro SD

Now unmount this disk2. When you run this command, the disk disappears from the screen.

Next, use the dd command to write the OS image to the SD card. When doing so, be careful to specify the correct disk in the “of=” part of the command. When selecting a Mac disk, it is completely overwritten.

When writing the full OS, it may take several minutes. At the end, the “transferred” message shown in yellow above appears. If a boot directory is displayed on the screen, then the write process is complete.

image writing process complete
[If boot appears, then the image write process is complete]

Writing the image file on a Windows PC:

On Windows, we will download and use a disk writing tool such as Win32 Disk Imager.
Obtain the zip file from this link, extract the file, and double-click it in Windows to launch the tool.
https://sourceforge.net/projects/win32diskimager/
disk writing tool

The following screen appears when Disk Imager starts. Specify the image file from before in the Image File section. Specify the SD card disk under Device and press the “Write” button below to write the image file.
disk imager

The Raspbian Buster OS should now be directly installed to the SD card.

2. Setting up the Raspberry Pi in a completely headless (screenless) mode

The OS is on the SD card, but there is a way to start setting up the Raspberry Pi in a completely headless (screenless) mode even without an HDMI connected display.
After writing the Raspbian image file, move to the boot disk on the SD card from the PC. Use the Console or Explorer to create a file called “ssh” without an extension directly under the boot disk. You do not need to write anything inside the file. When this ssh file is placed under the boot disk, a secure ssh connection is enabled (ssh is disabled under the OS default settings) when this disk is read for the first time by the Raspberry Pi, which will enable you to immediately establish a remote connection even without a screen-based setup.
Moreover, placing a file called “wpa_supplicant.conf” directly under the boot disk will load this file during the initial startup and enable Wi-Fi without using the graphical interface.


[Placing ssh and wpa_supplicant.conf directly under boot]

The following type of information about the Wi-Fi connection must be written in the wpa_supplicant.conf file. Fill in the appropriate information about your wireless network and save the file.

[wpa_supplicant.conf file sample entry]

Insert the SD card which contains the ssh and wpa_supplicant.conf files into the Raspberry Pi. Turn on the power (in this case, the power is supplied by the Mac) to the Raspberry Pi without connecting an HDMI screen or keyboard, etc.
connecting raspberry pi
The PC you are using should be connected to the same network as the Wi-Fi environment described in the wpa_supplicant.conf file above.

Now we will launch the Console from the PC. To establish an ssh (secure connection) connection from the Console, enter the command “ssh pi@” (connection name of the Raspberry Pi). The default user name is “pi” and the connection name is “raspberrypi.local”. When asked for the password as shown in the yellow text, enter the default password “raspberry”.

When the password is entered, you can connect to the Raspberry Pi without an HDMI screen.
Enter the “ls” command on the Raspberry Pi to view the folders directly below Home.

3. Configuring the Raspberry Pi environment settings from the command tool

Now you can remotely connect to the Raspberry Pi. Users who installed the OS using NOOBS in the previous lesson can also connect in a screenless manner using the same method by enabling ssh from the screen. If you have changed the host name and password from the screen, login using the updated information.

So let’s continue the Raspberry Pi setup over the remote connection. You can perform the basic setup previously conducted from the screen by entering the command “sudo raspi-config”.

The Software Configuration Tool launches when running raspi-config. This tool includes nine menus.

[Software Configuration Tool Menus]

  1. Change User Password
  2. Network Options
  3. Boot Options
  4. Localisation Options
  5. Interfacing Options
  6. Overclock
  7. Advanced Options
  8. Update
  9. About raspi-config

Here we will change the password and host name (1 and 2) as we did from the screen interface.


In addition, we will select “4. Localisation Options” to configure the language and keyboard settings.

Select “I2. Change Timezone” and set it to Tokyo time.

Also select “5. Interface Options” to configure the camera and other settings.

The P2 SSH setting should already be set to “Enable,” so enable the P1 Camera so that it can be used when connected. Also enable the P5 I2C setting for connecting external devices to be able to recognize sensors which support I2C.

Finally, when you navigate to at the bottom of the screen and press Enter, you will be asked if you wish to restart and enable all of the changes by rebooting.

Connect to the Raspberry Pi over ssh once again after it restarts.
This time, we will update to the latest Raspberry Pi and libraries by using the “apt update” and “upgrade” commands.

It may take some time when you run these commands for the first time. However, this will also allow you to check the Internet connection and update the Raspberry Pi to the latest version.

4. Summary

In this lesson, we installed and setup the Raspberry Pi over a remote SSH connection without connecting an HDMI screen or keyboard. This method might not be very elegant, but we will continue to remotely connect to the Raspberry Pi and run commands, so be sure to remember how to do this.

In the next lesson, we will finally cover electronic kits using the Raspberry Pi 4.
Please look forward to it!

DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Introduction to Raspberry Pi 4: Tackling the Basic Electronic Kits With the Raspberry Pi 4!Introduction to Raspberry Pi 4: Tackling the Basic Electronic Kits With the Raspberry Pi 4!
  • Introduction to Raspberry Pi 4: Let’s Start Using the New “Raspberry Pi 4!”Introduction to Raspberry Pi 4: Let’s Start Using the New “Raspberry Pi 4!”
  • The History and Uses of Raspberry Pi!The History and Uses of Raspberry Pi!
  • Review of the Raspberry Pi 2 and Comparison with Previous Raspberry Pi ModelsReview of the Raspberry Pi 2 and Comparison with Previous Raspberry Pi Models
  • DIY Tip: How to Set Up Your Raspberry PiDIY Tip: How to Set Up Your Raspberry Pi
  • Sensor Input Experiment Using Raspberry PiSensor Input Experiment Using Raspberry Pi
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort