ESP32 Bluetooth Connection - Immediate Disconnect

I am working on this project:

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.

#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:

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

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