Index>Robot Kit>RaspArm-S Kit for RPi>Lesson 1 Installing and Logging in to the Raspberry Pi System

Lesson 1 Installing and Logging in to the Raspberry Pi System

4293

In this lesson, we will learn how to install and remotely log in to the Raspberry Pi system under Windows. And we will download the code program to control the robot.

1.1 Preparation

(1) When studying this lesson, you need to prepare the following components first:

One SD card that has been formatted (we recommend using an SD card with memory above 16G), 1 card reader, Raspberry Pi development board.

(2) You need to insert the SD card into the card reader first, and then connect the card reader to the computer.


1.2 Downloading the Raspberry Pi system Raspbian

Raspbian is the official OS of the Raspberry Pi Foundation. It is customized based on Debian GNU/Linux and can run on all versions of the Raspberry Pi motherboard. According to the experience, Raspbian combines Raspberry Pi the best. It is stable, powerful, and easy to use. It can basically meet the needs of various applications. This course uses Raspbian as the preferred OS for the Raspberry Pi. Next, we will teach you how to download the Raspberry Pi OS Raspbian. Now there are two ways to download Raspbian for Raspberry Pi OS (we recommend Method One).

Method One :

Raspberry Pi officially provides a Raspberry Pi OS - Raspberry Pi OS (Legacy) for educational and industrial users. The operating system has stable compatibility, and there will be no incompatibility with specific dependencies due to the update of the Raspberry Pi system. It also avoids frequent revision of the tutorial.

Raspberry Pi official description of the Raspberry Pi OS (Legacy):

https://www.raspberrypi.com/news/new-old-functionality-with-raspberry-pi-os-legacy/

1. visit the official website of the Raspberry Pi through a browser to download Raspbian: 

https://www.raspberrypi.com/software/operating-systems/

After entering the Raspberry Pi official website page, click "Raspberry Pi OS (Legacy)" to jump to the corresponding location, or you can find the location of Raspberry Pi OS (Legacy) by sliding the page.

image.png 

2. Select the Raspberry Pi OS (Legacy) with desktop version, which contains a complete desktop system and recommended software packages.

image.png 

3. Click "Download", download the ".ZIP" file, and wait for the download to complete: (remember where the file is saved).

4. Find the ".ZIP" file you just downloaded, and extract it. The uncompressed file format of the file is ".img". Pay attention, you must name the path of the uncompressed .img file all English letters without special characters.

image.png 

 

Method Two:

Due to compatibility issues with the latest Raspberry Pi official image file and the camera. It may cause an error when the Raspberry Pi runs the program. We recommend downloading the official older version of the Raspberry Pi image.(This image file will not change and has been tested in detail and successfully).

Using this image is a good idea to try if you run into problems with dependent libraries in the following lessons.

 

Raspberry Pi old version image file (2021-5-07) download address:

 https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2021-05-28/

image.png 

After the download is successful, extract the ZIP file and get a ".img" file. 


1.3 Burning the downloaded Raspberry Pi system to the SD card

We recommend using the Raspberry Pi Imager tool officially provided by the Raspberry Pi. Raspberry Pi Imager is a new image burning tool launched by the Raspberry Pi Foundation. Users can download and run this tool on Windows, macOS and Ubuntu to burn the system image for the Raspberry Pi. Its usage is similar to Etcher and win32diskimager.

1.3.1 Downloading Raspberry Pi Imager

(1) Visit the official website of Raspberry Pi to download through a browser:

https://www.raspberrypi.org/downloads/

Click "Raspberry Pi Imager for Windows" to download. Wait for the download to complete.

image.png


(2) Open the downloaded file "imager.exe" and click "Install".

image.png


(3) Then click "Finish".

image.png


(4) The software interface after opening is as shown below:

image.png


1.3.2 Burning Raspberry Pi system to SD card with Raspberry Pi Imager

    (1) Click "CHOOSE OS" on the opened Raspberry Pi Imager software interface.

image.png


(2) Click "Use custom" and select a custom ".img" file from your computer, which is the ".img" file of the Raspberry Pi system that we downloaded and decompressed before.

image.png


(3) Find the ".img" file of the Raspberry Pi system that we downloaded and decompressed before. Click "Open".

image.png


(4) Select the ".img" file and click "Open".

image.png


(5) Then on the interface of Raspberry Pi Imager, the ".img" file of our selected Raspberry Pi system will appear.

image.png


(6) Click "CHOOSE SD".

image.png


(7) Then select the SD card we need to burn.

image.png


(8) Click "WRITE" to write it to the SD card. Wait for the burn to complete.

image.png


(9) After the burning is completed, the following message will be prompted,indicating that the burning is finished, click "CONTINUE".

image.png

【Note】:

Don't remove the SD card after burning! After the Raspberry Pi Imager is burned, the memory card will be ejected in the program. This will cause the subsequent copy operation to prompt that the SD card has not been found. You can unplug the card reader from the computer and then plug it into the computer again.It is necessary to configure SSH and WIFI connection later. At this time, once the SD card is put into the Raspberry Pi to boot, it may cause subsequent headless WIFI configuration failure.


1.4 Starting the Raspberry Pi SSH service

SSH is a protocol designed to provide security for remote login sessions and other network services. Through the SSH service, you can remotely use the command line of the Raspberry Pi on another machine. In the subsequent operations and the process of using the Raspberry Pi, you can control the Raspberry Pi through another machine in the same local area network without connecting the mouse, keyboard and monitor to the Raspberry Pi. After 2016, Raspbian distributions disable the SSH service by default, so we need to manually enable it.

