Index>Robot Kit>Alter All in One Kit for RPi>Lesson 18 Alter Program Installation
No related product information!

Lesson 18 Alter Program Installation

1175


18.1 Using Raspberry Pi for the first time

18.1.1 Write the operating system of the Raspberry Pi to the SD card

      18.1.1.1 Method A: Write 'Raspbian' to The SD Card by Raspberry Pi Imager

Raspberry Pi Imager is an image writing tool to SD card developed by the Raspberry Pi Organization. It comes with many versions working on different systems and it's quite easy to use; all you need is choose the operating system and SD card, Raspberry Pi Imager will download the corresponding image file for the system and install it to the SD card.

Step-by-Step Overview:

1.Prepare an SD card (16G or larger) and an SD card reader

2.Download the `Raspberry Pi Imager` on the official website

3.- [Raspberry Pi Imager for Windows]

4.- [Raspberry Pi Imager for macOS]

5.- [Raspberry Pi Imager for Ubuntu]

6. Install the `Raspberry Pi Imager`

     7. Write the operating system for Raspberry Pi to the SD card with `Raspberry Pi Imager` `Raspbian Full - A port of Debian with desktop and recommended application`  

     8. Leave the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later.

Detailed Steps:

Open a web browser on your computer, go to the Raspberry Pi website [Official Raspberry Pi website], find and download the Raspberry Pi Imager for your computer OS, or click on the links above for the corresponding system to directly download and install.

●Insert the SD card into the card reader, connect the card reader with your computer.

●Run the Raspberry Pi Imager, select CHOOSE OS -> Raspbian(other) -> Raspbian Full - A port of Debian with desktop and recommended applications.

●Click on CHOOSE SD CARD for the SD card to write the Raspbian Full, please be noted that the image writing will automatically delete all files on the SD card if any.

●Click on WRITE, wait for the writing. The Raspberry Pi Imager needs to download the Raspbian image file during the process. 

●Do not remove the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later. Otherwise, if you remove the card, insert it into the Raspberry Pi and boot, WiFi configuration without any peripherals may fail in the following process.


18.1.1.2 Method B: Download The Image File Raspbian and Write It to The SD Card Manually

Since the image file is downloaded with Raspberry Pi Imager in 18.1.1.1, it can take a long time due to a slow network in some places. You may then manually download the image file Raspbian and write it to the SD card with th Raspberry Pi Imager.

Step-by-Step Overview:

1. Prepare an SD card (16G or larger) and an SD card reader

     2. Download the `Raspberry Pi Imager` on the official website[Official Raspberry Pi Website]

- [Raspberry Pi Imager for Windows]

- [Raspberry Pi Imager for macOS]

- [Raspberry Pi Imager for Ubuntu]

3. Install the `Raspberry Pi Imager`

4. Download the image file `Raspbian`

- Torrent file:

[Raspbian-Raspbian Buster with desktop and recommended software]

-Zip file: [Raspbian - Raspbian Buster with desktop and recommended software]

5. Unzip the file, be noted that the path should be in English for the `.img` file extracted, no special characters allowed.

6. Write the image file `Raspbian` downloaded to the SD card with `Raspberry Pi Imager`

7. Leave the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later.

       Detailed Steps:

Open a web browser on your computer, go to the Raspberry Pi website[Official Raspberry Pi website], find and download the Raspberry Pi Imager for your computer OS, or click on the links above for the corresponding system to directly download and install.

●On the Raspberry Pi website [Official Raspberry Pi website], select through Downloads -> Raspbian -> Raspbian Buster with desktop and recommended software, and click on the torrent or zip file to download. Unzip the file after download, be noted that the path should be in English for the .img file extracted, no special characters allowed; otherwise Raspberry Pi Imager may not open the .img file. It's recommended to save the .img file to the root directory of the C:\ or D:\ disk, but do not save .img on the SD card.

●Insert the SD card into the card reader, connect the card reader and your computer.

●Run the Raspberry Pi Imager, select CHOOSE OS, and then Use custom to find the .img extracted, click Open.

●Select CHOOSE SD CARD for the SD card to write the Raspbian, please be noted that the image writing will automatically delete all files on the SD card if any.

●Click on WRITE, wait for the writing.

●Do not remove the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later. Otherwise, if you remove the card, insert it into the Raspberry Pi and boot it up, WiFi configuration without any peripherals may fail in the following process.


       18.1.1.3 Method C: Manually Download The Image File Provided by Us and Write It to The SD Card (Not Recommended)

●The Raspbian image file downloaded in 18.1.1.1 and 18.1.1.2 is the official source with some preinstalled software. To operate the robot, you may need many dependent libraries. Though we provide the simple script to install them (see details later), failure can happen during installation if the library is not the latest version. Therefore, despite we provide the downloading of the Raspbian image file, it may happen that our image file and the dependent libraries are not most updated versions. Please only use when you encounter the most troublesome situation.

