0

I'm trying to send data from a ps3 controller to my Raspberry Pi, but the code I'm using does not pick up any data sent from the controller. The controller is connected yet nothing happens when I press any of the buttons.

import socket

hostMACAddress = 'B8:27:EB:CC:F0:7B' # The MAC address of raspberry pi
port = 3
backlog = 1
size = 1024
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.bind((hostMACAddress,port))
s.listen(backlog)
print('start')
try:
    client, address = s.accept()
    while 1:
        data = client.recv(size)
        if data:
            print(data)
            client.send(data)
except: 
    print("Closing socket") 
    client.close()

Is there something wrong with my code? Am I trying to read the Ps3 controller's data in an incorrect way?

I have also made sure that the controller is definitely connected to the RPi using the bluetoothctl command . The controller also has a single led lit, which suggests it is connected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.