Sim7600g-h mqtt at+cmqttconnect error

I have SIM7600G-H.

The code I was using worked fine, until 2 days ago.

What I use is a C++ code to answer AT commands.

AT COMMAND PROGRAM: (Works fine!)

#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 30          /* Time ESP32 will go to sleep (in seconds) */

#define UART_BAUD 115200

#define MODEM_TX 27
#define MODEM_RX 26
#define MODEM_PWRKEY 4
#define MODEM_DTR 32
#define MODEM_RI 33
#define MODEM_FLIGHT 25
#define MODEM_STATUS 34

#define SD_MISO 2
#define SD_MOSI 15
#define SD_SCLK 14
#define SD_CS 13

#define LED_PIN 12

#define TINY_GSM_MODEM_SIM7600
#define TINY_GSM_RX_BUFFER 1024  // Set RX buffer to 1Kb
#define SerialAT Serial1

// See all AT commands, if wanted
#define DUMP_AT_COMMANDS

// set GSM PIN, if any
#define GSM_PIN ""

// Your GPRS credentials, if any
const char apn[] = "wap.tmovil.cl";  //SET TO YOUR APN
const char gprsUser[] = "wap";
const char gprsPass[] = "wap";

#include <TinyGsmClient.h>
#include <SPI.h>
#include <SD.h>
#include <Ticker.h>

#ifdef DUMP_AT_COMMANDS  // if enabled it requires the streamDebugger lib
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, Serial);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif


int counter, lastIndex, numberOfPieces = 24;
String pieces[24], input;


bool reply = false;

void modem_on() {
  // The indicator light of the board can be controlled
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);

  /*
    MODEM_PWRKEY IO:4 The power-on signal of the modulator must be given to it,
    otherwise the modulator will not reply when the command is sent
  */
  pinMode(MODEM_PWRKEY, OUTPUT);
  digitalWrite(MODEM_PWRKEY, HIGH);
  delay(300);  //Need delay
  digitalWrite(MODEM_PWRKEY, LOW);

  /*
    MODEM_FLIGHT IO:25 Modulator flight mode control,
    need to enable modulator, this pin must be set to high
  */
  delay(1000);  //Need delay
  pinMode(MODEM_FLIGHT, OUTPUT);
  digitalWrite(MODEM_FLIGHT, HIGH);


  int i = 10;
  Serial.println("\nTesting Modem Response...\n");
  Serial.println("****");
  while (i) {
    SerialAT.println("AT");
    delay(500);
    if (SerialAT.available()) {
      String r = SerialAT.readString();
      Serial.println(r);
      if (r.indexOf("OK") >= 0) {
        reply = true;
        break;
        ;
      }
    }
    delay(500);
    i--;
  }
  Serial.println("****\n");
}

void setup() {
  Serial.begin(115200);  // Set console baud rate
  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
  delay(100);

  modem_on();
  if (reply) {
    Serial.println(F("***********************************************************"));
    Serial.println(F(" You can now send AT commands"));
    Serial.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
    Serial.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
    Serial.println(F(" DISCLAIMER: Entering AT commands without knowing what they do"));
    Serial.println(F(" can have undesired consiquinces..."));
    Serial.println(F("***********************************************************\n"));
  } else {
    Serial.println(F("***********************************************************"));
    Serial.println(F(" Failed to connect to the modem! Check the baud and try again."));
    Serial.println(F("***********************************************************\n"));
  }
}

void loop() {
  while (true) {
    if (SerialAT.available()) {
      Serial.write(SerialAT.read());
    }
    if (Serial.available()) {
      SerialAT.write(Serial.read());
    }
    delay(1);
  }
}

In the console I write the AT Commands in the following sequence:

AT+CGDCONT=1,"IP","wap.tmovil.cl" //APN

AT+CGAUTH=1,1,"wap","wap" //Usuario y Pass de la APN

AT+CSSLCFG="sslversion",0,4 //Configurar ssl version 4, para TSL1.2

AT+CSSLCFG="authmode",0,2 //Configurar authmode 2 automatic.

AT+CSSLCFG="ignorelocaltime",0,1 //Configuramos para que ignore zona horaria

AT+CSSLCFG="cacert",0,"cacert.pem" //Cargar el primer certificado.

AT+CSSLCFG="clientcert",0,"clientcert.pem" //Cargar el segundo certificado.

AT+CSSLCFG="clientkey",0,"clientkey.pem" //Cargar el tercer certificado.

AT+CSSLCFG? //Verificamos si estan los 3 certificados cargados

AT+CMQTTSTART //Encendemos el MQTT

AT+CMQTTACCQ=0,"SIMCom_client01",1 //Elegimos cualquier nombre.

AT+CMQTTSSLCFG=0,0 //Configuramos el MQTT SSL

AT+CMQTTWILLTOPIC=0,9 //Insertamos el tópico. (con esto podemos mandarle mensajes publish desde AWS al dispositivo.)

>esp32/sub

AT+CMQTTWILLMSG=0,17,1 //Escribimos el mensaje que recibirá el tópico cuando se conecte.

>SIMCom Connected!

AT+CMQTTCONNECT=0,"tcp://a3kl3w0pwjown7-ats.iot.us-east-1.amazonaws.com:8883",60,1 //Nos conectamos a AWS endpoint.

In this last AT command I get the following error: (after 60 seconds)

+CMQTTCONNECT: 0,32

what it should give me is:

+CMQTTCONNECT: 0,0

It should be noted that all of the above AT commands are responding OK, including AT+CMQTTCONNECT, but this should response me 0,0.

This is my configuration of modem:

(AT+CGMR)
+CGMR: LE20B03SIM7600M22

(ATI)
Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM7600G-H
Revision: SIM7600M22_V2.0.1
SVN: 01
IMEI: 868822042462588
+GCAP: +CGSM

As I said, everything was working fine, but from one day to the next it failed.

Help me!

1 Like

even i do have this issue (+CMQTTCONNECT: 0,32) error
please provide solution for this issue

1 Like

I found the solution to the problem. All we had to do was change the SIM card provider because it was cancelled.

1 Like

thanks for ur reply dude

+CMQTTCONNECT: 0,34 Getting this error , Please suggest the solution .

Getting this error , Please suggest the solution . +CMQTTCONNECT: 0,34

Did you manage to resolve the issue with error code 34?

I am trying to get MQTT working on an A7682E module and cannot get it working properly.
It fails connecting to AWS with response "+CMQTTCONNECT: 0,34".

Connections without SSL/TLS seems fine though. Certificates are downloaded and configured for the connection.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.