arduinomqttesp32hivemq

DEVIO-I ESP32 struck in loop and reboot again and again while communicating with MQTT Broker


I am using a DEVIO NB-DEVKIT I (support NB-IOT) to connect to the public broker of HiveMQ.

I am using the code provided by AIS(Telecom service in Thailand) Team.

I set the following settings in the Code:

String address    = "broker.hivemq.com";          //Your IPaddress or mqtt server url
String serverPort = "1883";               //Your server port
String clientID   = "mclient1";               //Your client id < 120 characters
String topic      = "my/test/topic";               //Your topic     < 128 characters
String payload    = "HelloWorld!";    //Your payload   < 500 characters
String username   = "";               //username for mqtt server, username <= 100 characters
String password   = "";               //password for mqtt server, password <= 100 characters

The ESP32 controller after establishing the connection restarts again and again and is struck in this loop.

The error message is shown below.

13:37:31.622 -> >>Signal : -63 dBm
13:37:31.807 -> >>Connecting ..............OK
13:37:41.735 -> >>APN   : DEVKIT.NB
13:37:41.735 -> ---------- Connected ----------
13:37:47.263 -> # ServerIP : broker.hivemq.com
13:37:47.263 -> # Port : 1883
13:37:47.263 -> # ClientID : mclient1
13:37:47.297 -> -------------------------------
13:37:47.297 -> # Subscribe 
13:37:47.297 -> # Topic : my/test/topic
13:37:47.297 -> Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
13:37:47.297 -> 
13:37:47.297 -> Core  1 register dump:
13:37:47.297 -> PC      : 0x400d43bc  PS      : 0x00060e30  A0      : 0x800d43b4  A1      : 0x3ffb2680  
13:37:47.297 -> A2      : 0x00000003  A3      : 0x3ffc27f0  A4      : 0x00000003  A5      : 0x00000001  
13:37:47.297 -> A6      : 0x00000000  A7      : 0x3f4006fd  A8      : 0x800d5056  A9      : 0x3ffb26a0  
13:37:47.330 -> A10     : 0x00000002  A11     : 0x00000000  A12     : 0x0000000a  A13     : 0x0000ff00  
13:37:47.330 -> A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x00000015  EXCCAUSE: 0x0000001c  
13:37:47.330 -> EXCVADDR: 0x00000087  LBEG    : 0x400862e1  LEND    : 0x400862f1  LCOUNT  : 0xffffffff  
13:37:47.330 -> 
13:37:47.330 -> 
13:37:47.330 -> Backtrace: 0x400d43b9:0x3ffb2680 0x400d43b1:0x3ffb26e0 0x400d2293:0x3ffb2700 0x400d1741:0x3ffb2740 0x400d181b:0x3ffb27c0 0x400d63d6:0x3ffb2820
13:37:47.370 -> 
13:37:47.370 -> 
13:37:47.370 -> 
13:37:47.370 -> 
13:37:47.370 -> ELF file SHA256: 632709499e5776f5
13:37:47.370 -> 
13:37:47.449 -> Rebooting...
13:37:47.449 -> ets Jun  8 2016 00:22:57
13:37:47.449 -> 
13:37:47.449 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
13:37:47.449 -> configsip: 0, SPIWP:0xee
13:37:47.449 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
13:37:47.449 -> mode:DIO, clock div:1
13:37:47.449 -> load:0x3fff0030,len:1344
13:37:47.449 -> load:0x40078000,len:13836
13:37:47.495 -> load:0x40080400,len:3608
13:37:47.495 -> entry 0x400805f0
13:37:47.573 -> >>Rebooting ...OK
13:37:50.599 -> >>Check module status ........OK

I tried subscribing and publishing using AT command using the hardware serial code and it's working fine, which indicates that there is some issue with the code provided by the company.

AT Serial Commands to subscribe and publish.

AT+CMQNEW="broker.hivemq.com","1883",12000,100
AT+CMQCON=0,3,“myclient”,600,0,0
AT+CMQSUB=0, “my/test/topic”,1  
AT+CMQPUB=0,"my/test/topic",1,0,0,24,"48656c6c6f202d204d515454"

How can I fix the code so it does not stuck in the reboot loop?

I have found the problem is similar to this stackoveflow problem, but i don't know where to start to fix in my code.


Solution

  • The library has some issues with ESP32 core 2.0+. So downgrading ESP32 Core to 1.0.6 solved the issue. Source: Github