COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
    • RC RACE CAR PART 4
  • MORE
    • CLASS PROJECTS
    • BLOCKY GAMES
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
    • RC RACE CAR PART 4
  • MORE
    • CLASS PROJECTS
    • BLOCKY GAMES
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
Picture
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:
  • 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)
Avoid (for low latency):
  • Random USB webcams (some are fine, but often add delay and are less consistent)
2. Connect the camera ribbon cable
  1. Power off the Pi completely.
  2. Locate the CSI camera port on the Pi.
  3. Gently lift the black latch.
  4. Insert the ribbon cable fully:
    • Metal contacts facing the correct direction (depends on Pi model; check port orientation)
  5. Push the latch down to lock.
Common mistake: ribbon cable not fully seated → camera “not detected”.

Part 2 — Software: Enable + Test the Camera
1. Update the PiRun:
  • sudo apt update
  • sudo apt upgrade -y
2. Confirm the camera is detectedRun:
  • libcamera-hello
If it works, you’ll see a live preview (or it will run briefly then exit).
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:
  1. Camera capture time
  2. Encoding (compressing video on the Pi)
  3. Network delay (Wi-Fi congestion/interference)
  4. Decoding and display on the PC
  5. Buffering (this is the killer—many “easy” streaming tools buffer heavily)
Goal: keep buffering low and use a streaming method designed for real-time video.

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>
3. WebRTC tuning for low latencyUse these targets (starting point):
  • Resolution: 1280×720 or 960×540
  • Frame rate: 30 fps
  • Bitrate: 2–6 Mbps depending on network quality
If you see lag:
  • Reduce resolution first (biggest impact)
  • Then reduce fps
  • Then reduce bitrate
Why this works: WebRTC avoids heavy buffering and adapts smoothly.

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
Typical behaviour:
  • 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
2. Prefer 5 GHz Wi-Fi
  • Faster, less interference
  • Shorter range than 2.4 GHz, but great for a track in one space
3. Put the router close to the track
  • Line-of-sight if possible
  • Avoid hiding it behind metal benches, radiators, or PC towers
4. Connect the PC via Ethernet (if possible)Best setup:
  • PC → Ethernet to router
  • Pi → Wi-Fi to router (5 GHz)
This reduces jitter and random spikes.

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
Symptom: Video freezes or stutters
  • Network congestion or bitrate too high
    Fix:
  • Lower resolution (720p → 540p)
  • Lower bitrate
  • Move router closer
Symptom: Video is low delay but blocky
  • Bitrate too low
    Fix:
  • Slightly increase bitrate (don’t increase resolution first)

Part 8 — Measuring Latency (Simple Classroom Test)“Stopwatch test”
  1. Open a stopwatch app on a phone.
  2. Point the RC camera at the stopwatch.
  3. Compare the time on the phone vs the time you see on the PC screen.
  4. The difference is your approximate latency.
Targets:
  • 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
If the stream works on Pi but not on PC
  • 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
If you get high delay suddenly
  • Someone else may be streaming too (bandwidth limit)
  • Too many devices on the router
  • Router too far away
  • Bitrate too high

Logbook Tasks (Students)
  1. What resolution and frame rate did you choose, and why?
  2. What was your measured latency using the stopwatch test?
  3. What changes reduced lag the most?
  4. Why is dedicated 5 GHz Wi-Fi better than the school network for this project?
  5. What trade-off exists between video quality and latency?
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.