Setting Up a Pi 5 to Control the UGV Rover with a PS4 Controller
Goal: Get the Raspberry Pi 5 running on a wall adapter, connect it to the rover, and control it using a PS4 controller. Display status on a small OLED.
Note: This guide assumes you don’t have battery power yet, no sensors, and no buck converter.
- Hardware You’ll Need
Raspberry Pi 5 (with microSD card containing Raspberry Pi OS)
Wall power supply for the Pi (5V USB-C)
Rover with the General Driver Board (ESP32-based)
PS4 Wireless Controller
Small OLED (e.g., 0.91") for status display
USB keyboard + HDMI monitor (for initial setup)
Optional: Windows PC with PuTTY installed for SSH
- Initial Pi Setup
Flash Raspberry Pi OS onto the microSD card.
Insert the SD card into the Pi and power it via wall adapter.
Connect a monitor and keyboard for setup.
Update the system:
sudo apt update && sudo apt upgrade -y
Enable SSH (for remote access via Windows PC):
sudo raspi-config
Navigate to Interface Options → SSH → Enable.
- Using PuTTY from Windows
Download PuTTY from https://www.putty.org
and install it.
Connect your Pi to the same network as your PC.
Open PuTTY, enter the Pi’s IP address, and select SSH.
Click Open and log in with the Pi username/password (default: pi / raspberry).
This allows you to access the Pi terminal without needing a monitor or keyboard connected directly to it.
- Set Up the UGV Python Environment
SSH into the Pi (or use terminal) and create your virtual environment:
python3 -m venv ~/ugv_env
source ~/ugv_env/bin/activate
Install necessary Python packages (example: evdev for controller):
pip install evdev pyserial gpiozero adafruit-circuitpython-ssd1306
Clone or copy your rover scripts into ~/ugv_rpi.
- Connect Pi to Rover
Connect the Pi GPIO UART pins (TX/RX) to the rover’s driver board if using serial communication.
Ensure the rover’s power is turned off—we are only powering the Pi via wall adapter.
- Test PS4 Controller Connection
Install ds4drv inside the virtual environment (or use preinstalled):
sudo ~/ugv_env/bin/ds4drv
Press the PS button on the controller to enter pairing mode.
Check for the controller:
bluetoothctl
scan on
Pair and trust the controller:
pair <controller_mac>
trust <controller_mac>
connect <controller_mac>
Confirm the Pi sees the controller:
python3
from evdev import list_devices, InputDevice
[InputDevice(path).name for path in list_devices()]
- Run Your Rover Control Script
Activate your environment:
cd ~/ugv_rpi
source ~/ugv_env/bin/activate
Run your main rover script (example: working_test_bluetooth.py):
python3 working_test_bluetooth.py
You should see output like:
Found PS4 controller: /dev/input/eventX
Sending command: left=0, right=0
Use the left and right sticks on the PS4 controller to drive the rover.
- Optional: Add OLED Status Display
Connect the OLED via I²C (SDA/SCL).
Example status code snippet:
import board, busio
from adafruit_ssd1306 import SSD1306_I2C
i2c = busio.I2C(board.SCL, board.SDA)
oled = SSD1306_I2C(128, 32, i2c)
oled.fill(0)
oled.text(“UGV Rover Ready”, 0, 0, 1)
oled.show()
Update the OLED dynamically in your control loop to show speed, connection status, or other info.
Notes
No battery yet: The Pi is powered via wall plug.
No sensors yet: This setup is for testing the rover and PS4 controller.
No buck converter: Battery power and voltage regulation will be added later.
At this point, your Pi is fully functional, the PS4 controller is paired, and the rover is controllable.