Smart Home Automation Forum
Issue with GSM Pin Connect - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A2 (https://www.kincony.com/forum/forumdisplay.php?fid=43)
+--- Thread: Issue with GSM Pin Connect (/showthread.php?tid=3534)



Issue with GSM Pin Connect - airantoujc - 11-15-2023

Board is powered.
SIM7600E-L1C breakout is powered.

Link to board image:
https://imgur.com/a/sKNGmZm

Issue:
PIN TX RX definition cannot be swapped.

Situation 1: TX is 13, RX is 34 = Programs but no GSM connection can be made, no data can be requested from the SIM7600E-L1C.

Situation 2: TX is 34, RX is 13 = Backtrace Error logs.

Link to errors: 
https://imgur.com/a/D2MaYXh


RE: Issue with GSM Pin Connect - admin - 11-15-2023

whether your A2 PCB is v1.4? photo not clearly.


RE: Issue with GSM Pin Connect - airantoujc - 11-15-2023

(11-15-2023, 02:04 AM)admin Wrote: whether your A2 PCB is v1.4? photo not clearly.

A2 PCB is V2

(11-15-2023, 02:06 AM)airantoujc Wrote:
(11-15-2023, 02:04 AM)admin Wrote: whether your A2 PCB is v1.4? photo not clearly.

A2 PCB is V2

See this img instead, thank you        


RE: Issue with GSM Pin Connect - admin - 11-15-2023

ardunio board chose "NodeMcu-32S".


RE: Issue with GSM Pin Connect - airantoujc - 11-15-2023

(11-15-2023, 02:23 AM)admin Wrote: ardunio board chose "NodeMcu-32S".

still same issue with node32s board pick

still cannot switch pin define without backtrace error, changed hardware cpp pin define also doesn't work.

can i also check what is the power pin for the GSM ?


RE: Issue with GSM Pin Connect - airantoujc - 11-16-2023

Arduino settings below and hardware serial cpp changes attached

#define TX2 13
#define RX2 34


void modemHandler() {
  String res;
  SerialMon.println("========INIT========");

  modem.init();


  SerialMon.println("========SIMCOMATI======");
  modem.sendAT("+SIMCOMATI");
  modem.waitResponse(1000L, res);
  res.replace(GSM_NL "OK" GSM_NL, "");
  SerialMon.println(res);
  res = "";
  SerialMon.println("=======================");
  SerialMon.println("=====Preferred mode selection=====");
  modem.sendAT("+CNMP?");
  if (modem.waitResponse(1000L, res) == 1) {
    res.replace(GSM_NL "OK" GSM_NL, "");
    SerialMon.println(res);
  }
  res = "";
  SerialMon.println("=======================");
  SerialMon.println("=====Preferred selection between CAT-M and NB-IoT=====");
  modem.sendAT("+CMNB?");
  if (modem.waitResponse(1000L, res) == 1) {
    res.replace(GSM_NL "OK" GSM_NL, "");
    SerialMon.println(res);
  }
  res = "";
  SerialMon.println("=======================");
  String name = modem.getModemName();
  SerialMon.println("Modem Name: " + name);
  String modemInfo = modem.getModemInfo();
  SerialMon.println("Modem Info: " + modemInfo);
  for (int i = 0; i <= 4; i++) {
    uint8_t network[] = {
      2,  /*Automatic*/
      13, /*GSM only*/
      38, /*LTE only*/
      51  /*GSM and LTE only*/
    };
    SerialMon.printf("Try %d method\n", network[i]);
    modem.setNetworkMode(network[i]);
    delay(1000);
    bool isConnected = false;
    int tryCount = 60;
    while (tryCount--) {
      int16_t signal = modem.getSignalQuality();
      SerialMon.print("Signal: ");
      SerialMon.print(signal);
      SerialMon.print(" ");
      SerialMon.print("isNetworkConnected: ");
      isConnected = modem.isNetworkConnected();
      SerialMon.println(isConnected ? "CONNECT" : "NO CONNECT");
      if (isConnected) {
        break;
      }
      delay(500);
      digitalWrite(LED_PIN, !digitalRead(LED_PIN));
    }
  }
}


void setup() {
  // Set console baud rate
  SerialMon.begin(38400);
  delay(1000);
  pinMode(LED_PIN, OUTPUT);
  //modemPowerOn();
  SerialMon.println("Wait...");
  // Set GSM module baud rate
  SerialAT.begin(UART_BAUD, SERIAL_8N1, RX2, TX2);
  delay(3000);

  SerialMon.println("Initializing modem...");
  modemHandler();
  digitalWrite(LED_PIN, LOW);
  String modemInfo = modem.getModemInfo();
  SerialMon.print("Modem Info: ");
  SerialMon.println(modemInfo);
#if TINY_GSM_USE_GPRS
  // Unlock your SIM card with a PIN if needed
  if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); }
