Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: vietbac on Mar 09, 2020, 05:17 am

Title: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: vietbac on Mar 09, 2020, 05:17 am
Hi all,
I used the SIM7600CE and Arduino mega to send, receive message to MQTT.
My process to start MQTT in setup as
1. AT+CMQTTSTART
2. AT+CMQTTACCQ=0,"SIM7600_client"
3. AT+CMQTTCONNECT=0,\"tcp://tailor.cloudmqtt.com:11831\",90,1,\"xxxxxx\",\"yyyyyyyyy\""
4. AT+CMQTTSUBTOPIC
5. subscribe name
6. AT+CMQTTSUB

After that on loop, I send message to broker as process like this
1. AT+CMQTTTOPIC
2. Publish name
3. AT+CMQTTPAYLOAD
4. message
5. AT+CMQTTPUB

my problem is just broker can receive the first time.
if send more, SIM7600 return error 14, mean client busy, and after that return error 11, mean disconnect

Any people can help explain this problem ??

Thanks.
VB
Title: Re: why SIM7600 MQTT disconnect ?
Post by: pylon on Mar 09, 2020, 07:40 pm
Post the responses you get from the SIM7600 to the above commands!
Title: Re: why SIM7600 MQTT disconnect ?
Post by: vietbac on Mar 11, 2020, 06:57 am
Hi pylon,

The SIM7600 return after send the AT+CMQTTCONNECT is

OK

+CMQTTCONNECT=0,6

I can't find any document talk about this error code.

Thanks.
VB
Title: Re: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: pylon on Mar 11, 2020, 07:35 pm
Quote
I can't find any document talk about this error code.
According to the manual (https://github.com/Strictus/DFRobot/raw/master/TEL0124/Document/AT%20Command/SIM7500_SIM7600%20Series_MQTT_ATC_V1.01.pdf):

Quote
6 - message receive fail.
Post your complete code and the complete output you get!

Did you try to disconnect (AT+CMQTTDISC) before you re-connect?
Title: Re: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: vietbac on Mar 13, 2020, 04:04 am
Hi pylon,

yes, I have disconnect before re-connect, and just after turn on power or reset (AT+CRESET), the module also return same.

this is function for start

void startMQTTServer(){
   Serial2.println("Start MQTT server to broker >>");
   Serial2.println("send AT+ATE0 >>");
   sim7600.sendATcommand("ATE0", "OK", 1000);
   printResponceSIM();
   Serial2.println("send AT+CMQTTSTART >>");
   strcpy_P(str_buffer, (char *)pgm_read_word(&(cmd_table[11])));    //start network        
   sim7600.sendATcommand(str_buffer, "+CMQTTSTART: 0", 2000);
   printResponceSIM();
//    sim7600.sendATcommand("AT+CMQTTACCQ=0,\"SIM7600_client\"", "OK", 2000);
   Serial2.println("send AT+CMQTTACCQ >>");
   strcpy_P(str_buffer, (char *)pgm_read_word(&(cmd_table[21])));    //issue name of client
   sim7600.sendATcommand(str_buffer, "OK", 2000);
   printResponceSIM();
   Serial2.println("send AT+CMQTTWILLTOPIC >>");
   sim7600.sendATcommand("AT+CMQTTWILLTOPIC=0,10", ">", 2000);
   printResponceSIM();
   Serial2.println("send will topic >>");
   sim7600.sendATcommand("will topic", "OK", 2000);
   printResponceSIM();

   Serial2.println("send AT+CMQTTWILLMSG >>");
   sim7600.sendATcommand("AT+CMQTTWILLMSG=0,56,1", ">", 2000);
   printResponceSIM();
   Serial2.println("send will topic message >>");
   sim7600.sendATcommand("you'd better set will topic before setting will message.", "OK", 2000);
   printResponceSIM();
 
//    sim7600.sendATcommand(AT+CMQTTCONNECT=0,\"tcp://tailor.cloudmqtt.com:11831\",600,1,\"xxxxxxxx\",\"xxxxxxxxxxxx\"", "OK", 2000);
   Serial2.println("send AT+CMQTTCONNECT >>");
   strcpy_P(str_buffer, (char *)pgm_read_word(&(cmd_table[20])));    //connect MQTT broker
   result = sim7600.sendATcommand(str_buffer, "+CMQTTCONNECT: 0,0", 180000);
   if(result){
       connectFlag=true;      //connect server OK
       Serial2.println("Connect OK !");
   }else Serial2.println("Connect NG !");
   
   printResponceSIM();


}

and this is return from SIM7600

Start MQTT server to broker >>
send AT+ATE0 >>

OK
send AT+CMQTTSTART >>

OK

+CMQTTSTART: 0
send AT+CMQTTACCQ >>

OK
send AT+CMQTTWILLTOPIC >>

>
send will topic >>

OK
send AT+CMQTTWILLMSG >>

>
send will topic message >>

OK
send AT+CMQTTCONNECT >>
Connect NG !

OK

+CMQTTCONNECT: 0,6

Start send SUBTOPIC to broker >>
send AT+CMQTTSUBTOPIC >>

+CMQTTSUBTOPIC: 0,11

ERROR
Title: Re: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: pylon on Mar 13, 2020, 05:46 pm
This is not your complete code and you also forgot the code tags!
Title: Re: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: meroata on Jun 09, 2020, 08:41 am
Can you please share the complete code because I need it
Title: Re: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: juhan5025 on Jun 20, 2020, 05:11 am
Hi, vietbac
did you resolve this?
I've been getting same issue,, so could you share how to fix this?

Title: Re: why SIM7600 MQTT return +CMQTTCONNECT: 0,6 ?
Post by: rykers on Aug 02, 2020, 07:18 am
Sorry for bumping an old thread here, but I believe I am having this same issue.

I have detailed my problem here: https://forum.arduino.cc/index.php?topic=697539.0

Have spent weeks trying to fix this, even contacted SIMCOM support and attempted to contact one of their engineers... No response.

Did you manage to solve this issue? If so please share you fix with us.