●Step-by-Step Overview:

1. Prepare an SD card (16G or larger) and an SD card reader

2. Download the `Raspberry Pi Imager` from the official website [Official Raspberry Pi website]

- [Raspberry Pi Imager for Windows]

- [Raspberry Pi Imager for macOS]

- [Raspberry Pi Imager for Ubuntu]

3. Install the `Raspberry Pi Imager`

4. Download the image file `Adeept_alter`

https://www.adeept.com/learn/detail-51.html

5. Unzip the file, be noted that the path should be in English for the `.img` file extracted, no special characters allowed.

6. Write the image file `Raspbian` downloaded to the SD card with `Raspberry Pi Imager`

 7. Leave the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later.

Detailed Steps:

      ●Open a web browser on your computer, go to the Raspberry Pi website [Official Raspberry Pi website], find and download the Raspberry Pi Imager for your computer OS, or click on the links above for the corresponding system to directly download and install.

●Go to our [official website], find and download the image file [Image file for the Adeept_alter Robot]. Unzip the file, be noted that the path should be in English for the .img file extracted, no special characters allowed. otherwise Raspberry Pi Imager may not open the .img file. It's recommended to save the .img file to the root directory of the C:\ or D:\ disk, but do not save .img on the SD card.

     ●Insert the SD card into the card reader, connect the card reader and your computer.

     ●Run the Raspberry Pi Imager, select CHOOSE OS, and then Use custom to find the .img extracted, click Open.

     ●Select CHOOSE SD CARD for the SD card to write the Raspbian, please be noted that the image writing will automatically delete all files on the SD card if any.

     ●Click on WRITE, wait for the writing.

     ●Do not remove the SD card connected after writing is completed, we'll use for configuring WiFi connection later. Otherwise, if you remove the card, insert it into the Raspberry Pi and boot it up, WiFi configuration without any peripherals may fail in the following process. 



18.2 Enable SSH Server of Raspberry Pi 

●By SSH (Secure Shell) server, you can use the command line of Raspberry Pi remotely on another device. In the subsequent operation and when using the Raspberry Pi, you don't have to connect a mouse, keyboard, or monitor to it, but simply control it on a computer in the same LAN.

●As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually. 

●The method to enable the SSH in this lesson can be referred to the Raspberry Pi official website SSH(Secure Shell)

18.2.1 Method A: Enable SSH with Peripherals

●If you use (18.1.1.3to manually download the image file we provide and write it to the SD card) to write the operating system of the Raspberry Pi to the SD card, you do not need to refer to this section to open SSH, because The SSH service in the image is already enabled.

●If you've connected a mouse, keyboard, or monitor to the Raspberry Pi, follow these steps to enable SSH.

1.Remove the SD card from the computer, insert it to the Raspberry Pi, connect a mouse, keyboard, and monitor to the Raspberry Pi, boot it up.

2.Go to Preferences menu, select Raspberry Pi Configuration.

3.Go to Interfaces option.

4.Select Enable next to SSH.

5.Click on OK.

18.2.2 Method A: Enable SSH without Peripherals

●If you use (18.1.1.3 to manually download the image file we provide and write it to the SD card) to write the operating system of the Raspberry Pi to the SD card, you do not need to refer to this section to open SSH, because The SSH service in the image is already enabled.

●If you haven't connected any monitor to the Raspberry Pi, follow these steps to enable SSH.  

1. Do not remove the SD card after `Raspberry Pi Imager` writes the image file.  

