🛠 Premier attachement au réseau cellulaire
Objectives
Register the u-blox SARA-R410M-02B cellular module (LTE-M Cat-M1, NB-IoT Cat-NB1/NB2, EGPRS fallback) on the operator's network, then activate the packet data context (PDP). This is the step that triggers 90% of failures: active data SIM, operator coverage, supported band (2/3/4/5/8/12/13/20/28), and correct APN.
Hardware
- 1 MKR NB 1500 board with the antenna connected before powering on
- 1 data SIM card
- Active cellular plan with data enabled (SMS/voice-only plans do not attach on NB-IoT)
- Arduino IDE + MKRNB library (v1.6.0) or MKRGSM
Full Code
// Attachement reseau NB-IoT/LTE-M — MKR NB 1500 (lib MKRNB)
#include <MKRNB.h>
#include "arduino_secrets.h" // #define SECRET_PINNUMBER ""
const char PINNUMBER[] = SECRET_PINNUMBER;
// APN de votre operateur, ex. "orange" , "orange_m2m", "iot.1nce.net"...
const char APN[] = "orange";
NB nbAccess;
GPRS gprs;
void setup {
Serial.begin(9600);
while (!Serial);
bool connected = false;
while (!connected) {
// L'enregistrement NB-IoT peut durer plusieurs minutes : patience !
if ((nbAccess.begin(PINNUMBER) == NB_READY) &&
(gprs.attachGPRS(APN) == GPRS_READY)) {
connected = true;
} else {
Serial.println("Non connecte, nouvelle tentative...");
delay(2000);
}
}
Serial.println("Enregistre sur le reseau, contexte PDP actif.");
}
void loop {}
Expected Verification
After a few seconds to a few minutes, the console displays "Registered on network, PDP context active". The module selects the technology (NB-IoT or LTE-M) based on the network and plan; recent versions allow forcing the choice (RAT) via the MKRNB library.
Common Errors
- Antenna forgotten: without it, the module searches indefinitely and may overheat; connect it before powering on.
- SIM without a data subscription, PIN not entered, or SIM blocked after too many attempts.
- APN missing or incorrect:
attachGPRSwithout an APN is not suitable for all IoT operators. - Uncovered area: NB-IoT/LTE-M coverage is very uneven depending on the country and operator — check your operator's coverage map before concluding the board is dead.
- 2G/EGPRS fallback becomes useless: more and more operators are shutting down 2G.
Other tutorials for this board
Code examples for this board
attente-lte-nbiot.inoArduinochoix-bande.inoArduinopublish-mqtt-minimal.inoArduinoeconomie-energie.inoArduinogeoloc-cellules.inoArduinotest-coverage.inoArduino