Getting Setup
If you have any questions or get stuck as you work through this in-class exercise, please ask the instructor for assistance. Enjoy!
Formatting the SD card and Installing Raspbian
- Open this document in your browser and so that you can click on the hyperlinks in the document: http://bit.ly/2MCdL7r
- Download a copy of the Raspberry Pi OS with desktop from the Raspberry Pi website
- Note: This download will be ~1GB in size. If the download looks like it will take more than 5 minutes, ask your instructor if there are any SD cards with an operating system already installed.
- Install this Etcher disk imager for Windows, Mac, or Linux on your computer.
- Using Etcher, burn the disk image onto the SD card:
- If your computer does not have an SD card slot, you can borrow an adapter from the Music and Media desk in the library.
- Put the SD card into the USB adapter/micro-adapter then into your computer.
- Unzip the Raspbian file downloaded in step 1, and open Etcher.
- Follow the directions in Etcher to copy the file to the SD card.
- Raspbian is now installed onto the SD card!
- If you are on Windows, eject the drive before removing the SD card.
- If you are on a Mac the drive will be ejected for you. Go ahead and remove the SD card.
- Insert the card into the SD port of the Raspberry Pi, connect the peripherals, and power it up.
Initial Setup of Raspbian
- With all peripherals installed, allow the Raspberry Pi to boot into the desktop.
- The first thing you’ll be prompted to do will be to set up a new password, for the purposes of this lab set the password to be raspberry, or skip this step.
- When prompted, reboot your raspberry pi.
- Set the date and time on your raspberry pi:
- Open the terminal by clicking on the icon on the top bar (see icon on right).
- In the terminal enter this command with the date and time then press enter:
sudo date -s 'mm/dd/yyyy hh:mm:ss'
- Example:
sudo date -s '06/30/2023 11:40:00'
- Example:
- Connect to the internet through UVIC Guest WIFI:
- Click on the WIFI icon on the top bar and select “UVicStart”. This will connect the Raspberry Pi to the UVIC network as a guest.
- Upon opening the Chromium web browser, the UVicStart Guest Wireless page should open.
- Click the “REGISTER” button.
- Enter your email address and agree to the terms and conditions. You will be given 15 minutes of access to complete the registration.
- Log into the same email account on the Raspberry Pi. Note that Google Gmail could be very slow to respond on a Raspberry Pi 3, but will still work.
- Click the link at the top of the automatically sent email to complete the registration.
- At this point, you can sign out of your email account for security reasons.
- In order for the Raspberry Pi to accesss archive.raspberrypi.org for updates and software while connected to the UVIC network, run the following command:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
- Once this is done, enter this command:
sudo apt-get update
- Outside of the workshop you would want to run
sudo apt-get upgrade
as well, but we will not as that will take a long time!
- Outside of the workshop you would want to run
Installing New Software on Raspbian
- To install new software, you will enter a command like this:
sudo apt-get install <Software Name Here>
- In a new terminal shell, we will install the Python interpreter:
sudo apt-get install python3
Introduction to Python Programming, Hello World and Nano
- With Python installed, open the terminal and enter:
python3
- A new prompt should show up “>>>”. This is the Python shell. - Simple Python commands can now be executed. Try entering
x = 5
, theny = 8
. These variables, x and y, are now set as the values 5 and 8.- Type in
x+y
and press enter - Try some other basic arithmetic commands with these variables!
- When you’re done type:
exit()
and press enter.
- Type in
- In case we want to save a program, we need to be able to create new files. To do so, we will use nano.
- Enter this command
sudo nano hello_world.py
- In the nano window, type in
message = ‘Hello, world!’
then on a new lineprint(message)
. - Now to save the file, press “ctrl” and “X” then “Y” to save and exit. You should now be back in the terminal.
- If you need to exit without saving, press “N”.
- If you need to cancel the exit process and return to editing, press “ctrl” and “C”.
- From here, type in
python3 hello_world.py
- Enter this command
Extended Configuration
- In the case that you need to, or want to, edit any of the core settings of the Raspberry Pi, open a terminal and execute this command:
sudo raspi-config
- There are multiple configuration options here, to learn more checkout this website
- For an example of a useful feature, we will enable auto-login on the Raspberry Pi.
- After executing raspi-config (
sudo raspi-config
) navigate to Boot Options and press Enter - Navigate to Desktop/CLI then to Desktop Autologin and Enter.
- You’ve now enabled autologin to the desktop.
- Navigate to the main menu, and hit Tab then Exit and reboot the Pi. It should now autoboot
- After executing raspi-config (
Other Important Commands
- Change Directory:
cd <Path to Directory Here>
- List all files and sub-directories in the current directory:
ls
- Reboot the Raspberry Pi (recommended after installing a system update or large applications):
sudo reboot
- Shut down the Raspberry Pi:
sudo shutdown -h now
Useful Terminology
- Linux: A broad range of computer operating systems including Raspbian that are based on the Linux kernel. Aside from the Raspberry Pi, it is commonly used as an alternative to Windows or Mac operating systems.
- Directory: File system structure containing references or links to files and other directories. More often called “folders” in non-technical language.
- Python: One of the most popular programming languages with an emphasis on human readability and compataibility with many different devices. It is considered “high level” being abstracted from the deeper workings of computer hardware due to running on an interpreter program.
- Variable: Represents or holds some value. The value could be numerical or a reference to a more complex object or data structure.
- GPIO: General purpose input output pins on the Raspberry Pi to interface with outside circuitry.
- CPU: Central Processing Unit. The central component of any computer for processing data.
- GPU: Graphics Processing Unit. Generates the graphical output or images seen on a monitor. They often have many processors to complete small parallel tasks extremely quickly. The Raspberry Pi CPU chip contains a minimal GPU for integrated graphics.
- RAM: Random Access Memory. The variable data for any program running on a computer is stored here. This data is “volatile” meaning it is not retained if the computer loses power.
- SD Card: Secure Digital Card. The storage device chosen by the designers of the Raspberry Pi to contain the operating system.
- Flash: The non-volatile storage memory inside SD cards, USB drives, and the Solid State Drives of more sophisticated computers.
- USB: Universal Serial Bus. A connector standard for transferring power and data between devices.