Smart Cities - Installation of Raspberry Pi Operating System Desktop on a PC

From Sensors in Schools
Jump to navigation Jump to search

Introduction

  • In this lesson you will find out how to install the Raspberry Pi Desktop on an old PC.
  • Installing the Raspberry Pi Desktop will make the old laptop faster because the Linux operating system runs efficiently on old computers.
  • The laptops can then be used in school classrooms to teach a range of programming languages including Scratch, Python and C++ for Arduino.
  • Warning - the installation of the Raspberry Pi Desktop will erase all existing files on the old PC. Copy all important files before the installation of the Raspberry Pi Desktop.

Download Raspberry Pi Operating System Desktop for PC

  • Go to the https://www.raspberrypi.com/software/raspberry-pi-desktop/ Raspberry Pi Desktop Website and download the latest installation by clicking on the Download button.
  • The version shown on your computer may be different the one shown here. This version was from April 2023.
  • The downloaded file will an .IOS Disk Image File.
  • The fill file name will be similar to the following 2022-07-01-raspios-bullseye-i386.iso
  • Normally the file will be downloaded to the Downloads directory.

Create a USB Drive Installer

  • The Installer is a USB Memory Stick that will hold the installation files (the ISO Image File) required to install the Raspberry Pi Desktop to your PC.
  • The Installer USB can be used multiple times to install the Raspberry Pi Desktop on other PCs.
  • Warning - all files on the USB memory stick will be erased when the ISO Disk Image files are installed on the USB Memory Stick.
  • The USB Memory Stick should be 4GB or greater because the ISO Image File is approximately 3.6GB is size.
  • Etcher will be used to prepare the USB Drive Installer.
  • Download Etcher from [www.balena.io/etcher etcher.io]
  • Install the USB Memory Stick into the computer where Etcher is installed (ScanDisk Cruzer Blade Media - 16GB).
  • Open the Etcher program.
  • Click on Select Image

  • In the Window that opens select the Raspberry Pi Desktop ISO file.
  • In this case the file name is 2022-07-01-raspios-bullseye-i386.iso

  • Select the Target destination for the IOS file.

  • In the Window that opens select the appropriate Target media.
  • Important computer storage media are Hidden for protection.
  • Ensure that the USB Memory Stick is plugged into the computer during this operation so it can be identified.
  • Warning - selecting the wrong drive (target media) will result in all data being deleted.

  • Click Flash to write the Raspberry Pi Desktop image to the USB Drive.

  • You may be prompted to enter an Admin passwork (for your computer) before Flashing the USB Drive can start.

  • A progress bar will indicate how the Flashing is progressing.

  • When Flashing is complete the message Flash Complete! will appear.
  • You can remove the USB Drive and then insert it into the old PC.

Modifying the BIOS on the PC

  • Repeatedly tap the F1 key when the Lenovo, ThinkPad, ThinkStation, or ThinkCentre logo appears,
  • The computer may beep once to indicate that it will boot to BIOS.
  • Some models require users to continuously press Enter instead of F1 during power on; once the Startup Interrupt Menu displays, press F1 to enter BIOS.

Forcing a Lenovo laptop into Windows Boot Manager

  • Press F12 or (Fn+F12) rapidly and repeatedly at the Lenovo logo during bootup to open Windows Boot Manager.
  • Select boot device in the list.
  • This is a one-time-option.
  • If the boot device is disabled in the BIOS, then the boot device cannot be selected using this method.

Boot from the USB Drive

Install Raspberry Pi Desktop

Start Up Raspberry Pi Desktop

Additional Software to Install

  • Once you have installed the Raspberry Pi Desktop there are other program that you can install.
  • Remember that before installing programs update and periodically upgrade your system with the following commands
    • sudo apt update
    • sudo apt full_upgrade -y
  • Other useful software programs include
    • evince - simple pdf reader (sudo apt install evince)
    • Arduino IDE
    • Inkscape - CAD or vector drawing package we can use to build a Tiny House
    • screennsaver - (sudo apt install xscreensaver)

Reinstallation of Scratch

  • Scratch may need to be reinstalled if it doesn't work. Enter the following commands.
    • sudo apt remove scratch
    • sudo apt autoremove
    • sudo apt install scratch

Installation of the plotly python package

  • From the Raspberry Pi top bar menu click on the Terminal icon.
  • Open the Terminal and enter the command pip3 install plotly
  • pip is short for Pip Installs Python.
  • pip3 installs packages for python3
  • The version of plotly that was installed is plotly-5.13.1
  • Other python packages may also be installed to support plotly.

  • To test that plotly has been installed correctly open the Python Shell and enter - import plotly

