🛠 Premier attachement au réseau cellulaire

Arduino MKR NB 1500 · intermediaire · Schéma : IMG-mkr-nb-1500-intermediaire-1-mkrnb-attachement-reseau.svg — MKR NB 1500 avec antenne vissée sur son connecteur, carte nano-SIM insérée, et antenne relais NB-IoT/LTE-M à l'arrière-plan avec les bandes B3/B20

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials