# ESP32 Bluetooth Connection - Immediate Disconnect

**URL:** <https://forum.arduino.cc/t/esp32-bluetooth-connection-immediate-disconnect/1276238>\
**Category:** Programming\
**Created:** [June 28, 2024, 12:46am UTC](https://forum.arduino.cc/t/esp32-bluetooth-connection-immediate-disconnect/1276238 "2024-06-28T00:46:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzimmer12](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tzimmer12](https://forum.arduino.cc/u/tzimmer12)\
**Post date:** [June 28, 2024, 12:46am UTC](https://forum.arduino.cc/t/esp32-bluetooth-connection-immediate-disconnect/1276238/1 "2024-06-28T00:46:37Z")

</div>

I am working on this project:

[![](https://europe1.discourse-cdn.com/arduino/original/4X/5/9/7/597cbfbbde1c0d0f771c3a93a0703a533c367180.jpeg "How to build cheap VR Haptic Gloves to FEEL VR.") ](https://www.youtube.com/watch?v=2yF-SJcg3zQ&t=449s)

The device is fully built, however I cannot get my ESP32 to maintain a bluetooth connection.

To simplify things for testing I had ChatGPT write this code for just connecting to Bluetooth.

```arduino
#include "BluetoothSerial.h"

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200); // Start the hardware serial port
  SerialBT.begin("ESP32_Test"); // Start the Bluetooth Serial with a device name
  Serial.println("The device started, now you can pair it with Bluetooth!");
}

void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read()); // Read from hardware serial and write to Bluetooth serial
  }
  if (SerialBT.available()) {
    Serial.write(SerialBT.read()); // Read from Bluetooth serial and write to hardware serial
  }
  delay(20); // Small delay to prevent overwhelming the serial buffers
}

```

When I search for the device, it appears in the list, and connects just fine. However about 5 seconds after connecting it disconnects. I have tried multiple ESP32 boards, multiple computers, and various versions of the libraries.

This is the current board I am using:

> **[Amazon.com: AITRIP 3PCS Type c 30pins CP2102 ESP-WROOM-32 ESP32 ESP-32S...](https://www.amazon.com/AITRIP-ESP-WROOM-32-Development-Microcontroller-Integrated/dp/B0CR5Y2JVD)**
>
> AITRIP 3PCS ESP32 ESP-WROOM-32 CP2012 USB C 30 Pin WiFi+Bluetooth Dual Core Type-C Interface ESP32-DevKitC-32 Development Board Module STA/AP/STA+APFeatures：ESP32 CP2012 USB C (Type-C) core board, it has 30 pins，One USB C (Type-C) interface (built-in...

Arduino IDE 2.3.2, ESP32 by Espressif Systems Board library.

I have also tried alternate power supplies, cables, etc. No luck. My son and I are at a loss. Help!

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 25, 2024, 12:47am UTC](https://forum.arduino.cc/t/esp32-bluetooth-connection-immediate-disconnect/1276238/2 "2024-12-25T00:47:14Z")

</div>

Closed on December 25, 2024, 12:47am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
