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 PS3 Controller Bluetooth Pairing Issue: Native MAC vs Hard-Coded MAC, SixaxisPairTool

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 syntactically correct, but a PS3 (DualShock 3/Sixaxis) will only connect to the single Bluetooth MAC address stored as its “master.” Hard‑coding a MAC in Ps3.begin("F0:F0:02:4C:AC:3B") will only work if the controller has that exact address stored. On some ESP32 DevKit V1 boards, overriding the BT MAC is unreliable; use the board’s native BT MAC and pair the controller to it.
  • Key points
    • Read the ESP32 DevKit V1’s native Bluetooth MAC.
    • Program the controller’s “master” to that MAC with SixaxisPairTool (or equivalent).
    • Call Ps3.begin() without arguments (use native MAC).
    • Ensure stable power and recent ESP32 core + library.

Detailed problem analysis

  • PS3 controller pairing model
    • A PS3 controller does not “scan.” It initiates a connection only to the master MAC stored in its EEPROM. If that MAC doesn’t match what your ESP32 is advertising, it will blink and never connect.
  • MAC spoofing vs native MAC
    • Ps3.begin("") asks the library to advertise a custom MAC. Depending on silicon revision/board package/efuse config, some ESP32 DevKit V1 boards don’t reliably honor BT MAC overrides at runtime. This explains “works on ESP32‑32S, fails on DevKit V1” with identical sketches.
    • Using the native BT MAC (no argument to Ps3.begin) is the most robust approach across boards.
  • Library/API correctness
    • With the widely used jvpernis/esp32-ps3 library: Ps3.begin([optional_mac]) returns void; use Ps3.isConnected(), Ps3.attach(), Ps3.attachOnDisconnect() for state.
  • Power and RF considerations
    • BT bring‑up causes short current spikes; marginal USB ports/cables can brown out the radio while the CPU appears fine. DevKit V1 clones vary in LDO/5V path and antenna layout, making them more sensitive than some 32S modules.
  • NVS (flash) and board core
    • Old BT keys/partitions can linger when switching cores/partitions. Erasing flash (or at least NVS) removes stale BT state.

Current information and trends

  • Practitioners commonly report:
    • DS3 requires writing the ESP32’s MAC into the controller with SixaxisPairTool.
    • Some DevKit V1 boards show problems when forcing a custom BT MAC; native MAC pairing solves it.
    • Alternative stacks (e.g., Bluepad32) exist and support DS3, but jvpernis/esp32-ps3 remains the simplest for DS3 HID with Arduino.
  • Industry trend
    • More users migrate to unified gamepad stacks (multi‑controller HID with BLE/BT Classic). For DS3 specifically, BT Classic remains the required path; BLE-only controllers (e.g., newer gamepads) differ.

Supporting explanations and details

  • How to read the ESP32 DevKit V1 native BT MAC (does not require enabling BT first):

    • Code snippet:
      
      #include <Arduino.h>
      #include "esp_system.h"

    void setup() { Serial.begin(115200); uint8_t mac[6]; esp_read_mac(mac, ESP_MAC_BT); // read Bluetooth (not WiFi) MAC Serial.printf("ESP32 BT MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } void loop() {}

  • Minimal, robust PS3 test sketch (native MAC; attach callbacks; throttled prints):

    #include <Ps3Controller.h>
    void onConnect() { Serial.println("PS3 connected"); }
    void onDisconnect() { Serial.println("PS3 disconnected"); }
    void setup() {
    Serial.begin(115200);
    delay(500);
    // Optional: print native BT MAC for SixaxisPairTool
    uint8_t mac[6];
    esp_read_mac(mac, ESP_MAC_BT);
    Serial.printf("Pair controller to: %02X:%02X:%02X:%02X:%02X:%02X\n",
    mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
    Ps3.attachOnConnect(onConnect);
    Ps3.attachOnDisconnect(onDisconnect);
    Ps3.begin(); // use native MAC
    Serial.println("Ready. Press PS button.");
    }
    void loop() {
    static uint32_t t;
    if (millis() - t > 1000) {
    t = millis();
    Serial.println(Ps3.isConnected() ? "Connected!" : "Waiting...");
    }
    }
  • Pairing procedure
    • Connect DS3 via USB to PC.
    • Run SixaxisPairTool; set the controller’s master to the BT MAC you printed from the ESP32 DevKit V1.
    • Disconnect USB, power the ESP32, then short‑press the PS button.

Ethical and legal aspects

  • Use authentic or properly licensed controllers and software tools.
  • Respect local wireless regulations; don’t spoof MACs of devices you don’t own/control.

Practical guidelines

  • Implementation checklist
    • Read and note the DevKit V1 BT MAC (ESP_MAC_BT).
    • Program controller’s master to that MAC with SixaxisPairTool.
    • Use Ps3.begin() without arguments.
    • Enable Arduino “Core Debug Level: Verbose” to see BT bring‑up logs.
    • Partition scheme: use a standard “No OTA (Large APP)” or “Default” to avoid tight app space; not usually critical for this library.
    • Power: good data‑rated USB cable; >1 A 5 V supply if powering standalone.
    • RF: keep the PCB antenna edge clear of ground/metal; avoid metal benches.
  • Potential challenges and mitigations
    • Controller keeps blinking, never connects: master MAC mismatch → re‑pair with correct MAC.
    • Connects once, then fails after reflash: stale NVS → erase flash/NVS and repeat pairing.
    • Frequent disconnects: power/antenna issues → improve supply and placement.

Possible disclaimers or additional notes

  • Third‑party “PS3‑compatible” controllers sometimes deviate from DS3 HID behavior; results can vary.
  • Some DevKit V1 clones may still resist MAC overrides; stay with native‑MAC method.

Suggestions for further research

  • Evaluate Bluepad32 if you need multi‑controller support or other gamepads in one firmware.
  • If you must change the ESP32 BT MAC dynamically, prototype with ESP‑IDF examples to confirm silicon/ROM support on your module revision.
  • Investigate coexistence if you plan to run Wi‑Fi and DS3 concurrently (throughput vs latency, antenna detuning).

Brief summary

  • Don’t hard‑code an arbitrary MAC. Read the ESP32 DevKit V1’s native BT MAC, write that MAC into the PS3 controller using SixaxisPairTool, then call Ps3.begin() with no arguments. Ensure solid power, recent core/library, and clear antenna placement. This native‑MAC pairing path is the most reliable fix for the “works on ESP32‑32S, not on DevKit V1” symptom. If problems persist, erase flash/NVS and repeat the pairing flow.

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.