Installing pandas python package

  • To read data from our data.txt file we need to install another python package named pandas.
  • To install the pandas package open the Terminal and enter the following commands.
    • pip3 install pandas – will take up to 5-10 minutes to install. On an old laptop (2017) it took 30 minutes for pandas to install.
    • sudo apt-get update – update all libraries on the Raspberry Pi
  • Once pandas has been installed check to see if pandas can be imported in Thonny.
  • Use the command import pandas
  • If there is no error pandas has been installed correctly.
  • If however there is an error try installing these additional libraries.
    • sudo apt-get install libatlas-base-dev – extra missing software package to support pandas
  • To test that pandas has been installed correctly open the Python Shell and enter - import pandas

Installing Arduino IDE

  • We need to download the latest version of the Arduino IDE software compatible with the Raspberry Pi.
  • You can go directly the Arduino Download site and download the Linux ARM 32 bit version.
  • Alternatively, you can use the wget instruction.

Download the Arduino IDE Software

  • Create a new folder for the Arduino IDE software.
  • In the Terminal enter the following commands.
    • mkdir Applications
    • cd Applications

  • Go to the Arduino website Arduino Software
  • For a Lenovo PC (Yoga 11e) with the Raspberry Pi Desktop (Linux) installed the Linux 32 bit version of the software would be downloaded.
  • CLick on the file to download it to the ~/Downloads directory on the laptop.

Copy arduino software to the Applications directory

  • Go to the Downloads directory with the command cd ~/Downloads
  • Copy the arduino tar file to the ~/Applications directory with the command cp arduino-1.8.19-linux32.tar.xz ~/Applications
  • Then change to the Applications directory with the command cd ~/Applications

Unpack the Arduino IDE application

  • Enter the following command to unpack the package tar -xvf arduino-1.8.19-linuxarm.tar.xz
    • x - extracts the files
    • v - verbose mode so all extraction operations will be shown in the Terminal
    • f - specifies the name of the archive file we are extracting files from, in this case arduino-1.8.19-linuxarm.tar.xz
  • Refer to this tutorial Linux tar Command Tutorial
tar -xvf arduino-1.8.19-linuxarm.tar.xz

  • Once the package in unpacked enter the newly created folder named arduino-1.8.19.
  • You can use the Tab key to complete the file name (cd arduino + Tab)

Installing the Arduino IDE Application

  • Once in the directory there is an install.sh scripting file that will complete the installation.
  • Make this file executable with the command sudo chmod +x install.sh
  • If the file is already executable you can ignore this step.

  • Start the install with the command sudo ./install.sh

Running the Arduino IDE Application

  • The installation process adds an entry into the Raspberry Pi OS drop down menu.
  • You can find the Arduino IDE entry under the Programming heading.

Setting Preferences

  • Update the Arduino preferences.
  • Select File > Preferences

  • In the Preferences window you can check the box to display line numbers
  • All preference settings are saved in a hidden file /home/pi/.arduino15/preferences.txt
  • We can modify this file to change the font preferences in Arduino to make the code more readable.
  • Note that before modifying the preferences.txt file the Arduino application must be closed (not running).

Improving Font Readability

  • Close the Arduino application.
  • Using the File Manager navigate to the /home/pi home directory.
  • If you can't see the hidden folder .arduino15 go to the View dropdown menu and ensure Show Hidden is selected.

  • Enter the .arduino15 directory.
  • Double click on the preferences.txt file to edit it.
  • You can edit the file with any text editor.

  • Find the line editor.font and change it from editor.font=Monospaced,plain,12 to editor.font=consolas,plain,14
    • consolas is a font that is more readable in the Arduino IDE
    • 14 is the font size
  • Save the changes and close the file.

  • When you restart the Arduino IDE application the new font settings will be active.


Installing and Upgrading Node-RED

  • The following script installs Node.js, npm and Node-RED onto a Raspberry Pi.
  • The script can also be used to upgrade an existing install when a new release is available.
  • NodeRED is a powerful language which organises programming modules into blocks.

Script to install NodeRED

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16

  • The installation will take five minutes to complete.
  • During the installation a progress table showing green ticks will appear.
  • All items need a green tick.
  • If there are any red crosses the installation has failed.

  • Screen capture showing successful installation of Node-RED version 16.
  • Note that we will be installing version 16 (not 14)