Pairing issues with your Bluetooth gamepad, Pybricks and the LMS-EPS32 board can come from many parts in the system. Here’s a step-by-step troubleshooting guide to find and elimintate these problems.
Preliminary Checks
- Ensure you have flashed the latest PyBricks firmware on the hub.
- Use our LMS-ESP32 installer web site to flash your LMS-ESP32 board with the BluePad32 LPF2 for PyBricks projects firmware.
- Confirm that the LMS-ESP32 is connected to the correct Port, the same as indicated your Python program where it says:
p=PUPRemoteHub(Port.D)
- Check if the controller is paired with the LMS-ESP32. Pairing is different for each brand and model. For a PS4 gamepad, you pair by holding the PS and Share button at the same time. When the gamepad is paired, it shows a constant blue light on the back.
Initial Testing of the gamepad connection
Run the gamepad_print.py
program. Do this with the LMS-ESP32 connected to the correct port and the controller paired.
# Add pupremote.py in pybricks, with the contents of pupremote_hub.py
# to run this.
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pupremote import PUPRemoteHub
p=PUPRemoteHub(Port.D)
p.add_command('gmpd',"hhhhHH","HHHHHHHH")
def btns_pressed(btns):
pressed = []
if btns & 1:
pressed.append("X")
if btns & 2:
pressed.append("O")
if btns & 4:
pressed.append("[]")
if btns & 8:
pressed.append("Δ")
return pressed
def dpad_pressed(btns):
pressed = []
if btns & 1:
pressed.append("D") # Down
if btns & 2:
pressed.append("R") # Right
if btns & 4:
pressed.append("L") # Left
if btns & 8:
pressed.append("U") # Up
return pressed
while 1:
lx, ly, rx, ry, btns, dpad = p.call('gmpd')
print("Left: {},{}. Right: {},{}. Buttons:{}. Dpad:{}".format(lx,ly,rx,ry,btns_pressed(btns), dpad_pressed(dpad)))
Observe the PyBricks IDE lower part for joystick positions and button states. If the controller is not connected, the program will run but show all zeros.
Try Resetting LMS-ESP32
If the above doesn’t resolve the issue, try pressing the small reset button on the LMS-ESP32 to see if it starts functioning correctly.
Try Reconnecting LMS-ESP32
- Disconnect the LMS-ESP32 from USB.
- Connect it to the hub on port D.
- Power on the hub.
- Pair it with PyBricks.
- Try running the
program above.gamepad_print
.py
Checking BluePad32 Firmware
- Connect the LMS-ESP32 to the robot.
- Power on the robot.
- Connect the LMS-ESP32 with a USB cable to the PC.
- Start a serial monitor (here’s a browser-based serial monitor for Chrome: https://googlechromelabs.github.io/serial-terminal/).
- Press ‘Connect’ and select the appropriate COM port.
- Press the small reset button on the LMS-ESP32.
- Look for an ‘Ack received’ line, indicating correct recognition by the PyBricks hub.
Pairing Gamepad with LMS-ESP32
After the above steps, pair the LMS-ESP32 with your controller and look for a confirmation message like ‘Gamepad is connected’. Note: The actual text may vary based on the controller type.
Additional Steps for Troubleshooting a Gamepad connection with LMS-ESP32
- Ensure you’re following the instructions in our gamepad connection guide correctly.
- Recheck all connections and setups if issues persist.
- Consider reviewing the code for any potential mismatches or errors in the setup.
If these steps do not resolve the issue, it’s advisable to reach out to us for further assistance.