ESP32 Arduino, BLE and mDash


Hi All,

I am using an Olimex ESP32 POE board and I can succesfully connect to mdash thru Ethernet or WiFi.
Problems start introducing BLE … seems mDash does not like it at all (or the reverse). Without mDash the sketch works, without BLE mDash works.

Initializing mDash before BLE does:

1970-01-01 00:00:02 init_wifi2: Connecting to WiFi network our-wlan...
1970-01-01 00:00:03 eh: WiFi connected, IP
1970-01-01 00:00:04 dopoll: Subscriptions changed, reconnecting...
1970-01-01 00:00:05 mdashconnect: reconnecting to @
Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.

Initializing BLE before mDash does:

1970-01-01 00:00:06 init_wifi2: Connecting to WiFi network our-wlan...
1970-01-01 00:00:07 eh: WiFi connected, IP
1970-01-01 00:00:08 dopoll: Subscriptions changed, reconnecting...
1970-01-01 00:00:09 mdashconnect: reconnecting to @
1970-01-01 00:00:09 tls_init: err 0xffff8100
1970-01-01 00:00:09 conn_handshake: err 0xffff8f00
1970-01-01 00:00:10 mdashconnect: reconnecting to @
1970-01-01 00:00:10 tls_init: err 0xffff8100
1970-01-01 00:00:10 conn_handshake: err 0xffff8f00
1970-01-01 00:00:11 mdashconnect: reconnecting to @

…and so on

Any Help ?

1 Like

Thanks. Same goes with Ethernet enabled and wifi disabled?


Hi @lsm ,

Exactly the same thing. Even trying with a “normal” ESP32 (no wired ethernet) shows same behaviour.


Thank you, looking at it.


We could not reproduce the crash.
What mDash library version you are using?

W.r.t. the failure: we can reproduce the connection failure.
The err 0xffff8100 corresponds to the mbedtls error MBEDTLS_ERR_SSL_ALLOC_FAILED - see ssl.h

Which is a low RAM condition - apparently BLE code is very RAM hungry, and does not leave much for the TLS handshake to happen.

You can use insecure MQTT instead of secure MQTTS, in which case the mDash connection happens successfully. Our assumption is such a problem exists for any TLS-enabled backend, not just mDash.

There are ways to reduce the RAM usage though, and make it work fine with TLS. The first step could be to try a native ESP-IDF example instead of Arduino - maybe Arduino libs add too much cruft.

Below is a snippet that shows how to switch to insecure port:

extern "C" void mDashSetServer(const char *, int);

void setup() {

  mDashSetServer("", 1883);

1 Like

You are right.
BLE and TLS have their (large) needs, therefore cutting encryption works.

BTW, mDash library is 1.0.26 (should be the latest).

Thank You !

1 Like

Same behaviour, also solved!
Changed the order and started BLE before mDash and switching to nonTLS

void setup() {


  //Starting BLE before mdash (
  Serial.println("BLE Service Starting");
  xTaskCreate(taskServer, "bleserver", 20000, NULL, 5, NULL);
  //Starting mDash
  mDashSetServer("", 1883);

Any progress on this limitation/bug?
Tried also without TLS…
Got the following error (Arduino):
‘mDashSetServer’ was not declared in this scope

Any help please?