I've already returned one MKR 1500 because it couldn't recognize my SIM, but the one I hold in my hands now is working fine.
I'm trying to connect to a NB-IoT Network via my 1NCE SimCard. However, when I'm trying the "NB Network Scanner" example, I can't establish a connection. I obtain the following output:
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","iot.1nce.net"
OK
AT+UAUTHREQ=1,0
OK
AT+CFUN=1
OK
AT+CGREG?
+CGREG: 0,4 // 4 tells me "unknown" error
I'm using a similar test snippet for my SIM7000E module and it's working just fine. Is there a specific AT command I forgot to call?
MPQ:
However, when I'm trying the "NB Network Scanner" example, I can't establish a connection.
Where did you find that example? The closest example sketch to that name in the MKRNB library is File > Examples > MKRNB > Tools > NBScanNetworks, but that would have different output.
Right, it's exactly that example. I slightly modified the code and changed CEREG to CGREG. Here is the result, when I run it using the original code:
NB IoT/LTE Cat M1 networks scanner
AT
OK
AT
OK
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","iot.1nce.net"
OK
AT+UAUTHREQ=1,0
OK
AT+CFUN=1
OK
AT+CEREG?
+CEREG: 0,0
Obviously, I'm stuck here in the ready() method of the NB class, as it is called over and over again until CEREG acknowledges a established connection.
Same problem when I use the "TestGPRS" example as it also tries to connect.
I just tried the "TestModem" example and could not get the IMEI. Using my own code works though, I can extract the IMEI using the respective command
I've encountered this issue and solved it that way:
Ensure you have a good antenna fot the band you are using.
Ensure there is a good coverage on your area. In my lab, which is off the floor, next to a window, I have troubles connecting. 10 meters away in another room on the other side of the building that is fine...
Not 100% sure of this, but having a good quality LiPo connected seems to help.
COPS you show returns mode 1, meaning it is in manual mode.
Try to force in automatic mode by issuing:
AT+COPS=0
If you want to do this while using the MKRNB library, do as follow by adapting your code:
MODEM.begin(true); // true to restart the modem
while (!MODEM.noop());
MODEM.sendf("AT+COPS=0");
MODEM.waitForResponse(2000);
if (nbAccess.begin(pin, false) == NB_READY) { // second arg is false so that we don't restart the modem and loose the automatic config we did before
// Whatever code you want here.
}
Concerning the coverage, changing antenna helped me a lot. Before, I was frequently loosing connection (when I was able to connect), and then with a proper antenna it was steady state.
What do you do before running the AT-commands? Have you tried the AT-passthrough code available and written the commands manually? There you can include a reset in the setup and also run modem.begin() which might make some difference:
I usually just run the passthrough code and write AT+CEREG? in the serial port. If you didnt find the passthrough code before:
#include <MKRNB.h>
NBModem modem;
// baud rate used for both Serial ports
unsigned long baud = 115200;
void setup() {
// reset the ublox module
pinMode(SARA_RESETN, OUTPUT);
digitalWrite(SARA_RESETN, HIGH);
delay(100);
digitalWrite(SARA_RESETN, LOW);
Serial.begin(baud);
while (!Serial) {
;
}
Serial.println("CPU connected to PC");
if (modem.begin()) {
Serial.println("Modem connected to CPU");
} else {
Serial.println("ERROR, no modem answer.");
}
SerialSARA.begin(baud);
}
void loop() {
if (Serial.available()) {
SerialSARA.write(Serial.read());
}
if (SerialSARA.available()) {
Serial.write(SerialSARA.read());
}
}
I also noticed that you are running on a battery. When trying to run on battery I need to call the NBClient to see if it is connected. I am very confused by what is making this difference. Is it working differently for you when powered through USB? Then this could be your issue.
Sorry, but I'm really lost with this project (NBSSLWebClient from arduino library). This are the prgram and the resulted code:
PROGRAM:
/*
SSL Web client
This sketch connects to a website using SSL through a MKR NB 1500 board. Specifically,
this example downloads the URL "https://www.arduino.cc/asciilogo.txt" and
prints it to the Serial monitor.
Circuit:
* MKR NB 1500 board
* Antenna
* SIM card with a data plan
created 8 Mar 2012
by Tom Igoe
*/
// 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;
const char APN[]= APNcode;
// initialize the library instance
NBSSLClient client;
GPRS gprs;
NB nbAccess=true;
// URL, path and port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/asciilogo.txt";
int port = 443; // port 443 is the default for HTTPS
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Starting Arduino web client.");
// connection state
boolean connected = false;
// After starting the modem with NB.begin()
// attach to the GPRS network with the APN, login and password
while (!connected) {
if ((nbAccess.begin(PINNUMBER,APN,true,true ) == NB_READY) &&
(gprs.attachGPRS() == GPRS_READY)) {
connected = true;
} else {
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, port)) {
Serial.println("connected");
// Make a HTTP request:
client.print("GET ");
client.print(path);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.available() && !client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for (;;)
;
}
}
SERIAL MONITOR:
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","internet4gd.gdsp"
OK
AT+UAUTHREQ=1,0
OK
AT+CFUN=1
OK
AT+CEREG?
+CEREG: 0,3
OK
Not connected
For those with the Arduino MKR NB 1500, I found that reception using a tmobile hotspot data only sim was terrible. I used a AT&T prepaid phone sim and immediately was able to get connection. Also check to see if your carrier supports the SARA-R410M module on the 1500. You can see that AT&T supports it here: Get Network Ready – AT&T IoT Devices