Day 1: Pi Setup Guide
Debugging Material for Day 1 (Released on 2 July 2024)
Last updated
Debugging Material for Day 1 (Released on 2 July 2024)
Last updated
This material is designed as supplementary to the Day 1 Lab Handout. You should not use this material without first reading the handout. Instead, refer to this material only if you encounter issues or bugs while following the handout.
While writing the image to the SD card, ensure your WiFi configurations are correct. Your Raspberry Pi should be able to connect to WiFi upon its initial power-up.
If you are using a Windows 10/11 or macOS hotspot to provide WiFi, you can easily view the IP address of your Raspberry Pi (2.4GHz).
Although the Raspberry Pi 4 can connect to 5.0GHz WiFi, the 2.4GHz band offers higher compatibility with the Raspberry Pi.
If you are using an iPhone hotspot, you may be unable to get the IP address of your Raspberry Pi directly. In this case, use NetSetMan to enumerate the devices connected to your iPhone and find the IP address of your Raspberry Pi. (Ensure your PC is connected to the iPhone's hotspot!)
If you cannot use the GUI mode of the Raspberry Pi or do not have a keyboard or mouse as peripherals, you can use SSH to configure your Raspberry Pi.
Ensure that in C1.10, you have enabled SSH in the OS Customisation section of the Raspberry Pi Imager.
To use SSH, you need to connect your PC and Raspberry Pi to the same network and know the IP address or the hostname of your Raspberry Pi.
for me, the SSH command is ssh pi@sws3009
or ssh pi@192.168.137.43
.
You should enable fingerprint check and enter the correct password for your Raspberry Pi. For security reasons, you will not see what you type during the password entry session.
Then, run sudo raspi-config
, and click Enter, you should see a blue screen with options in a grey box:
Use the Up and Down arrow keys to move the highlighted selection between the options available.
Press the Right arrow key or press Tab to access the <Select>
and <Finish>
buttons. Press Left or press Tab to return to the options.
Select the "Interfaces" tab and enable:
Camera*
SSH (you should have enabled)
VNC
If you did not see the camera at this stage, it is OK! We will guide you in C6.1.
You should reboot your Raspberry Pi after changing the above configurations, run sudo reboot
to restart your Raspberry Pi.
Please download VNC from: https://www.realvnc.com/en/connect/download/
If you encounter the “Cannot currently show the desktop” error while using VNC, you can resolve this issue by editing the boot/config.txt
file on your Raspberry Pi. Please read the section 2 at: https://www.comp.nus.edu.sg/~guoyi/tutorial/cg2111a/ros-setup/.
rpicam-hello
You should see if your RPi Camera can work correctly:
However, if you see the following outputs, meaning your RPi Camera did NOT set up correctly yet.
Unplug the power supply of the Raspberry Pi and unplug the RPi camera from your Raspberry Pi.
Plug in the Camera wire, note the metal surface should face to the SD Card end of your Raspberry Pi. Then power the Raspberry Pi.
Run vcgencmd get_camera
in the terminal, we expect the answer is:
If you see this response, meaning your RPi Camera is ready and you can resume your work from C6.1.
However, if you see something like:
Meaning that your Raspberry Pi is unable to detect and support the camera, we should manually add some code in configuration file:
Open the terminal and enter the following command:
Then add the following lines to the file:
Save the file and exit (press Ctrl+X
, then press Y
, and finally press Enter
).
Restart the Raspberry Pi: To apply the changes, restart your Raspberry Pi:
After restarting, you can test if the Pi Camera is working correctly by running the following command:
If the camera is enabled correctly, you should see the following output:
You can resume your work from C6.1.
rpicam-jpeg --output test.jpg
By running the above commandm, you should see the following outputs from the terminal:
You may see the test picture from /home/pi/test.jpg
.
While you run the python code, and see the error from Traceback, meaning you have not installed some libraries:
To install the cv2
library (OpenCV) in a virtual environment (venv) on a Raspberry Pi 4, follow these steps:
Update and Upgrade the System: First, ensure your system is up to date:
Install Dependencies: OpenCV requires several dependencies. Install them using the following command:
Create and Activate a Virtual Environment: Create a new virtual environment and activate it:
Install pip
and wheel
: Ensure pip
and wheel
are installed and up to date in your virtual environment:
Install OpenCV: Install OpenCV in your virtual environment:
If you need the full OpenCV package with GUI support, you can install:
Verify the Installation: Check if OpenCV is installed correctly by running a simple Python script:
To install the cv2
library (OpenCV) as system package on a Raspberry Pi 4, run:
You may need download a xml file from: https://github.com/opencv/opencv/raw/master/data/haarcascades/haarcascade_frontalface_default.xml