Time estimate
Scheduled time: 11:35 AM – 12:15 PM (40 minutes)
Running the test suite
1
SSH into your robot
Open a terminal and connect to your Pi over SSH. Use the hostname and username you set during imaging.
2
Launch the test script
Run the test suite with The script initializes the PiCar-X hardware and drops you into an interactive menu.
sudo (required for hardware access):3
Use the menu
You see a menu like this:
- Type 1–6 to run a single test.
- Type a to run every test in order.
- Type r to print a results summary at any time.
- Type q to quit (the summary prints automatically on exit).
4
Confirm each result
At the end of every test, the script asks:
- Press y if the hardware behaved as expected.
- Press n if something was wrong.
- Press s if you want to skip it for now.
Each test in detail
Test 1 — Ultrasonic distance sensor
What does this test do?
What does this test do?
The script reads the HC-SR04 ultrasonic sensor 10 times, one reading per second. Each reading shows the distance to the nearest object in centimeters, along with a small bar chart.
—) means “no echo received” — the sensor didn’t detect anything within range. This is normal if nothing is in front of the robot.
PASS criteria: values change when you move your hand near the sensor.
Test 2 — Grayscale sensor
What does this test do?
What does this test do?
The script reads all 3 channels (Left, Center, Right) of the grayscale sensor module 10 times, one reading per second. It also reports the cliff detection status and line-following status for each reading.
- High values (800–1400) on light surfaces (white paper, light-colored desk).
- Low values (100–400) on dark surfaces (black tape, dark paper).
no on a normal surface and YES when the sensor is lifted off the table.
Test 3 — Servos
What does this test do?
What does this test do?
The script sweeps all 3 servos through their full range of motion (–35° to +35°), one at a time:
- Steering servo — turns the front wheels left and right.
- Camera pan servo — rotates the camera horizontally.
- Camera tilt servo — tilts the camera up and down.
Servo movement is jerky or stuttering
Servo movement is jerky or stuttering
This almost always means low battery. The servos draw significant current during movement. Charge your batteries and try again.
One or more servos don't move at all
One or more servos don't move at all
Power off the robot and check the servo cable connections on the Robot HAT. Each servo plugs into a specific 3-pin header — make sure none are loose or plugged into the wrong port.
Test 4 — DC motors
What does this test do?
What does this test do?
The script runs both DC drive motors at 30% speed:
- Forward for 2 seconds.
- Pause for half a second.
- Backward for 2 seconds.
- Stop.
Car goes backward when it should go forward
Car goes backward when it should go forward
The motor direction needs to be swapped. Run the calibration script again and use option 2 (motor direction):Select option
2, then follow the prompts to reverse the motor direction.Only one wheel spins
Only one wheel spins
Check the motor cable connections on the Robot HAT. One of the two motor connectors may be loose.
Neither wheel spins
Neither wheel spins
Make sure the Robot HAT power switch is on and batteries are charged. Motors require more current than sensors — a low battery can power the Pi but not the motors.
Test 5 — Camera
What does this test do?
What does this test do?
The script captures a single still image and saves it to
~/test_capture.jpg. It uses picamera2 if available, falling back to libcamera-still. After capturing, it prints the file size so you can verify the image is real."Camera not found" or capture failed
"Camera not found" or capture failed
The CSI ribbon cable is likely loose. Power off the Pi, gently reseat the flat ribbon cable where it plugs into the camera port on the Pi, and make sure the locking clip is pushed down. Then power back on and re-run the test.
File size is 0 or very small
File size is 0 or very small
The camera module may be defective or the ribbon cable is partially disconnected. Try reseating the cable at both ends (the camera board and the Pi board).
Test 6 — Battery and speaker
This test has two parts.Battery voltage
What does this test do?
What does this test do?
The script reads the battery voltage from the Robot HAT’s ADC (analog-to-digital converter) on channel A4. It converts the raw ADC reading to a voltage estimate.
You can monitor battery voltage at any time without running the full test suite:For live monitoring that updates every 2 seconds, add the Press Ctrl-C to stop the live monitor.
--watch flag:Speaker
What does this test do?
What does this test do?
The script plays a 4-second sine wave test tone through the Robot HAT’s onboard speaker, then follows up with a text-to-speech phrase (“Hello. Picar X speaker test.”) using
espeak.The speaker is powered through the battery, not the USB port. You need charged batteries (above 7 V) for the onboard amplifier to produce audible sound. If you don’t hear anything, check your battery voltage first.
Results summary
After you finish all six tests (or whenever you want a status check), press r at the menu to see the summary:It’s OK if the speaker shows [SKIP] because your batteries are low. You can always test the speaker later after charging. Everything else should be [PASS] before you move on to Day 2.
Troubleshooting
Day 1 wrap-up
Checkpoint: every student ends Day 1 with all sensors showing [PASS] and a confirmed SSH connection to their robot.
What you accomplished today
- Imaged an SD card with Raspberry Pi OS and configured Wi-Fi, SSH, and Pi Connect.
- Connected to your PiCar-X over SSH for the first time.
- Installed all SunFounder libraries (robot-hat, vilib, picar-x).
- Calibrated the steering servo, motor direction, and grayscale cliff threshold.
- Validated every sensor and actuator on the robot with the test suite.
What’s coming on Day 2
Tomorrow you start writing real programs for your robot:- Movement programs — drive in patterns, steer with code, and control speed.
- Text-to-speech — make the robot talk using
espeak. - Line following — use the grayscale sensor to follow a track.
- Computer vision — process camera frames to detect objects and colors.
Homework: leave your robot powered on and connected to Wi-Fi overnight. Tomorrow morning you should be able to SSH right in and start coding without any setup delay.

