MKR NB 1500 Tests fails

Hi everyone,

I am starting to work with the MKR NB1500 with a 1NCE SIM. Before starting to implement my design, I've been trying some of the sketches from the MKRNB library, and I have found some fails when passing them.

First sketch, TestModem, works fine, with the following output:

>>Starting modem test...modem.begin() succeeded
>>Checking IMEI...Modem's IMEI: 352753090906429
>>Resetting modem...Modem is functioning properly

Second sketch, TestGPRS, gives the following:

>>Connecting NB IoT / LTE Cat M1 network...OK
>>Attaching to GPRS...
>>OK
>>If your carrier uses a proxy, enter it, if not press enter: (Press Enter)
>>Connecting and sending GET request to example.org...OK
>>Receiving response...
>>disconnecting.
>>Connecting NB IoT / LTE Cat M1 network...ERROR

It seems to connect ok to NB IoT and GPRS network, and even the connection to the "example.org" seems to be established, but it doesn't print what it contains, and then it desconnects.
Finally, it tries to start again the NB IoT network connection, but it appears the error message, and the execution got stuck here (I've tried several times this sketch, giving always the same result)

Third sketch, NBWebClient, also fails, at the same point than the previous one (it doesn't print the contains of "example-org"):

>>Starting Arduino web client.
>>connecting...
>>connected
>>disconnecting.

It is my first time working with this board, so any help would be really appreciated!

Thanks,

Dani

Use
NB nbAccess(true);
to debug. Then you can see all the AT commands sent to the modem and the returns.
The Ublox AT command manual can help you further. In general, you have to disconnect the board from the power supply to reset the modem. The reset sent to the cpu after uploading a sketch does not affect the modem because it has it's own cpu/os/memory (a whole independent computer).

Hi @intstarep ,

I've used the nbAccess(true) to debug and the resulted output was the following:

Connecting NB IoT / LTE Cat M1 network...AT

OK
AT+CMEE=0

OK
AT+CFUN=0

OK
AT+CPIN?

+CPIN: READY

OK
AT+CMGF=1

OK
AT+UDCONF=1,1

OK
AT+CTZU=1

OK
AT+CGDCONT=1,"IP",""

OK
AT+UAUTHREQ=1,0

OK
AT+CFUN=1

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,0

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CEREG?

+CEREG: 0,5

OK
OK
Attaching to GPRS...
AT+CGATT=1

OK
AT+CGACT?

+CGACT: 1,1

OK
OK
If your carrier uses a proxy, enter it, if not press enter: 
Connecting and sending GET request to example.org...AT+USOCR=6

+USOCR: 0

OK
AT+USOCO=0,"example.org",80,1

OK
AT+USOWR=0,4,"47455420"

ERROR
AT+USOWR=0,1,"2F"

ERROR
AT+USOWR=0,9,"20485454502F312E31"

ERROR
AT+USOWR=0,2,"0D0A"

ERROR
AT+USOWR=0,6,"486F73743A20"

ERROR
AT+USOWR=0,11,"6578616D706C652E6F7267"

ERROR
AT+USOWR=0,2,"0D0A"

ERROR
AT+USOWR=0,17,"436F6E6E656374696F6E3A20636C6F7365"

ERROR
AT+USOWR=0,2,"0D0A"

ERROR
AT+USOWR=0,2,"0D0A"

ERROR
OK
Receiving response...AT+USORD=0,512

ERROR
AT+USOCL=0

ERROR

disconnecting.
Connecting NB IoT / LTE Cat M1 network...AT+CPWROFF

OK

+UUSOCO: 0,100

+UUSOCL: 0
AT

OK

As you can see, the errors started with the "AT+USOWR" command, which is basically the write socket data command (looking into the Ublox AT command manual).
Also the read socket data command is not working (AT+USORD).

Any idea about why these 2 commands are not working? I've tried the sketch several times, disconnecting the board from the power supply, but I always obtain the same result.

Thanks,

Dani

Welcome to the MKR1500 club.. It fails when trying to write into the socket. All info you got to debug is ERROR. I lost 3 month with stuff like that. It's hard to debug. Check the docs from ublox. There is a command to read out the last socket error code. Check jbelding's code. Scream. Pray. Start all over again and again.

Thank you for your help @intstarep,

I'll check carefully all the ublox documentation, trying to solve the problem.

Dani

Some of the IDE examples sketch are being looked into at the moment, their libraries needs to be updated to match with the newer Ublox firmware for the board. This will take a little while to complete.

For using 1NCE SIM with the cloud/Web Editor, check Configure a device for a network that doesn't use all the parameters in IoT Cloud

You can check the board's Ublox firmware version following this guide: How to know your MKR NB 1500 SARA module version, version L0.05.11,A.02.16 is avialble via the Arduino Tech Support, you can contact via CONTACT US

Hi,

I found what's the problem with this and modified the code of the TestGPRS example to mimic the connection code in the SendSMS example.

The problem is that the start the NB module and attaching to GPRS were put in the loop command. So Arduino would connect to the NB network, attach itself to GPRS, do a GET for example.org and then try to connect again and hang-up indefinitely - because it WAS already connected.

So I just moved the whole connection code into the setup() function and voila - it works like a charm.

code attached.

/*

 This sketch tests the MKR NB 1500 board's ability to connect to a
 GPRS network. It asks for APN information through the
 serial monitor and tries to connect to example.org.

 Circuit:
 * MKR NB 1500 board
 * Antenna
 * SIM card with data plan

 Created 18 Jun 2012
 by David del Peral
 Modified by David Blazevic 21.03.2023. (moved NB and GRPS attachment code into setup())
*/

// libraries
#include <MKRNB.h>

#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// PIN Number
const char PINNUMBER[] = SECRET_PINNUMBER;

// initialize the library instance
NB nbAccess;      // NB access: include a 'true' parameter for debug enabled
GPRS gprsAccess;  // GPRS access
NBClient client;  // Client service for TCP connection

// messages for serial monitor response
String oktext = "OK";
String errortext = "ERROR";

// URL and path (for example: example.org)
char url[] = "example.org";
char urlproxy[] = "http://example.org";
char path[] = "/";

// variable to save obtained response
String response = "";

// use a proxy
boolean use_proxy = false;

void setup() {
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ;  // wait for serial port to connect. Needed for Leonardo only
  }

  // connection state
  bool connected = false;

  // Start NB module
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while (!connected) {
    if (nbAccess.begin(PINNUMBER) == NB_READY) {
      connected = true;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("NB initialized");

  // attach GPRS
  Serial.println("Attaching to GPRS...");
  if (gprsAccess.attachGPRS() != GPRS_READY) {
    Serial.println(errortext);
  } else {

    Serial.println(oktext);
  }
}

  void loop() {
    use_proxy = false;

    // read proxy introduced by user
    char proxy[100];
    Serial.print("If your carrier uses a proxy, enter it, if not press enter: ");
    readSerial(proxy);
    Serial.println(proxy);

    // if user introduced a proxy, asks them for proxy port
    int pport;
    if (proxy[0] != '\0') {
      // read proxy port introduced by user
      char proxyport[10];
      Serial.print("Enter the proxy port: ");
      readSerial(proxyport);
      // cast proxy port introduced to integer
      pport = (int)proxyport;
      use_proxy = true;
      Serial.println(proxyport);
    }

    // connection with example.org and realize HTTP request
    Serial.print("Connecting and sending GET request to example.org...");
    int res_connect;

    // if use a proxy, connect with it
    if (use_proxy) {
      res_connect = client.connect(proxy, pport);
    } else {
      res_connect = client.connect(url, 80);
    }

    if (res_connect) {
      // make a HTTP 1.0 GET request (client sends the request)
      client.print("GET ");

      // if using a proxy, the path is example.org URL
      if (use_proxy) {
        client.print(urlproxy);
      } else {
        client.print(path);
      }

      client.println(" HTTP/1.1");
      client.print("Host: ");
      client.println(url);
      client.println("Connection: close");
      client.println();
      Serial.println(oktext);
    } else {
      // if you didn't get a connection to the server
      Serial.println(errortext);
    }
    Serial.print("Receiving response...");

    boolean test = true;
    while (test) {
      // if there are incoming bytes available
      // from the server, read and check them
      if (client.available()) {
        char c = client.read();
        response += c;

        // cast response obtained from string to char array
        char responsechar[response.length() + 1];
        response.toCharArray(responsechar, response.length() + 1);

        // if response includes a "200 OK" substring
        if (strstr(responsechar, "200 OK") != NULL) {
          Serial.println(oktext);
          Serial.println("TEST COMPLETE!");
          test = false;
        }
      }

      // if the server's disconnected, stop the client:
      if (!client.connected()) {
        Serial.println();
        Serial.println("disconnecting.");
        client.stop();
        test = false;
      }
    }
  }


/*
  Read input serial
 */
int readSerial(char result[]) {
  int i = 0;
  while (1) {
    while (Serial.available() > 0) {
      char inChar = Serial.read();
      if (inChar == '\n') {
        result[i] = '\0';
        return 0;
      }
      if (inChar != '\r') {
        result[i] = inChar;
        i++;
      }
    }
  }
}

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