This library enables connecting BLE (Bluetooth Low Energy) gamepads to ESP32 boards. Supported gamepads include the Xbox Wireless Controller and the Steam Controller.
- Open Arduino Library Manager: Tools -> Manage Libraries.
- Search for
BLE-Gamepad-Clientand install it.
Add the following line to the lib_deps option of platformio.ini file.
tbekas/BLE-Gamepad-Client@^0.11.0#include <Arduino.h>
#include <BLEGamepadClient.h>
XboxController controller;
void setup(void) {
Serial.begin(115200);
controller.begin();
}
void loop() {
if (controller.isConnected()) {
XboxControlsState s;
controller.read(&s);
Serial.printf("lx: %.2f, ly: %.2f, rx: %.2f, ry: %.2f\n",
s.leftStickX, s.leftStickY, s.rightStickX, s.rightStickY);
} else {
Serial.println("controller not connected");
}
delay(100);
}#include <Arduino.h>
#include <BLEGamepadClient.h>
XboxController controller;
void onValueChanged(XboxControlsState &s) {
Serial.printf("lx: %.2f, ly: %.2f, rx: %.2f, ry: %.2f\n",
s.leftStickX, s.leftStickY, s.rightStickX, s.rightStickY);
}
void setup(void) {
Serial.begin(115200);
controller.begin();
controller.onValueChanged(onValueChanged);
}
void loop() {
delay(100);
}
Checkout the code examples in the examples directory.
Install BLE firmware using these instructions: Steam Controller BLE.
- Turn on your controller by pressing the Steam button while holding the Y button.
SteamControllerSteamControlsState
Update controller's firmware to version 5.x using these instructions: Update your Xbox Wireless Controller.
- Turn on your controller by pressing the Xbox button.
- Press and hold the controller’s pair button for 3 seconds, then release.
XboxControllerXboxControlsStateXboxBatteryStateXboxVibrationsCommand
Your controller most likely already runs firmware version 5.x. If not, follow these instructions to update it: Update your Xbox Wireless Controller.
- Turn on your controller by pressing the Xbox button.
- Press and hold the controller’s pair button for 3 seconds, then release.
XboxControllerXboxControlsStateXboxBatteryStateXboxVibrationsCommand
- h2zero for the excellent NimBLE-Arduino library, which this library is built upon.


