# ESP32 auto bluetooth connect

**URL:** <https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318>\
**Category:** General Guidance\
**Created:** [August 26, 2026, 4:04pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318 "2026-08-26T16:04:15Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![deadrailtrains](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deadrailtrains/32/1282036_2.png) [@deadrailtrains](https://forum.arduino.cc/u/deadrailtrains)\
**Post date:** [August 26, 2026, 4:04pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/1 "2026-08-26T16:04:15Z")

</div>

When powering up, Is it possible to have the ESP32 automatically connect to an android devise that it is already paired to?

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [August 26, 2026, 4:08pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/2 "2026-08-26T16:08:38Z")

</div>

I would suspect so, if the code is right. You may need to store the credentials of the paired device. I never use the Bt features of the ESP32 but as i said, i suspect so.

---

<div class="post-metadata">

**Author:** ![drmpf](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drmpf/32/1126438_2.png) [@drmpf](https://forum.arduino.cc/u/drmpf)\
**Post date:** [August 27, 2026, 1:52am UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/3 "2026-08-27T01:52:15Z")

</div>

It might be possible if you write an app for Android that makes it look like a BLE server and then have the ESP32 be the client that opens a connection on start up.

While I have programmed Android as a client, I have not yet tried to set it up as the server. You may find Google has locked down the operation on security grounds.

What do you expect the Android to do once connected?

edit.  
Claude say Google support this and provided some very basic code, you would need to add a lot more.  
But you need to jump through some hoops to get an unvarying 'address' for the phone for the ESP32 to connect to. Not sure what support the ESP32 has for these hoops. Would need to do much more detailed design and testing.

---

<div class="post-metadata">

**Author:** ![deadrailtrains](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deadrailtrains/32/1282036_2.png) [@deadrailtrains](https://forum.arduino.cc/u/deadrailtrains)\
**Post date:** [August 27, 2026, 12:35pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/4 "2026-08-27T12:35:46Z")

</div>

I am just looking to save the steps of manually connecting. Every other Bluetooth device I have automatically connects when I turn it on, but not the ESP32s

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [August 27, 2026, 1:01pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/5 "2026-08-27T13:01:45Z")

</div>

> [@deadrailtrains](#):
>
> Every other Bluetooth device I have automatically connects when I turn it on, but not the ESP32s

And what (kind of) code do you use to connect the ESP32 to BT devices manually now ?

---

<div class="post-metadata">

**Author:** ![loveforcircuits](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/loveforcircuits/32/1127286_2.png) [@loveforcircuits](https://forum.arduino.cc/u/loveforcircuits)\
**Post date:** [August 27, 2026, 2:19pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/6 "2026-08-27T14:19:19Z")

</div>

You can check these contents.

> **[Bot Challenge](https://esp32.com/ext/espressif/stupidbots/challenge.php?n=MTc4Nzg0MDI5NC4zMDkzODY5MDky&c=3bace50d6ef81d3855c2762579590a43f1dfd5015ea7d268d0f7d4ff48d6fc87&h=f5b623091749aa65942cc106bed6b9f8d8e9da3cb0c60ae31bf57766a1582410&from=L3ZpZXd0b3BpYy5waHA%2FdD0xMTQ2OA%3D%3D)**

> **[Auto Reconnect](https://github.com/pschatzmann/ESP32-A2DP/wiki/Auto-Reconnect)**
>
> A Simple ESP32 Bluetooth A2DP Library (to implement a Music Receiver or Sender) that supports Arduino, PlatformIO and Espressif IDF - pschatzmann/ESP32-A2DP

---

<div class="post-metadata">

**Author:** ![deadrailtrains](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deadrailtrains/32/1282036_2.png) [@deadrailtrains](https://forum.arduino.cc/u/deadrailtrains)\
**Post date:** [August 27, 2026, 2:37pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/7 "2026-08-27T14:37:12Z")

</div>

Thanks. Turns out to be more complex than I expected.

---

<div class="post-metadata">

**Author:** ![deadrailtrains](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deadrailtrains/32/1282036_2.png) [@deadrailtrains](https://forum.arduino.cc/u/deadrailtrains)\
**Post date:** [September 1, 2026, 2:16pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/8 "2026-09-01T14:16:41Z")

</div>

This is the code on the ESP32

#include \<ESP32Servo.h\>  
#include \<analogWrite.h\>  
#include \<ESP32Tone.h\>  
#include \<ESP32PWM.h\>

#define LED2 2 // Built-in LED

#include "BluetoothSerial.h"  
String DATA;  
#if !defined(CONFIG\_BT\_ENABLED) || !defined(CONFIG\_BLUEDROID\_ENABLED)  
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it  
#endif

BluetoothSerial SerialBT;  
Servo servo\_13;  
Servo servo\_12;  
Servo servo\_15;  
Servo servo\_14;  
Servo servo\_27;  
Servo servo\_25;  
Servo servo\_26;  
Servo servo\_33;  
Servo servo\_32;  
Servo servo\_21;  
Servo servo\_22;  
Servo servo\_4;  
Servo servo\_18;  
Servo servo\_5;  
Servo servo\_19;  
Servo servo\_23;

void Bt\_Status (esp\_spp\_cb\_event\_t event, esp\_spp\_cb\_param\_t \*param) {

if (event == ESP\_SPP\_SRV\_OPEN\_EVT) {  
Serial.println ("Client Connected");  
digitalWrite (LED2, LOW);  
// Do stuff if connected  
}

else if (event == ESP\_SPP\_CLOSE\_EVT ) {  
Serial.println ("Client Disconnected");  
digitalWrite (LED2, HIGH);  
// Do stuff if not connected  
}  
}

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [September 1, 2026, 3:34pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/9 "2026-09-01T15:34:56Z")

</div>

> [@deadrailtrains](#):
>
> This is the code on the ESP32

Looks incomplete without setup() & loop(), also please put code within `<code>` tags so it will be properly formatted for the forum.

---

<div class="post-metadata">

**Author:** ![deadrailtrains](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deadrailtrains/32/1282036_2.png) [@deadrailtrains](https://forum.arduino.cc/u/deadrailtrains)\
**Post date:** [September 1, 2026, 4:19pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/10 "2026-09-01T16:19:54Z")

</div>

Here is more. the rest of the coding is just servo control and number printing.

```arduino
#include <ESP32Servo.h>
#include <analogWrite.h>
#include <ESP32Tone.h>
#include <ESP32PWM.h>

#define LED2 2 // Built-in LED

#include "BluetoothSerial.h"
String DATA;
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;
Servo servo_13;
Servo servo_12;
Servo servo_15;
Servo servo_14;
Servo servo_27;
Servo servo_25;
Servo servo_26;
Servo servo_33;
Servo servo_32;
Servo servo_21;
Servo servo_22;
Servo servo_4;
Servo servo_18;
Servo servo_5;
Servo servo_19;
Servo servo_23;

void Bt_Status (esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {

  if (event == ESP_SPP_SRV_OPEN_EVT) {
    Serial.println ("Client Connected");
    digitalWrite (LED2, LOW);
    // Do stuff if connected
  }

  else if (event == ESP_SPP_CLOSE_EVT ) {
    Serial.println ("Client Disconnected");
    digitalWrite (LED2, HIGH);
    // Do stuff if not connected
  }
}

```

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [September 1, 2026, 4:45pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/11 "2026-09-01T16:45:11Z")

</div>

> [@deadrailtrains](#):
>
> Here is more. the rest of the coding is just servo control and number printing.

It still does not compile due to the reason previously mentioned. What is required is an example that you use to connect to another BT device manually, and that is a complete sketch including setup() and loop()

---

<div class="post-metadata">

**Author:** ![deadrailtrains](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deadrailtrains/32/1282036_2.png) [@deadrailtrains](https://forum.arduino.cc/u/deadrailtrains)\
**Post date:** [September 2, 2026, 1:13pm UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/12 "2026-09-02T13:13:08Z")

</div>

That is why I posted. My ESP32 does not automatically connect to the phone. And I don't have any code to do it.  
Peter

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [September 3, 2026, 8:11am UTC](https://forum.arduino.cc/t/esp32-auto-bluetooth-connect/1457318/13 "2026-09-03T08:11:36Z")

</div>

And what research have you done so far ? Do you have a code with which you can manually connect to your phone, because this is the first step.
