BLE and ESP32 dev environment



Hi Florian,

I’ll try it during weekend.



In the folder where you have downloaded the entire project look for OpenMQTTGateway.ino file and open it with Arduino IDE (now it should load all the files, OpenMQTTGateway should be first tab).
Then, search for “void loop” (anyway there is only a single instance in the file). After that just copy/paste the additional code (the extract should look as below).


void loop()

unsigned long now = millis();
  //MQTT client connexion management
  if (!client.connected()) { // not connected


Clear …thanks … Was not sure of the indent …dies it work for u?


No, still disconnects after 3-4 hours .


Thanks for the feedback, I engaged a discussion in the arduino esp32 repository


that’s strange… some users face it some not … it’s board related ?


It can, in my side the doit board never keep disconnected. Maybe it can be also related to the network configuration.


Another test for @thundergreen and @PetricaM if you would

Could you replace on ZgatewayBT line 49:
static int taskCore = 0;
static int taskCore = 1;


Testing now … Will report tomorrow :wink:


for the first time it seems running… i’ve it running for 16 hours … another 24 hours and we should be good i think


Hi Florian,

The ESP32 stopped working after about 5 hours, however I think we’re on the right track this time as the wireless router now shows that the board is trying to connect (and also sometimes it replies to ping commands) but after 5-10 seconds gets timed out.

I’ll look also into possible issues with the wireless router (I use a 63 char password for the wifi but I don’t think it would matter).

I tried to use the BLE gateway on Mega however, although there is no issue when compiling, none of the RX/TX pin combination works (5-6/18-19/0-1) and there is no reply from the HM-10 board (when connected to PC the board receives AT command replies from Flora).


did u apply all changes in the code?

in ZgatewayBT line 49:

`static int taskCore = 0;`
`static int taskCore = 1;`

and in OpenMQTTGateway.ino:


void loop()


unsigned long now = millis();
//MQTT client connexion management
if (!client.connected()) { // not connected

we all strictly need to test the same. Having the same codebase. If not debugging will be impossible :)


Yes (although initially I thought I should reverse the vTaskDelay modification).


serial debug output?


Haven’t done yet it as I connected the board to an USB charger not to the PC.

I did, however, mounted a USB power meter and the consumption even after the board disconnected was similar to the period it was working fine.

Seeing the wireless router log I think that now the issues are more from a wifi config perspective.


… and to exactly know what caused this disconnect… we would highly need a serial output :slight_smile: I also faced that on USB on my Laptop and Arduino Serial output it seemed more stable than on jzs a USB power plug… I use inwall UBS Sockets with 2.1 A by the way


Yes, I know about the problems of cheap power supplies (I use 8 OpenMQTT gateways around the house on ESP8266 and I had to place fairly good 5V adapters as otherwise the boards would reset).

Actually there is no need for a 2 A+ power supply as the board uses ways less than 1 A but it should be stable enough to drive that 1 A.


1 A is guaranteed so from this perspective there shouldn’t be a problem. I got issues above but surprisingly it now works with changed code. Could you please attach your ESP to serial and provide output as soon as it hangs?


Yes you should reverse it for your test


Hmm strange, I suppose with the latest version of OMG?