I am a newbie with ESP32, but have worked a long time in deeply embedded firmware industry. I am trying to get Bluetooth to work on this "Wemos D1 R32" board I am using for one of my projects. My host is an Ubuntu 20.04 PC with Arduino 1.8.13 IDE and ESP32 environment sourced from https://dl.espressif.com/dl/package_esp32_index.json
I am able to compile / upload basic examples like toggling LED via a GPIO. So my basic setup is OK.
I tried out a basic Bluetooth example named "Serial2SerialBT" that turns ESP32 on this board into a bridge between USB serial & Bluetooth serial. When I run this, I can see the Bluetooth device from multiple android phones, and can reliably pair but within 3-4 seconds of pairing the device disconnects. I have tried this multiple times, using USB power for the board and also 12v 1.5Amp supply.
#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
Code: Select all
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(20);
}
Any help would be highly appreciated!
Thanks
Kedar