Lesson 3 Installing and Configuring Raspberry Pi System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

1

Lesson 3 Installing and Configuring Raspberry Pi System

The Raspberry Pi OS will affect the installation of the dependent libraries. It is


recommended to use the Raspberry Pi OS we recommend.

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

3.1 Preparation

⚫ 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.

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

3.2 Install imager tool

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

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

Support email:
2

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

3. Then click "Finish".

Support email:
3

4. The software interface after opening is as shown below:

Support email:
4

3.3 Downloading the Raspberry Pi OS 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 three ways to download Raspbian for Raspberry Pi OS (we
recommend method 1).

Method 1
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.

Support email:
5

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

3. Click "Download", download the ".ZIP" file(or compressed files in other formats), 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.

Support email:
6

Method 2
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/

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

Method 3
The image downloaded according to the method 1 is the official version of Raspbian and comes
with some pre-installed software. At the same time, the normal operation of the robot product
requires many other dependent libraries, although we provide a script to install these simple
methods of relying on libraries (will be introduced in detail later), occasionally encountering
dependent library updates may cause the installation of dependent libraries to fail, so we
provide a Raspbian mirror file pre-installed with dependent libraries. The disadvantage of this
method is that the mirror files and related dependent libraries we provide cannot be kept
updated at any time. Only when you encounter a very difficult problem, you can try this method

Support email:
7

to solve it. Download the Raspbian image file address we


provide:https://www.adeept.com/learn/detail-38.html

The content of the PDF "xxx image file" on the page is the download address of the image
file. After the download is complete, decompress it. The path of the decompressed” .img” file
must be all English letters and no special characters.

3.4 Burning Raspberry Pi OS to SD card with Raspberry Pi Imager

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

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

Support email:
8

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

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

Support email:
9

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

6. Click "CHOOSE SD".

Support email:
10

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

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

Support email:
11

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

Support email:
12

【Pay Attention】

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.

3.5 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.

The following steps are operated under Windows OS, other OS are similar. If the operation
is unsuccessful, please see the second half of 3.5.

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

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

Support email:
13

3. Name the file "ssh", as shown below:

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

5. Copy this ssh file to the root directory of the SD card of the Raspberry Pi OS. 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:

Support email:
14

3.6 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.

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

3. Select "Notepad" to open it.

Support email:
15

4. Write the following contents:

Support email:
16

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

"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:

Support email:
17

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

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.

Support email:
18

Note: If the above steps are not successful in configuring SSH and WiFi, please try another way
to configure SSH and WiFi: (If you cannot complete the above steps using a Mac OS, you can use
this method)

1. Connect the Raspberry Pi to the display through the mouse, keyboard, and HDMI cable.

2. Click the WiFi icon in the upper right corner of the desktop (the WiFi icon in the picture is
the connected WiFi status), then select the WiFi name and enter the password.

3. Select "Preferences" from the drop-down list in the main menu of the Raspberry Pi desktop,
and then select "Raspberry Pi Configuration".

Support email:
19

4. Select "Interfaces", set the SSH and I2C options to "Enabled", and then click "OK".

3.7 Remotely logging in to the Raspberry Pi OS

Support email:
20

Before using SSH to connect to Raspberry Pi, you need to know the IP address of the
Raspberry Pi and the software that supports SSH.

The remote login to the Raspberry Pi is achieved through the SSH protocol, and the
Raspberry Pi can be remotely logged in through the software with the SSH protocol. For
example: Putty, MobaXterm, etc. It is recommended that MAC users install Putty windows and
install MobaXterm.

Linux or Mac OS comes with SSH function, and you can also log in to the Raspberry Pi
remotely through the terminal.

3.7.1 Obtaining the IP address of the Raspberry Pi

Method 1
Obtaining an IP address with an external display

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

⚫ One Type-C data cable: used to supply power to the Raspberry Pi.

⚫ One HDMI cable: used to connect the monitor.

⚫ One mouse: used to operate.

⚫ One monitor

⚫ One Raspberry Pi

Support email:
21

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

Support email:
22

2. 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 "

" 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 OS later.

Support email:
23

3. You can also check the following IP address by opening the command window of the
Raspberry Pi and entering the following command, you need to write it down:

hostname -I

Method 2

Obtaining an IP address with a mobile phone

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

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":

Support email:
24

3. Click“CONTINUE WITHOUT PERMISSION”:

Support email:
25

4. Click “OK”:

5. 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.