#endif
#if TINY_GSM_USE_WIFI
  // Wifi connection parameters must be set before waiting for the network
  SerialMon.print(F("Setting SSID/password..."));
  if (!modem.networkConnect(wifiSSID, wifiPass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");
#endif
#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE
  // The XBee must run the gprsConnect function BEFORE waiting for network!
  modem.gprsConnect(apn, gprsUser, gprsPass);
#endif
  SerialMon.print("Waiting for network...");
  if (!modem.waitForNetwork()) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");
  if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); }
#if TINY_GSM_USE_GPRS
  // GPRS connection parameters are usually set after network registration
  SerialMon.print(F("Connecting to "));
  SerialMon.print(apn);
  if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");
  if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); }
#endif
}
void loop() {
  // Make sure we're still registered on the network
  if (!modem.isNetworkConnected()) {
    SerialMon.println("Network disconnected");
    if (!modem.waitForNetwork(180000L, true)) {
      SerialMon.println(" fail");
      delay(10000);
      return;
    }
    if (modem.isNetworkConnected()) {
      SerialMon.println("Network re-connected");
    }
#if TINY_GSM_USE_GPRS
    // and make sure GPRS/EPS is still connected
    if (!modem.isGprsConnected()) {
      SerialMon.println("GPRS disconnected!");
      SerialMon.print(F("Connecting to "));
      SerialMon.print(apn);
      if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
        SerialMon.println(" fail");
        delay(10000);
        return;
      }
      if (modem.isGprsConnected()) { SerialMon.println("GPRS reconnected"); }
    }
#endif
  }
}

#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS
#undef TINY_GSM_USE_GPRS
#undef TINY_GSM_USE_WIFI
#define TINY_GSM_USE_GPRS false
#define TINY_GSM_USE_WIFI true
#endif
#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI
#undef TINY_GSM_USE_GPRS
#undef TINY_GSM_USE_WIFI
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
#endif

my ifdef is using GSM GPRS


RE: Issue with GSM Pin Connect - KinCony Support - 11-16-2023

(11-16-2023, 02:01 AM)airantoujc Wrote: Arduino settings below and hardware serial cpp changes attached

#define TX2 13
#define RX2 34


