ESP32 Bluetooth only work with usb cable

Hello, my ESP32-WROOM-32U-DEVKIT connects to bluetooth only when I have the usb cable connected to the board.

When I disconnect the cable, and connect the board to the 5v power supply, it never connects to bluetooth, it shows on the cell phone, connection error.

My code

#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
#endif

BluetoothSerial SerialBT;

int pinOut = 12;
int maleta = 23;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32test"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
  pinMode(pinOut, OUTPUT);
}

void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read());
  }

  
  if (SerialBT.available())
  {
    char data = ((byte) SerialBT.read());
    switch (data)
    {
      case 'P':
        digitalWrite (pinOut, HIGH);
        //Hacemos un delay de 1 segundo
        delay (800);
        digitalWrite (pinOut, LOW);
        break;

      case 'b':
        digitalWrite(maleta, HIGH);
        delay(800);
        digitalWrite(maleta, LOW);
        break;
      default : break;
    }
    Serial.println(data);
  }
  delay(20);
}

Diagram

Arduino board selected

Most likely your 5v power supply is inadequate. The ESP32 can draw a lot of current when using radio (Wifi/Bluetooth).

Also possible that you need some capacitors close to the ESP, or the breadboard itself is causing issues.

Are you getting brownout messages?

I have tried with two different sources, configured at 5v.

  1. LM2596 - DC-DC HW-411 3A
  2. the XL4005 DC-DC 5A

And with none it connects, so what source should I use for the ESP32?

Are you getting brownout messages?

I am new with ESP32, I have only connected it as it is in the diagram, with the cable connected to the board and to the laptop, the bluetooth works, but I disconnect it, and use the power supply, and it never connects, it just says: error connection, is the only message

Hi, i fix this error, change to the GND position

Thanks for the update. I have also had issues in the past with some ESP modules, and the use of different GND pins. Would be interesting to see the schematic of that board.

1 Like

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