3.7.2 Remotely logging in to the Raspberry Pi OS


This course recommends two kinds of software for SSH login to Raspberry Pi. In actual use,
you only need to download one. LInux or Mac OS comes with SSH function, you can log in to the
Raspberry Pi remotely with the terminal without downloading software.

Support email:
26

Putty
You need to download and install PuTTY corresponding to your computer OS version, and
use it to log in to the Raspberry Pi. PuTTY download address:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

1. Run PuTTY, enter the IP address of the Raspberry Pi into the Host Name, and click
“Open”.

For example: 192.168.3.179

2. If it prompts Network error: Connection timed out, it means you probably entered the
wrong IP address.

Support email:
27

3. When the connection is normal, you will see a security warning. You can safely ignore it
and click the "Yes" button. You will see this warning when PuTTY connects to a Raspberry Pi
that has not been connected before.

4. You will now see the usual login prompt. Log in with the same username and password
as the Pi itself. The default login name of Raspbian is pi and the password is raspberry. When
entering the password, the screen will not display the entered password. After entering
raspberry, press Enter to confirm.

5. You should now have the Raspberry Pi prompt, which will be the same as the prompt on
the Raspberry Pi itself.

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

Support email:
28

1. Log in to the official website with a browser to download:


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

Choose the Free version to download.

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

3. Find the downloaded file MobaXterm_Portable_v20.2.zip, double-click to open it, unzip it


to get a new file.

Support email:
29

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

5. Double-click to open MobaXterm_Personal_20.2.exe, and then directly open the


MobaXterm software. The interface is as follows:

6. Click "Session" in the upper left corner.

Support email:
30

7. Click "SSH".

8. Enter the your IP address of the Raspberry Pi queried before, E.g:192.168.3.157, and
click "OK" to confirm.

Support email:
31

9. Enter the Raspberry Pi default account: pi, then press the Enter key, and then enter the
Raspberry Pi default password: raspberry. Press Enter to log in to the Raspberry Pi system.

Note: Please distinguish between uppercase and lowercase.

10. After successfully logging in to the Raspberry Pi OS, the following interface will appear:

Support email:
32

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

12. When we close the MobaXterm software and open MobaXterm again to connect to the
Raspberry Pi, we can double-click the IP address under "User sessions" on the left:
192.168.3.157, enter the account name: pi, and you can directly connect to the Raspberry Sent.

Support email:
33

Windows10, LInux and Mac OS comes with SSH function


Steps to connect to Raspberry Pi via SSH:

1. Open a console terminal window.

2. The initial user name of the Raspberry Pi is “pi” and the initial password is “raspberry”.

3. Enter ssh pi@<IP> in the command line and replace <IP> with your Raspberry Pi IP
address, as shown in the following example:

ssh [email protected]
4. Press Enter, and the prompt Are you sure you want to continue connecting (yes/no)?

5. Enter “yes”, press Enter, “[email protected]'s password:” appears, fill in the initial
password “raspberry“ of the Raspberry Pi, pay attention to the case, there will be no changes
on the screen during the password input, but it does not Indicates that the input was not
successful, press enter after the input is complete.

6. Now you have logged in to the Raspberry Pi.

Support email:
34

3.8 Downloading the code program to control the robot

⚫ For the power supply of Raspberry Pi, please refer to this official document:

https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.md

⚫ Our Raspberry Pi robot driver board Robot HAT can directly supply power to the Raspberry
Pi through the GPIO pins. However, because the software installation time in the Raspberry
Pi is relatively long, it is not recommended to use battery power when installing the
Raspberry Pi. The Raspberry Pi robot driver board Robot HAT or camera need not be
installed when installing the software in the Raspberry Pi. This does not affect the software
installation, but when you run the installed program, you must connect the driver board and
the Raspberry Pi camera, otherwise Will cause the program to report an error.

⚫ If you manually download the image file provided by us, you only need to load the SD card
into the Raspberry Pi to boot, and the program of the robot product will run automatically.
You can skip this section.

Use the image file we provide If you want to update the code, you can delete the
"adeept_picarpro" file and download the product code again.

sudo rm -rf adeept_picarpro

sudo git clone https://github.com/adeept/adeept_picarpro.git


⚫ All the code of our product has been open sourced on GitHub, you need to download it to
the Raspberry Pi and install the relevant dependencies before it can run normally. github
address: https://github.com/adeept/adeept_picarpro

1. After the operations in the previous section, we have logged in to the Raspberry Pi, and enter
the following commands in the console:

sudo git clone https://github.com/adeept/adeept_picarpro.git

Support email:
35

2. After the input is complete, press enter to start downloading the robot program from GitHub.
This process will continue for a period of time. Wait patiently for the download to complete.

Take MobaXterm as an example:

4. After the download is complete, a new folder” adeept_picarpro”will appear, in which the
product code is stored. Check through the Linux command "ls".

ls

3.9 Installing the dependency library of program

⚫ If you use "Manually download the image file we provide" to write the image file to the SD card,
the dependency library of the robot product has been installed, you can directly boot the
Raspberry Pi to start using the robot.

Support email:
36

⚫ If you used "Download the official Raspbian image file" to write the image file to the SD card,
you can refer to this section to install the dependent libraries.

⚫ When installing dependent libraries, the installation of some dependent libraries may fail due to
network problems or dependent library version issues. For dependent libraries that fail to install,
the program will automatically install multiple times.

⚫ After the installation is complete, the Raspberry Pi will automatically restart. At this time, the
remote login program of the Raspberry Pi via SSH will be terminated. Please log in again.

⚫ When installing dependent libraries, the installation may fail due to network or regional reasons.
If you encounter any problems, please contact us: [email protected]

We have prepared a script to install all the dependent libraries that need to be used and set up
operations such as turning on the camera and automatically running on startup.

Steps:

1. Enter the following code in the console and run the script setup.py to install the required
dependent libraries:

sudo python3 adeept_picarpro/setup.py

2. Press Enter to confirm. The following operations are automatically completed by the script
program. Depending on the network environment, this process may last for tens of minutes or several
hours, just wait patiently.

3. After the installation is complete, the console will show text:

Support email:
37

After the installation is complete, the Raspberry Pi will automatically disconnect the SSH
connection and restart. At this time, if you are using a Raspberry Pi connected by software such as
Putty, there will be an error message such as Network error: Software caused connection abort,
which is normal, just close the window.

3.10 Whether the dependent library is installed successfully

⚫ When no error message appears when the “webServer.py” program is running, the dependent
library is installed successfully.

⚫ Only by successfully running the webServer.py program on the Raspberry Pi, can the Raspberry
Pi be accessed with the IP on the browser.(After installing the dependent libraries, the Raspberry
Pi will automatically run webServer.py).

⚫ Prepare the components required for installation, and turn off the power of the Raspberry Pi
during installation.

Support email:
38

1. Install the camera cable, contact the metal surface of the cable with the metal surface of the
Raspberry Pi (the same applies to installing the camera).

2. Install Robot HAT and camera, and connect the Raspberry Pi power supply.

3. After the Raspberry Pi is turned on (about 30-50s), you can access the Raspberry Pi with a
browser.

⚫ How to tell whether the robot has run the `webServer.py` or not: If the WS2812-LED lights up
with the breathing effect, it means the robot has booted and runs the program automatically.

⚫ If the program is not run when the robot is booted, try to connect Raspberry Pi via SSH,
manually run `webServer.py` with code and check the errors. Refer to the Q&A below or email
us for help: [email protected]

Support email:
39

⚫ before manually running `webServer.py`, you need to end the program possibly auto run in the
back end to release resources.

sudo killall python3

⚫ Use the following command to run webServer.py

sudo python3 adeept_picarpro/server/webServer.py

⚫ Open the web control interface.

1. Make sure your device is in the same local area network as the Raspberry Pi.

2. Obtain the IP address of the Raspberry Pi (refer to the software installation section).

3. Open the browser on the device (chrome browser is recommended to avoid possible browser
compatibility issues), enter the IP address of your Raspberry Pi in the address bar, and visit port 5000,
for example: 192.168.3.44:5000

Support email:
40

4. The web controller will then be loaded into the browser.

Depending on the product, the modules on the web controller are also different.

3.11 Creating a WiFi Hotspot on Raspberry Pi

The dependent library is successfully installed, and after "webServer.py" runs automatically, our
product will automatically turn on the hotspot when the wifi is not connected.

The method of turning on the WIFI hotspot in our robot product uses a project from GitHub
create_ap. Our installation script will automatically install this program and related dependent
libraries. If you have not run our installation script, you can use the following command to install
create_ap:

sudo git clone https://github.com/oblique/create_ap.git

Support email:
41

cd create_ap

sudo make install

1.Install related dependent libraries:

sudo apt-get install -y util-linux procps hostapd iproute2 iw haveged dnsmasq


2.Before turning on the hotspot, your Raspberry Pi cannot be connected to WIFI, and the WIFI
module cannot be turned off, so when you test the hotspot function, you need to connect the
necessary peripherals for the Raspberry Pi.

3.Under normal circumstances, if the robot program is not connected to the WIFI when it is
turned on, it will automatically turn on the hotspot. You can use your phone or computer to search for
the WIF named Adeept_Robot. The default password is 12345678. Once the connection is successful,
you can log in to 192.168 .12.1: 5000 using a browser to open the WEB application to control the
robot.

4.If your Raspberry Pi is connected to peripherals, and you want to test the Raspberry Pi ’s
ability to turn on hotspots, you can click the WIFI icon in the upper right corner of the Raspberry
Pi ’s desktop, click the name of the connected WIFI, click forget, and never turn Off WIFI, if it is
already in the off state, you need to turn it on.

5.When the WIFI module of the Raspberry Pi is turned on and is not connected to any known
network, you can enter the following command on the console to turn on the WIFI:

sudo create_ap wlan0 eth0 Adeept_Robot 12345678


“Adeept_Robot“ is the name of the WIFI hotspot, ”12345678“ is the password of the WIFI
hotspot.

Support email:
42

Q&A

⚫ Errors occur with `permission denied` prompt when I manually run `server.py` or
`webServer.py`.
The Raspberry Pi needs the root permission to run the dependent libraries for WS2812 LED
lights control.
You need to add `sudo` to the beginning of `server.py` or `webServer.py` to run the program.
[PATH] is the product folder path. E.g: sudo python3 adeept_picarpro/server/webserver.py
sudo python3 [PATH]/server.py
sudo python3 [PATH]/webServer.py

⚫ Raspberry Pi can't boot.


Remove all parts on the driver board. Only connect the board to Raspberry Pi and power
supply, reboot.
Observe if the green light of the Raspberry Pi is blinking.
If the indicator does not flash or the indicator flashes at the same interval, it means that the
image file has not been burned successfully, please re-burn the system.

⚫ "Remote side unexpectedly closed network connection" shows on a popup window.


There can be error prompts during installation because the Raspberry Pi will auto reboot
after the installation, which will disconnect the board.

⚫ Raspberry Pi failed to connect a WiFi.


Please connect to the Raspberry Pi through the mouse, keyboard, monitor, and then click the
wifi icon in the upper right corner of the Raspberry Pi interface to enter the wifi information.

Support email:
43

⚫ I can not connect to the Raspberry Pi terminal via SSH


Please connect to the Raspberry Pi through the mouse, keyboard, monitor, and then click on the
main menu in the upper left corner of the Raspberry Pi interface, select "preferences", select
"Raspberry Pi Configuration", select "Interfaces", set the SSH bar to "Enabled", then Click "OK"

⚫ SSH can't connect, error: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Enter the following in the command line and press Enter
ssh-keygen -R <the Raspberry Pi's IP address>
For example:
ssh-keygen -R 192.168.3.157
Then you can SSH to the Raspberry Pi again

⚫ Can I supply the Robot HAT and Raspberry Pi via USB?


A 2A output is required for a Raspberry Pi 3B, when at least 3A is needed for a Raspberry Pi 4.
You can use the USB power for software installation and testing, but it's not suitable for high power
module like servo or motor adjustment as it may result in low voltage. It's recommended to use
battery for power here.

⚫ no cv2 error occurs when I manually run `server.py` or `webServer.py`.


OpenCV is not installed correctly. Type in the command sudo pip3 install
opencv-contrib-python in the Raspberry Pi to manually install OpenCV.

⚫ When using a computer to copy ssh and wpa_supplicant.conf to the SD card, it prompts that
there is no SD card
If this happens, unplug the card reader and connect it to the computer.

Support email:
44

⚫ Run "webServer.py" error: Could not start camera.


Check whether the camera is installed correctly:

The metal surface of the camera cable is in contact with the metal surface of the camera,The
metal surface of the camera cable is in contact with the metal surface of the camera interface of the
Raspberry Pi

How to judge whether the camera is connected correctly

Please run the command in the terminal: "raspistill -t 1000 -o image.jpg",

If the camera is installed correctly, the program will not go wrong, and after running the
command "ls", an image file of image.jpg will appear

If an error occurs, it means that the camera is not installed correctly or the camera is
malfunctioning

Support email:

You might also like