Hi,
Im starting with Narrow band. I want to use Arduino MKR NB 1500 and Hologram sim card to connect to Blynk platform, but the program is always getting stuck at [3113] Modem init…
I tried already different alterations of the code, but without success. Any ideas what could be wrong?
Im frustrated, I use the most basic example code and its not working. I cannot find any documentation on how exactly the code is executed. Im diving into the Blynk library and I see the program is getting stuck at the function “modem.begin(pin)”, more specifically at “NB_NetworkStatus_t NB::begin()” endlessly running “while (ready() == 0)” since the _timeout is set to 0 (I dont know why). When I change the timeout to, lets say 10000, I can an error “Cannot init”
Diving into the “ready()” function, I found out, the program is stuck at registering, as these two switch cases are being repeated endlessly:
READY_STATE_CHECK_REGISTRATION
READY_STATE_WAIT_CHECK_REGISTRATION_RESPONSE
#define BLYNK_PRINT Serial
/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "*****"
#define BLYNK_TEMPLATE_NAME "*****"
#define BLYNK_AUTH_TOKEN "*****"
#include <MKRNB.h>
#include <BlynkSimpleMKRNB.h>
// Your SIM and GPRS credentials
char pin[] = "";
char apn[] = "hologram"; // I also tried blynk.cloud
char user[] = "";
char pass[] = "";
NBClient client;
GPRS gprs;
NB nbAccess;
NBModem modem;
void setup()
{
// Debug console
Serial.begin(115200);
delay(3000);
Serial.println("hello");
// Initialize onboard LED pin
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // Start with LED off
Serial.println("Connecting to Blynk...");
Blynk.begin(BLYNK_AUTH_TOKEN, nbAccess, gprs, client, pin, apn);
Serial.println("Connected!");
}
// Function to control onboard LED from Blynk
BLYNK_WRITE(V1) {
int ledState = param.asInt(); // Read value from Blynk app (0 or 1)
digitalWrite(LED_BUILTIN, ledState);
Serial.print("LED State: ");
Serial.println(ledState);
}
void loop()
{
Blynk.run();
}
Hi PeterKnight and thanks for the answer!
well, that is one of the confusing parts for me. The example sketch has nothing, but pin to be filled out. I manually added APN, but am not sure if it should be hologram, blynk-cloud.com, blynk.cloud, fra1.blynk.com, … do I also need to place there my username and password and I have no idea what the port is for. Anyway, is it all necessary, if the example sketch is without it?
Is for credentials relating to your mobile ISP and any PIN number that you’ve created for your SIM card.
Nothing at all to do with Blynk or the Blynk servers.
You’ll need to read the Hologram documentation to see if any of these are mandatory or optional, and which credentials to supply if any are required.
If you want to specify the url of your local Blynk server (which may be desirable when using GPRS then you also need to specify the port, which will be 80 in this case.
Thanks for explaining!
all these settings are set correctly, including the port.
somehow I tried AT+CSQ command to check the signal quality and got response 99,99 which as I found means Not known or not detectable. Other commands I tried didnt work for me
Good idea, I tired Aruino example for testing AT commands and when I forced network operator selection, by writing “AT+COPS=1,2,“23101”,9” the device got successfully connected! (although I dont know why manual operator selection was necessary). After that I uploaded the sketch and Im connected to blynk platform
So, thanks Peter for the suggestion and quick replies!