logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

ESP32 DevKit V1 PS3Controller Library Bluetooth Pairing Issue with Hardcoded MAC

User question

#include <Ps3Controller.h>

void setup()
{

Serial.begin(115200);
Ps3.begin("F0:F0:02:4C:AC:3B");


delay(500);
Serial.println("Ready.");
}

void loop()
{
if (Ps3.isConnected()){
Serial.println("Connected!");
}

delay(3000);
}

Artificial Intelligence Response

Direct answer to the question

  • Your sketch is fine as a minimal heartbeat, but it will report “Connected!” only if the PS3 controller is paired to the exact Bluetooth MAC address your ESP32 is using.
  • Hardcoding Ps3.begin("F0:F0:02:4C:AC:3B") will work only if:
    • The ESP32 is actually using that address, and
    • The controller’s stored “master” address is the same.
  • The quickest fix is to use the ESP32’s own Bluetooth MAC and pair the controller to it, or call Ps3.begin() with no parameter and then pair the controller to the printed address.

Detailed problem analysis

  • Pairing model (PS3 controllers):
    • A PS3 controller does not do general discovery/pairing. It stores one “master” BD_ADDR (Bluetooth MAC) and connects only to that address.
    • The jvpernis/esp32-ps3 library lets you:
    • Use the ESP32’s native BD_ADDR: Ps3.begin();
    • Or spoof a BD_ADDR: Ps3.begin("XX:XX:XX:XX:XX:XX").
    • If you hardcode a spoofed address that doesn’t match what’s saved inside the controller, it will blink and never connect. If another device on the air uses that same BD_ADDR, connections will also fail or be erratic.
  • Why it can work on one ESP32 but not another:
    • Each board has a different factory MAC. If you paired the controller to Board A’s MAC but now run the same sketch on Board B with a different MAC (or with an arbitrary spoofed MAC), the controller won’t connect until you update its stored master address.
  • Common pitfalls that look like “library or DevKit issue” but are not:
    • Using a board variant that lacks Bluetooth Classic (ESP32-S2/C3 do not support BT Classic; PS3 requires Classic HID, not BLE).
    • Power droop during BT init (brownout) on some DevKit V1 regulators/USB cables.
    • Insufficient flash “app” partition causing BT stack init to fail silently.
    • Residual NVS/BT keys from previous experiments.
    • Third‑party “PS3-compatible” controllers that don’t fully follow the original HID over BT behavior.
  • What your current code does:
    • Initializes Serial, sets ESP32 BT to the fixed BD_ADDR "F0:F0:02:4C:AC:3B", prints “Ready.”, then every 3 s prints “Connected!” only if a PS3 link is up.
    • It gives no feedback about pairing state. Adding callbacks and more logging greatly speeds diagnosis.

Current information and trends

  • Community experience consistently shows MAC/master mismatch as the number-one cause of no-connect symptoms with PS3 on ESP32.
  • Users frequently report DevKit V1 “works-after” actions: pairing the controller to the board’s true MAC, switching to a “Huge App” partition, erasing NVS, and ensuring adequate 5 V/3.3 V power.
  • Third-party PS3 pads are mixed: some only connect after multiple retries; some never complete authentication.

Supporting explanations and details

  • Retrieve and use the ESP32’s real BT MAC, then pair the controller to it:

    • Minimal diagnostic sketch:
      
      #include <Ps3Controller.h>

    void onConnect() { Serial.println("=== CONNECTED ==="); } void onDisconnect() { Serial.println("=== DISCONNECTED ==="); }

    void setup() { Serial.begin(115200); Serial.println("\nPS3 host starting..."); Ps3.attachOnConnect(onConnect); Ps3.attachOnDisconnect(onDisconnect);

    // Prefer using the native address first: Ps3.begin(); Serial.print("ESP32 BT MAC: "); Serial.println(Ps3.getAddress()); // Note this address

    Serial.println("Pair controller to the above MAC, then press the PS button."); }

    void loop() { static uint32_t t; if (millis() - t > 2000) { t = millis(); Serial.println(Ps3.isConnected() ? "Status: CONNECTED" : "Status: WAITING"); } }

    
    - Pairing steps (once):
    - Connect the controller to a PC via USB.
    - Use SixaxisPairTool (Windows/macOS) or sixpair (Linux) to set the controller’s “Current Master” to the MAC printed by Ps3.getAddress().
    - Unplug USB, power the ESP32, and press the PS button.
  • If you must spoof a specific MAC:
    • Call Ps3.begin("AA:BB:CC:DD:EE:FF"); then program the controller’s master address to the exact same value.
    • Avoid arbitrary or duplicate addresses; collisions will break connectivity.
  • Power integrity:
    • Symptoms: resets, “brownout detector triggered”, or silent BT init failures at Ps3.begin().
    • Mitigations: short, good USB cable; powered USB hub; add ≥100 µF bulk cap across 5V–GND near the module; ensure solid 3.3 V regulation.
  • Flash/partitioning and NVS:
    • Use a partition that leaves ample app space (e.g., “Huge App 3MB no OTA”).
    • If behavior is weird after many experiments, erase NVS or full flash and re-upload.
  • Board family check:
    • Ensure the module can: “ESP-WROOM-32” / “ESP32-D0WD”. If it says ESP32‑S2 or ESP32‑C3, PS3 Classic HID will not work.

Ethical and legal aspects

  • MAC spoofing:
    • Using a fabricated BD_ADDR can conflict with other devices and may violate local policies. Prefer the factory MAC, and only use a spoofed address in controlled environments.
  • Bluetooth compliance and radio emissions:
    • Keep within appropriate regulatory use; avoid high‑gain antennas close to people without assessment.

Practical guidelines

  • Fast path to success:
    1. Flash the diagnostic sketch above with Ps3.begin() (no parameter).
    2. Note the printed ESP32 BT MAC.
    3. Program the controller’s master address to that MAC via SixaxisPairTool/sixpair.
    4. Power-cycle ESP32, press PS button; expect “=== CONNECTED ===” within a few seconds.
  • If still failing:
    • Confirm the board is an ESP32 (not S2/C3).
    • Change partition to “Huge App”.
    • Try a different USB cable or 5 V supply; add a 100–220 µF cap at 5 V.
    • Erase NVS (Tools → “Erase All Flash Before Upload”, or esptool erase_flash).
    • Try an official Sony controller if using a clone.
  • Optional alternative stack:
    • If you need multi‑gamepad support or extensive HID handling, consider BluePad32. For PS3 specifically, the jvpernis library remains simple and effective once pairing is correct.

Possible disclaimers or additional notes

  • Some third‑party PS3 controllers never complete the legacy authentication sequence and won’t connect even with correct MAC pairing.
  • Arduino core/library combinations evolve; if you hit a regression on a brand‑new core, try a previously stable core release for validation.

Suggestions for further research

  • Investigate controller behavior via HCI logs (ESP-IDF BT log levels) to see authentication/ACL states.
  • Evaluate RF environment (2.4 GHz congestion, metal nearby) if links drop after connecting.
  • Explore migrating to a modern controller (e.g., Switch/PS4/PS5) with libraries that support both BLE and Classic, if PS3 hardware is the bottleneck.

Brief summary

  • Your code is fine but relies on a correct MAC pairing model. Stop hardcoding an arbitrary MAC unless you also program the controller to that same value.
  • Best practice: call Ps3.begin(), print Ps3.getAddress(), set the controller’s master to that MAC, then press the PS button.
  • Verify the board supports BT Classic, ensure solid power, choose a large-app partition, and clear NVS if needed.

Ask additional question

Wait...(2min)
Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.