Connecting A PS5 Controller With RaspberryPi Via Bluetooth - by Shyam Padia - Me
Connecting A PS5 Controller With RaspberryPi Via Bluetooth - by Shyam Padia - Me
Member-only story
This guide will teach you how to connect a PS5 controller to a Raspberry Pi via
bluetooth and install pydualsense to read the controller inputs in python which
supports gyroscopes and touchpad input as well.
Press and hold the PS button and Share button at the same time until the light bar
begins to flash, this should put the controller in pairing mode
Connect the controller to bluetooth via the GUI. Alternatively, you can also use
bluetoothctl if you face issues.
Open the Bluetooth settings on your raspberry pi and connect with Dual Sense
Wireless Controller and Pair with it
Verify that the controller is registered as a input device with ls /dev/input
You should see 4 events(event0, event1, event2, event3) and 2 js(js0, js1)
Install pydualsense
You can now start the installation for pydualsense and start reading the inputs
from the controller. You can also refer to pydualsense-documentation for
additional details
mkdir ps5_controller
cd ps5_controller
wget https://github.com/flok/pydualsense/blob/master/70-ps5-controller.rules
Add a udev rule to allow user to access controller without requiring root access
Install pydualsense
def cross_down(state):
dualsense.light.setColorI(255,0,0) # set touchpad color to red
print(f'cross {state}')
def circle_down(state):
dualsense.light.setColorI(0,255,0) # set touchpad color to green
print(f'circle {state}')
def dpad_down(state):
dualsense.light.setColorI(0,0,255) # set touchpad color to blue
print(f'dpad {state}')
def l2_down(state):
print(f'l2 {state}')
# close device
dualsense.close()
Run the python file and test different inputs and verify their output
Follow
No responses yet
No responses yet
Shyam Padia
[Lucian]
Dec 2 50 1
Lists
Staff picks
790 stories · 1519 saves
Aug 19 1
In Stackademic by Crafting-Code
Jun 22 249 2