RASPBERRY PI | RC RACE CAR (PART 1)
SECTION 1 | CAMERA SETUP
You will add a first-person camera to the RC car and stream it to a Windows PC with as little delay (latency) as possible. By the end, you should be able to:
Part 1 — Hardware: Connecting the Camera Correctly
1. Choose the right cameraRecommended:
Part 2 — Software: Enable + Test the Camera
1. Update the PiRun:
3. Quick sanity checks (if it doesn’t work)
Part 3 — The Big Idea: Where Latency Comes From
Latency is the time between:
the camera seeing something → you seeing it on the PC
The main sources:
Part 4 — Best Option for Low Latency: Web
RTC Streaming (Recommended)WebRTC is built for real-time video calls, so it’s excellent for low-latency streaming.
1. Install a WebRTC streamerDepending on your Pi OS image, you may use a package or install via instructions your teacher provides. If it’s already installed, skip this.
2. Run the stream (typical workflow)You will start a WebRTC streaming service on the Pi, then open a webpage on your PC using the Pi’s IP address.
Part 5 — Alternative: MJPEG Streaming (Easy, but Higher Latency)
MJPEG is simple and browser-friendly, but usually more delay and more bandwidth use.
Use MJPEG only if:
Part 6 — Network Setup for Minimal Lag (Do This!)
1. Use a dedicated router/access pointDo not use the school Wi-Fi.
Part 7 — Settings That Usually Cause Lag (and How to Fix Them)
Common lag symptoms → fixesSymptom: Video is smooth but delayed
Part 8 — Measuring Latency (Simple Classroom Test)“Stopwatch test”
Part 9 — Troubleshooting Checklist
If the camera isn’t detected
Logbook Tasks (Students)
- Confirm the Raspberry Pi camera works reliably
- Stream video to your PC over a dedicated local Wi-Fi network
- Tune settings to reduce lag and stutter
Part 1 — Hardware: Connecting the Camera Correctly
1. Choose the right cameraRecommended:
- Raspberry Pi Camera Module 3 (wide is great for racing/track view)
- Random USB webcams (some are fine, but often add delay and are less consistent)
- Power off the Pi completely.
- Locate the CSI camera port on the Pi.
- Gently lift the black latch.
- Insert the ribbon cable fully:
- Metal contacts facing the correct direction (depends on Pi model; check port orientation)
- Push the latch down to lock.
Part 2 — Software: Enable + Test the Camera
1. Update the PiRun:
- sudo apt update
- sudo apt upgrade -y
- libcamera-hello
3. Quick sanity checks (if it doesn’t work)
- Re-seat ribbon cable (most common fix)
- Try:
- libcamera-still -o test.jpg
- Ensure you’re using Raspberry Pi OS that supports libcamera (modern Pi OS does)
Part 3 — The Big Idea: Where Latency Comes From
Latency is the time between:
the camera seeing something → you seeing it on the PC
The main sources:
- Camera capture time
- Encoding (compressing video on the Pi)
- Network delay (Wi-Fi congestion/interference)
- Decoding and display on the PC
- Buffering (this is the killer—many “easy” streaming tools buffer heavily)
Part 4 — Best Option for Low Latency: Web
RTC Streaming (Recommended)WebRTC is built for real-time video calls, so it’s excellent for low-latency streaming.
1. Install a WebRTC streamerDepending on your Pi OS image, you may use a package or install via instructions your teacher provides. If it’s already installed, skip this.
2. Run the stream (typical workflow)You will start a WebRTC streaming service on the Pi, then open a webpage on your PC using the Pi’s IP address.
- Find Pi IP:
- hostname -I
- On your PC browser, go to:
- http://<pi_ip_address>:<port>
- Resolution: 1280×720 or 960×540
- Frame rate: 30 fps
- Bitrate: 2–6 Mbps depending on network quality
- Reduce resolution first (biggest impact)
- Then reduce fps
- Then reduce bitrate
Part 5 — Alternative: MJPEG Streaming (Easy, but Higher Latency)
MJPEG is simple and browser-friendly, but usually more delay and more bandwidth use.
Use MJPEG only if:
- WebRTC setup is not available yet
- You need a quick proof-of-concept
- Easy to view in a browser
- Often noticeably laggier than WebRTC
- Can overload Wi-Fi if many teams stream at once
Part 6 — Network Setup for Minimal Lag (Do This!)
1. Use a dedicated router/access pointDo not use the school Wi-Fi.
- Too many devices
- Too much interference
- Too many routing rules
- Faster, less interference
- Shorter range than 2.4 GHz, but great for a track in one space
- Line-of-sight if possible
- Avoid hiding it behind metal benches, radiators, or PC towers
- PC → Ethernet to router
- Pi → Wi-Fi to router (5 GHz)
Part 7 — Settings That Usually Cause Lag (and How to Fix Them)
Common lag symptoms → fixesSymptom: Video is smooth but delayed
- Your stream is buffering too much
Fix: - Switch to WebRTC
- Reduce buffering settings if using other tools
- Network congestion or bitrate too high
Fix: - Lower resolution (720p → 540p)
- Lower bitrate
- Move router closer
- Bitrate too low
Fix: - Slightly increase bitrate (don’t increase resolution first)
Part 8 — Measuring Latency (Simple Classroom Test)“Stopwatch test”
- Open a stopwatch app on a phone.
- Point the RC camera at the stopwatch.
- Compare the time on the phone vs the time you see on the PC screen.
- The difference is your approximate latency.
- Excellent: ~70–150 ms
- Good: ~150–250 ms
- Usable: ~250–400 ms
- Hard to drive: 400 ms+
Part 9 — Troubleshooting Checklist
If the camera isn’t detected
- Re-seat ribbon cable
- Ensure latch is locked
- Try a different cable/camera (if available)
- Run:
- libcamera-hello
- PC and Pi must be on the same network
- Check Pi IP address again
- Check firewall settings on PC (rare, but possible)
- Confirm the correct port is being used
- Someone else may be streaming too (bandwidth limit)
- Too many devices on the router
- Router too far away
- Bitrate too high
Logbook Tasks (Students)
- What resolution and frame rate did you choose, and why?
- What was your measured latency using the stopwatch test?
- What changes reduced lag the most?
- Why is dedicated 5 GHz Wi-Fi better than the school network for this project?
- What trade-off exists between video quality and latency?