2. Create a file named `ssh` under any directory, without any extension name. You may create a `ssh.txt` and delete the `.txt` (make sure under Folder Options the box of Hide extensions for known file types is unchecked. Then you have an `ssh` file without extension name.   

3. Copy the `ssh` file and paste to the root directory of the SD card. The Raspberry Pi will auto search for the `ssh` file when booting, and enable SSH if the file is found. You only need to copy for one time because the Raspberry Pi then will automatically enable SSH at every boot.   

4. Do not remove the SD card if you need to configure WiFi.


18.3 Configure WiFi on Raspberry Pi 

●There are many ways to connect WiFi for Raspberry Pi. Two methods are provided in this documentation; you may visit the official Raspberry Pi website for more: [Wireless connectivity]

 18.3.1 Method A: WiFi Connection with Peripherals 

     ● If you've connected a mouse, keyboard, or monitor to the Raspberry Pi, follow these steps to configure WiFi.

1.Remove the SD card from the computer, insert it to the Raspberry Pi, connect a mouse, keyboard, and monitor to the Raspberry Pi, boot it up.   

2. Select the WiFi icon at the top right corner on the monitor, find the WiFi to connect and select.

3. Type in the password for the WiFi, connect.

4. After it's connected successfully, the WiFi will be saved and the Raspberry Pi will auto connect for next boot, so you don't need to connect peripherals every time.

  18.3.2 Method B: WiFi Connection without Peripherals 

     ●If you haven't connected any monitor to the Raspberry Pi, follow these steps to configure WiFi.  

     ●This method is based on the [official documentation]

1. Do not remove the SD card after `Raspberry Pi Imager` has written the image file. (This method works for the situation that the Raspbian image file has just been written to the SD card; if you've already plugged the SD card into the Raspberry Pi and got it rebooted after the image file being written, the configuration may fail.)  

2. Create a file named `wpa_supplicant.conf` anywhere in your computer.   

3. Open the file `wpa_supplicant.conf` created with Textbook, enter the following code:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=Insert country code here

network={

ssid="Name of your WiFi"

psk="Password for your WiFi"

}

          4. Type in your own information for `Insert country code here`, `Name of your WiFi`, and `Password for your WiFi`. Pay attention to the capitalization. Refer to the example below:   

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=US

network={

    ssid="MyName"

    psk="12345678"

}

         5. Save and exit. Copy the `wpa_supplicant.conf` to the root directory of the SD card.   

         6. If you've already copied the file `ssh` to the SD card as instructed in **2.2**, then both the WiFi and SSH settings without peripherals are done. You may remove the SD card, insert it into the Raspberry Pi, and boot it up.   

         7. For more about the file `wpa_supplicant.conf`, refer to the official documentation [WIRELESS-CLI]


18.4 Software installation and operation in Raspberry Pi

●If you followed the steps in 18.2.1 and 18.3.1 for SSH and WiFi configuration, you may remove the peripherals now and use SSH to remotely control the Raspberry Pi later on.

●If you followed the steps in18.2.2 and 18.3.2, you may now insert the SD card into the Raspberry Pi and boot it up. The Raspberry Pi will auto boot and connect WiFi when powered on, with no need of peripherals.

●If you use the operation steps of 18.1.3 to write to the SD card, you only need to refer to18.3.1 or 18.3.2 to configure the WIFI, you can install the SD card into the Raspberry Pi, and the robot product program will Automatic operation, you can skip some content, refer to 5 Use WEB application to control the robot after the structure is assembled.

●Some steps mentioned below are based on the official Raspberry Pi documentation SSH.

●For power supply of the Raspberry Pi, refer to the official documentation Power supply.

●The Motor HAT board of the Adeept Raspberry Pi Robot can supply power for the Raspberry Pi via GPIO port. However, since it may take a long time to install software on the Raspberry Pi, it's not recommended to supply with the batteries during this process. You may skip the installation of the Motor HAT board or camera during software installation; though you need to make sure the driver board and camera for the Raspberry Pi when it's ready to run the software installed, or a program error will occur.

 

18.4.1 Log into Raspberry Pi (Windows 10)

●For Windows 10, SSH is built in the versions after October 2018, so you don't need any third-party software.   

●For lower versions of Windows OS, SSH is not built in, and you may log into the Raspberry Pi by referring to the official documentation [SSH using Windows].

    ●Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app `Network Scanner` -> search for a device named `RASPBERRY` or `Raspberry Pi Foundation` to get the IP address.  

    ●For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation [IP Address]

    ●Press the keys ‘win’+’R’, type in `cmd`, and press ‘enter’.

    ●The default user is `pi`, and the password is `raspberry`. 

    ●Type in `ssh pi@<IP>` in the command line, replace the `<IP>` with the IP address of your Raspberry Pi, as shown below:  

ssh pi@192.168.3.161  

    ●Press Enter key and a prompt will appear: `Are you sure you want to continue connecting (yes/no)?`  

    ●Type in `yes`, press Enter and it'll show `pi@192.168.3.161's password:`, type in the initial password of the Raspberry Pi, `raspberry` (pay attention to capitalization). There's no change on the screen when you're typing in, but it doesn't mean you're not entering the information. Press ‘enter’ after you finish typing in.

 ●So now you've logged into the Raspberry Pi.


18.4.2 Log into Raspberry Pi (Linux or Mac OS)

    ●Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app `Network Scanner` -> search for a device named `RASPBERRY` or `Raspberry Pi Foundation` to get the IP address.  

    ●For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation [IP Address]  

    ●Open the terminal window (or command line)   

●The default user is `pi`, and the password is `raspberry`. 

    ●Type in `ssh pi@<IP>` in the command line, replace `<IP>` with the IP address of your Raspberry Pi as shown below:   

          ssh pi@192.168.3.161  

    ●Press Enter key and a prompt will appear: `Are you sure you want to continue connecting (yes/no)?`  

    ●Type in `yes`, press Enter and it'll show `pi@192.168.3.161's password:`, type in the initial password of the Raspberry Pi, `raspberry` (pay attention to capitalization). There's no change on the screen when you're typing in, but it doesn't mean you're not entering the information. Press ‘enter’ after you finish typing in.   

    ●So now you've logged into the Raspberry Pi.

18.4.3 Log into Raspberry Pi (Windows)

    ●For lower versions of Windows OS, SSH is not built in, and you may log into the Raspberry Pi by referring to the official documentation Raspberry Pi[SSH using Windows].  

    ●Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app `Network Scanner` -> search for a device named `RASPBERRY` or `Raspberry Pi Foundation` to get the IP address.  

    ●For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation [IP Address]

    ●You may need to download the `PuTTY` version for your OS and log into Raspberry Pi with the tool. [Click here to download PuTTY]

    ●Run `PuTTY`, type in the IP address of Raspberry Pi for `Host Name`, and click ‘Open’.  

    ●If a prompt of `Network error: Connection timed out` appears, possibly you've entered an incorrect IP address.   

    ●When the connection works you will see the security warning shown below. You can safely ignore it, and click the 'Yes' button. You will only see this warning the first time PuTTY connects to a Raspberry Pi that it has not seen before.  

    ●You will now see the usual login prompt. Log in with the same username and password you would use on the Pi itself. The default login for Raspbian is `pi` with the password `raspberry`.  

    ●You should now have the Raspberry Pi prompt which will be identical to the one found on the Raspberry Pi itself.  


18.4.4 Download Program of The Raspberry Pi Robot 

    ●The code for the robot product has been uploaded to [GitHub], you may need to download to your Raspberry Pi and install the corresponding dependent libraries to run the program.   

    ●In the previous section you've logged into the Raspberry Pi, and here type in the follow command in the terminal window:

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


    ●Press ‘enter’ to start downloading the program of the robot from GitHub. It may take some time, please wait until it's done.  

18.4.5 Install Corresponding Dependent Libraries 

    ●Follow the steps below to install the libraries if you wrote the image file to the SD card based on 18.1.1 Write 'Raspbian' to the SD card by `Raspberry Pi Imager` and 18.1.2 Download the image file `Raspbian` and write it to the SD card manually.   

    ●Here a script is provided for installing all dependent libraries needed and configuration of starting the camera and other auto start programs.   

    ●Type in the code below in the terminal window to run the dependent libraries for the script `setup.py`:  

sudo python3 adeept_alter/setup.py


    ●Press ‘enter’ and the script will auto run. This may take minutes or hours, depending on the network status. Please wait until it's done.  

    ●After installation is completed, the following prompts will appear:

The program in Raspberry Pi has been installed, disconnected and restarted.  

You can now power off the Raspberry Pi to install the camera and driver board (Motor HAT). After turning on again, the Raspberry Pi will automatically run the program to set the servos port signal to turn the servos to the middle position, which is convenient for mechanical assembly.

    ●When installation is completed, the Raspberry Pi will automatically disconnect SSH and reboot. If you used puTTy to connect the Raspberry Pi, there can be an error prompt like `Network error:Software caused connection abort`. You can just ignore and close it.  


18.4.6 Run the Raspberry Pi Robot's Program

    ●Raspberry Pi auto runs the program for the robot when rebooting every time, which is the part `[RobotName]/server/webServer.py` (replace `[RobotName]` for the name of the folder for your robot product's program). However, if the Raspberry Pi camera or Motor HAT is not connected, the `webServer.py` can't run well. It makes sense because the robot's program needs the camera and the chipset PCA9685. Motor HAT controls servo with PCA9685; the Raspberry Pi communicates with PCA9685 via I2C; so if Motor HAT is not connected to Raspberry Pi, a program error will occur when instantiating dependent libraries for PCA9685 due to communication failure.

     ●Power off the Raspberry Pi, connect camera module and Motor HAT, reboot it up and now `webServer.py` can run.   

     ●Generally you don't need to manually run `webServer.py` since it's auto run by Raspberry Pi at every boot.   

     ●Open a web browser (Google Chrome for example), in the address bar type in the IP address of the Raspberry Pi, add `:5000` to the end as shown below, and press ‘enter’ to redirect to the web page of the Raspberry Pi:   

          http://192.168.3.157:5000/

     ●If it fails to enter the page, log into the Raspberry Pi via SSH, type in the command below to end the program auto run at boot to release resources, or else issues like camera initialization failure or occupied ports.   

sudo killall python3


     ●Type in the command below to run `webServer.py`:

sudo python3 adeept_alter/server/webServer.py


     ●Check whether there's any error and solve them based on instructions in the Q&A section below.