void modemHandler() {
  String res;
  SerialMon.println("========INIT========");

  modem.init();


  SerialMon.println("========SIMCOMATI======");
  modem.sendAT("+SIMCOMATI");
  modem.waitResponse(1000L, res);
  res.replace(GSM_NL "OK" GSM_NL, "");
  SerialMon.println(res);
  res = "";
  SerialMon.println("=======================");
  SerialMon.println("=====Preferred mode selection=====");
  modem.sendAT("+CNMP?");
  if (modem.waitResponse(1000L, res) == 1) {
    res.replace(GSM_NL "OK" GSM_NL, "");
    SerialMon.println(res);
  }
  res = "";
  SerialMon.println("=======================");
  SerialMon.println("=====Preferred selection between CAT-M and NB-IoT=====");
  modem.sendAT("+CMNB?");
  if (modem.waitResponse(1000L, res) == 1) {
    res.replace(GSM_NL "OK" GSM_NL, "");
    SerialMon.println(res);
  }
  res = "";
  SerialMon.println("=======================");
  String name = modem.getModemName();
  SerialMon.println("Modem Name: " + name);
  String modemInfo = modem.getModemInfo();
  SerialMon.println("Modem Info: " + modemInfo);
  for (int i = 0; i <= 4; i++) {
    uint8_t network[] = {
      2,  /*Automatic*/
      13, /*GSM only*/
      38, /*LTE only*/
      51  /*GSM and LTE only*/
    };
    SerialMon.printf("Try %d method\n", network[i]);
    modem.setNetworkMode(network[i]);
    delay(1000);
    bool isConnected = false;
    int tryCount = 60;
    while (tryCount--) {
      int16_t signal = modem.getSignalQuality();
      SerialMon.print("Signal: ");
      SerialMon.print(signal);
      SerialMon.print(" ");
      SerialMon.print("isNetworkConnected: ");
      isConnected = modem.isNetworkConnected();
      SerialMon.println(isConnected ? "CONNECT" : "NO CONNECT");
      if (isConnected) {
        break;
      }
      delay(500);
      digitalWrite(LED_PIN, !digitalRead(LED_PIN));
    }
  }
}


void setup() {
  // Set console baud rate
  SerialMon.begin(38400);
  delay(1000);
  pinMode(LED_PIN, OUTPUT);
  //modemPowerOn();
  SerialMon.println("Wait...");
  // Set GSM module baud rate
  SerialAT.begin(UART_BAUD, SERIAL_8N1, RX2, TX2);
  delay(3000);

  SerialMon.println("Initializing modem...");
  modemHandler();
  digitalWrite(LED_PIN, LOW);
  String modemInfo = modem.getModemInfo();
  SerialMon.print("Modem Info: ");
  SerialMon.println(modemInfo);
#if TINY_GSM_USE_GPRS
  // Unlock your SIM card with a PIN if needed
  if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); }
#endif
#if TINY_GSM_USE_WIFI
  // Wifi connection parameters must be set before waiting for the network
  SerialMon.print(F("Setting SSID/password..."));
  if (!modem.networkConnect(wifiSSID, wifiPass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");
#endif
#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE
  // The XBee must run the gprsConnect function BEFORE waiting for network!
  modem.gprsConnect(apn, gprsUser, gprsPass);
#endif
  SerialMon.print("Waiting for network...");
  if (!modem.waitForNetwork()) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");
  if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); }
#if TINY_GSM_USE_GPRS
  // GPRS connection parameters are usually set after network registration
  SerialMon.print(F("Connecting to "));
  SerialMon.print(apn);
  if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");
  if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); }
#endif
}
void loop() {
  // Make sure we're still registered on the network
  if (!modem.isNetworkConnected()) {
    SerialMon.println("Network disconnected");
    if (!modem.waitForNetwork(180000L, true)) {
      SerialMon.println(" fail");
      delay(10000);
      return;
    }
    if (modem.isNetworkConnected()) {
      SerialMon.println("Network re-connected");
    }
#if TINY_GSM_USE_GPRS
    // and make sure GPRS/EPS is still connected
    if (!modem.isGprsConnected()) {
      SerialMon.println("GPRS disconnected!");
      SerialMon.print(F("Connecting to "));
      SerialMon.print(apn);
      if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
        SerialMon.println(" fail");
        delay(10000);
        return;
      }
      if (modem.isGprsConnected()) { SerialMon.println("GPRS reconnected"); }
    }
#endif
  }
}

#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS
#undef TINY_GSM_USE_GPRS
#undef TINY_GSM_USE_WIFI
#define TINY_GSM_USE_GPRS false
#define TINY_GSM_USE_WIFI true
#endif
#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI
#undef TINY_GSM_USE_GPRS
#undef TINY_GSM_USE_WIFI
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
#endif

my ifdef is using GSM GPRS
https://www.kincony.com/forum/showthread.php?tid=3330   
download  KCS firmware  and test the 4G module.