Wemos D1 R32 Bluetooth issues

kpatankar7
Posts: 1
Joined: Fri Nov 27, 2020 4:11 am

Wemos D1 R32 Bluetooth issues

Postby kpatankar7 » Fri Nov 27, 2020 4:21 am

Hi,

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);
}
I have tried this with two different Wemos D1 R32 boards and both show similar behavior.

Any help would be highly appreciated!


Thanks
Kedar

abel-lisco
Posts: 6
Joined: Tue Dec 22, 2020 6:37 pm

Re: Wemos D1 R32 Bluetooth issues

Postby abel-lisco » Tue Mar 02, 2021 6:56 am

Hi,
I've been running into the same type of issues with these boards (I tried with 2 of them), using Arduino 1.8.13 and Ubuntu.
I compiled and downloaded the 3 BluetoothSerial sketch examples, and none of them worked with them.
I have been developing with these boards for quite a long time, using many different APIs, and they worked fine.
But with Bluetooth there seems to be no way...

This is the output from the Exception Decoder:
E (21036) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (21036) task_wdt: - IDLE0 (CPU 0)
E (21036) task_wdt: Tasks currently running:
E (21036) task_wdt: CPU 0: btController
E (21036) task_wdt: CPU 1: loopTask
E (21036) task_wdt: Aborting.
abort() was called at PC 0x400d4afb on core 0

Backtrace: 0x4009194c:0x3ffbe320 0x40091b7d:0x3ffbe340 0x400d4afb:0x3ffbe360 0x400847b9:0x3ffbe380 0x4003c9fd:0x3ffccc80 0x4005516e:0x3ffccca0 0x4016ebd6:0x3ffcccc0 0x40162953:0x3ffccd00 0x40162e34:0x3ffccd20 0x4008e0bd:0x3ffccd50

Decoding stack results
0x4009194c: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155
0x40091b7d: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170
0x400d4afb: task_wdt_isr at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/task_wdt.c line 174
0x4008e0bd: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

It looks like the btcontroller locks or enter in a loop.

I tried with another development kit (Heltec), and all the sketches run fine...

I just tried SerialBluetooth, neither wifi nor BLE (to check if the problem is with the radio...).

Interesting to note that these boards are not advertised in Wemos web pages. When I bought them they were advertised as "Wemos TTGO".
I do not expect to invest more time on them, it is much cheaper to switch supplier.

abel-lisco
Posts: 6
Joined: Tue Dec 22, 2020 6:37 pm

Re: Wemos D1 R32 Bluetooth issues

Postby abel-lisco » Wed Mar 03, 2021 9:26 pm

Hi,
I just want to share with you that I could solve the issue I had with my boards.
It looks the problem is not with the boards themselves (or faulty SoCs...), it "seems" to be related to NVS.
in the spp_acceptor_demo (one of BT ESP-IDF examples), I've found something that looks like a dependency between BT and NVS (I actually should read the documentation more in depth to be sure... and keep learning...).
I adapted the piece of code to Arduino, that you may include in your sketch, if you want to try:
#include "nvs.h"
#include "nvs_flash.h"

in void setup() include
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
Serial.println(esp_err_to_name(ret));
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
Serial.println(esp_err_to_name(ret));
}
ESP_ERROR_CHECK( ret );
Serial.println(esp_err_to_name(ret));

hope this works for you.

Who is online

Users browsing this forum: DonEvans and 41 guests