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