(1) We first enter the driver D of the computer, click "View" in the upper left corner, and select "File Extension", as shown below:

image.png


(2) Right-click on the blank space of the D drive, select "New", and select "Text Document".

image.png


(3) Name the file "ssh", as shown below:

image.png


(4) Then delete the suffix ".txt". We will get an ssh file without any extension. As shown below:

image.png


(5) Copy this ssh file to the root directory of the SD card of the Raspberry Pi system. When the Raspberry Pi starts, it will automatically find this ssh file. If it is found, it will start SSH. This method only needs to be used once. After that, every time you start the Raspberry Pi, it will automatically start SSH without repeating the above operations. Copy the ssh file to the Raspberry Pi as shown below:

image.png


1.5 Setting up Raspberry Pi WIFI wireless connection

Next, we also need to set up a WIFI wireless connection for the Raspberry Pi.

(1) Create a new file named wpa_supplicant.conf in the root directory of the D driver of the computer.

image.png

(2) Click to select the wpa_supplicant.conf file, right-click the mouse, and select "Open Mode (H)".

image.png


(3) Select "Notepad" to open it.

image.png


(4) Write the following contents:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="WIFI"
psk="PASSWORD"
key_mgmt=WPA-PSK
priority=1
       }


image.png


"Country" is your country code, do not modify it, the default is US; "ssid" needs to be changed to the name of the WIFI you want to connect; "psk" needs to be changed to the password of the WIFI you want to connect; other parts do not need to do any modifications.

For example, our company's WIFI name is Adeept, WIFI password is 123456, and the modified wpa_supplicant.conf file is as shown below:

image.png


(5) Save the set wpa_supplicant.conf file, and then copy it to the root directory of the SD card of the Raspberry Pi system. As shown below:

image.png


    (6) Now we can take out the SD card and put it into the "MICRO SD CARD" card slot on the Raspberry Pi development board, and use the Type-C data cable to supply power to the Raspberry Pi. And then the Raspberry Pi will start up and run.

image.png


1.6 Remotely logging in to the Raspberry Pi system

1.6.1 Download and install MobaXterm software

MobaXterm is a terminal tool software that can be used to remotely control the Raspberry Pi.

(1)Log in to the official website through a browser to download:

https://mobaxterm.mobatek.net/download.html

Select Free version to download.

image.png 


(2) Download the Portable edition of MobaXterm Home Edition (current version):

image.png


(3) Find the downloaded file MobaXterm_Portable_v20.2.zip, double-click to open it, extract it to get a new file.

    image.png


        image.png

(4) Open the unzipped folder, there is a file MobaXterm_Personal_20.2.exe.

    image.png


(5) Double-click to open MobaXterm_Personal_20.2.exe to directly open the MobaXterm software. The interface is as shown below:

image.png 


1.6.2 Obtaining the IP address of the Raspberry Pi

1.6.2.1 Using the Pi with a display

We provide a simple and fast way to get the Raspberry Pi IP address. You need to prepare the following components:

(1) One Type-C data cable: used to supply power to the Raspberry Pi.

(2) One HDMI cable: used to connect the monitor.

(3) One mouse: used to operate.

(4) One monitor

(5) One Raspberry Pi

image.png 


Connect the HDMI cable to the HDMI port of the monitor:

image.png 


Turn on the monitor switch, and connect the mouse to the USB port of the Raspberry Pi, supply power to the Raspberry Pi with the Type-C data cable, then the Raspberry Pi starts. After entering the system interface, we move the mouse cursor to the " image.png" in the upper right corner, then it will display the IP address of the Raspberry Pi: 192.168.3.157 (the IP address of each Raspberry Pi is different). It is necessary for you to record this IP address for it is needed to log in to the Raspberry Pi system later.

image.png 


2.You can also open the command window of the Raspberry Pi and enter the following command to view the following IP address, you need to write it down:

    hostname -I

image.png



1.6.2.2 Getting the IP address of a Pi using your smartphone

1.You need to download an APP called "Fing" on your phone, as shown below:

image.png 


2.After the download is complete, your phone and Raspberry Pi need to be in the same local area network, that is, your phone and Raspberry Pi are connected to the same WIFI, then open "Fing" and click "Scan for devices":

image.png 


Click“CONTINUE WITHOUT PERMISSION”:

image.png 


Click OK:

image.png 


3.Wait for the scan to complete. In the list, you find a device named "Raspberry Pi". In the lower left corner, you will see the IP address of the Raspberry Pi: 192.168.3.157. You need to write down this IP address.

image.png 



1.6.3 Remotely logging in to the Raspberry Pi system

(1) Open the softwareimage.png on the desktop, as shown below:

image.png


(2) Click "Session" in the upper left corner.

image.png


(3) Click "SSH".

image.png


(4) Enter the IP address of the Raspberry Pi previously queried: 192.168.3.157, and confirm with "OK".

image.png


(5) Enter the default account of Raspberry Pi: pi, then press Enter, and then enter the default password of Raspberry Pi: raspberry. Press Enter to log in to the Raspberry Pi system.

image.png


(6) After successfully logging into the Raspberry Pi system, the following interface will appear as shown below:

image.png


(7) The red box in the figure below is the command window, where you can control the Raspberry Pi by entering commands.

image.png


    (8) When we close the MobaXterm software and then open it to connect to the Raspberry Pi, we can double-click the IP address under the "User sessions" on the left: 192.168.3.157, enter the account name: pi. Then the Raspberry Pi will be directly connected.


image.png