Raspberry Pi Zero 2 W: Setup and Usage Guide
1. Overview and Prerequisites
You will be working with a Raspberry Pi Zero 2 W that has been preconfigured to: - Automatically join the RedRover Wi-Fi network. - Present a serial console over the USB micro port so you can connect via a serial terminal (using VS Code or PuTTY).
Default Login Credentials
- Username:
CPSPi - Password:
CPS
Software Setup
- The Pi has Pyenv installed, with a Python virtual environment called
cps. - You will use VS Code for:
- Serial communication (via the "Serial Terminal" plugin).
- SSH connections (via the integrated terminal or an SSH plugin).
-
File transfers using
scp(Secure Copy Protocol). -
Optional: Instructions for using PuTTY (external serial terminal tool) are included but not recommended.
2. Setting Up a Serial Connection
2.1 Using VS Code Serial Terminal (Recommended)
- Install the Serial Terminal plugin:
- Open VS Code.
- Go to Extensions (square icon in the left toolbar).
-
Search for "Serial Terminal" and install it.
-
Connect your Pi to your computer:
- Use a USB data cable (micro USB to USB-A or USB-C).
-
Plug it into the USB data port on the Pi Zero (not the power-only port).
-
Open the Serial Terminal in VS Code:
- Open the Serial Terminal plugin.
-
Select the appropriate port:
- On Windows, it may be
COM3,COM4, etc. - On macOS/Linux, it may be
/dev/tty.usbmodemXXXXor/dev/ttyUSB0.
- On Windows, it may be
-
Set the baud rate:
-
Login to the Pi:
- When prompted, enter:
2.2 Using PuTTY (Optional)
- Install PuTTY (if not already installed):
- Windows: https://www.putty.org/
-
Mac/Linux: Install via a package manager:
-
Identify the serial port:
- Windows: Look in Device Manager (
COMx). -
Mac/Linux: Run:
-
Open PuTTY and configure the connection:
- Connection type: Serial.
- Serial line:
COM3(Windows) or/dev/ttyUSB0(macOS/Linux). - Speed:
115200. -
Click Open.
-
Login to the Pi:
- Enter:
3. Activating the Python Virtual Environment
Once logged in via serial, you should see a prompt like:
Activate the Python virtual environment:
Your prompt should now display (cps):
4. Connecting via SSH
1. Get the Pi’s IP Address
Run the following command in the serial terminal:
Look for thewlan0 entry and find the inet IP address (e.g., 192.168.1.42).
2. Open a terminal on your computer (VS Code integrated terminal or system terminal)
Run:
Example: Enter the password:CPS when prompted.
3. Activate the Python Virtual Environment
5. Transferring Files Using scp
- Ensure the file is in a known directory on your computer.
-
Use
Example: (Enter thescpto copy the file to the Pi:CPSpassword when prompted.) -
Check the file on the Pi:
-
Organize your labs:
6. Installing Python Packages with pip
Inside the cps virtual environment, install packages as needed:
Example:
To verify installation:
7. Linux Command Cheat Sheet
| Command | Description | Example |
|---|---|---|
| ls | List files and directories. | ls |
| mkdir | Create a directory. | mkdir myFolder |
| cd | Change directory. | cd myFolder |
| pwd | Show current directory. | pwd |
| rm | Remove a file. | rm file.txt |
| rm -r | Remove a directory and its contents. | rm -r myFolder |
| cp | Copy a file or directory. | cp file1.txt file2.txt |
| mv | Move or rename a file. | mv oldName.txt newName.txt |
| ifconfig | Display network interface info (IP address, etc.). | ifconfig |
| sudo | Execute a command with admin privileges. | sudo apt-get update |
| ping | Check network connectivity. | ping www.google.com |
| apt-get | Install/remove software packages (system-wide). | sudo apt-get install python3 |
Warning: Use sudo rm -r with caution. It can delete important files!
8. Next Steps
Practice:
- Create folders for each lab and organize files.
- Transfer files using
scp. - Install packages in your
cpsenvironment. - Explore system commands (
ifconfig,sudo,ping, etc.).
Keep your system updated:
That’s It!
You now have a reliable workflow for:
- Serial connection via VS Code (or PuTTY).
- SSH login and file transfers (scp).
- Python virtual environment management.
- Installing packages with pip.
- Basic Linux commands.