Try Embedded

Cellular IoT: NB-IoT and LTE-M

The two LPWA standards, PSM, eDRX and AT commands.

Cellular built for things

Standard LTE is designed for phones: high data rates, constant reachability, recharged daily. Two LTE variants from 3GPP Release 13 target devices instead: low data, years on a battery, deep indoor coverage and cheap modules. Together they are called LPWA (low-power wide-area) cellular, and they run on operators' existing networks.

NB-IoT versus LTE-M

NB-IoT (Cat NB1/NB2)LTE-M (Cat M1)
Bandwidth180 kHz1.4 MHz
Peak rate~60 kbit/s down, ~150 kbit/s up (NB2)~1 Mbit/s
LatencySeconds10 to 15 ms
MobilityLimited: no seamless handover (re-attach)Full handover: works in vehicles
VoiceNoVoLTE possible
Coverage enhancementUp to +20 dB over LTE (deep indoor, basements)Up to +15 dB
Typical usesStatic meters, sensors, parking, smoke alarmsTrackers, wearables, alarms, POS terminals
TransportUDP preferred (and Non-IP)TCP and UDP

Availability differs by country and operator; many modules support both and fall back between them, often with 2G as well. Check the target markets' networks, bands and roaming agreements before choosing.

Saving power: PSM and eDRX

A cellular device's biggest energy cost is staying reachable. Two features let it sleep while remaining registered on the network, so it does not pay the expensive attach procedure each time:

PSM (Power Saving Mode): after sending, the device stays reachable for a short active time (timer T3324), then goes completely unreachable, drawing a few µA, until its periodic tracking-area-update timer (T3412) expires or it has data to send. Sleeps of hours to days are possible. Downlink messages wait in the network (or are lost) until the device wakes.

eDRX (extended discontinuous reception): the device wakes periodically (from about 5 seconds to 3 hours on LTE-M, up to ~3 hours on NB-IoT) to check for incoming data, then sleeps. It trades downlink latency for power while remaining reachable.

send ─┬─ active time (T3324): reachable ─┬─ PSM sleep (µA), unreachable ── ... ─ wake at T3412 or on data
      └─ RRC release ───────────────────┘

The device requests timer values; the network decides what it grants. Always read back the granted values (AT+CEREG? shows them) rather than assuming.

#include <stdio.h>

/* Decode a 3GPP GPRS Timer 3 value (T3412 extended), as returned in AT+CEREG: 3-bit unit + 5-bit value. */
static long t3412_seconds(unsigned byte) {
  static const long unit[] = { 600, 3600, 36000, 2, 30, 60, 1152000, -1 };  /* 10 min, 1 h, 10 h, 2 s, 30 s, 1 min, 320 h, deactivated */
  unsigned u = (byte >> 5) & 7, v = byte & 31;
  return unit[u] < 0 ? -1 : unit[u] * (long)v;
}

int main(void) {
  unsigned granted[] = { 0x38 /* 001 11000 */, 0x2C /* 001 01100 */, 0xA3 /* 101 00011 */ };
  for (int i = 0; i < 3; i++) {
    long s = t3412_seconds(granted[i]);
    printf("T3412 = 0b%u%u%u %u%u%u%u%u -> %ld s (%.1f h)\n",
           (granted[i] >> 7) & 1, (granted[i] >> 6) & 1, (granted[i] >> 5) & 1,
           (granted[i] >> 4) & 1, (granted[i] >> 3) & 1, (granted[i] >> 2) & 1, (granted[i] >> 1) & 1, granted[i] & 1,
           s, s / 3600.0);
  }
  return 0;
}

Also important: Release Assistance Indication (RAI) tells the network the device has no more data, so it can release the radio connection immediately instead of waiting for an inactivity timer (often 10 to 20 s at tens of milliamps).

AT commands

Most designs use a cellular module (Quectel BG95/BG77, u-blox SARA-R5, Nordic nRF9160/9151 as an integrated SoC, Sierra, Telit, SIMCom) controlled from the MCU over UART with AT commands. A minimal session:

AT                          -> OK                    (module alive)
AT+CPIN?                    -> +CPIN: READY          (SIM ready)
AT+CFUN=1                   -> OK                    (radio on)
AT+CGDCONT=1,"IP","iot.example"                      (set the APN)
AT+CEREG=5                                           (report registration incl. PSM timers)
AT+CEREG?                   -> +CEREG: 5,1,...        (1 = home, 5 = roaming: registered)
AT+CSQ / AT+CESQ            -> signal quality
AT+CPSMS=1,,,"00111000","00000001"                   (request PSM: TAU and active time)
... module-specific socket, MQTT or HTTP commands ...

Writing a robust AT driver is a project in itself:

  • Commands and unsolicited result codes (URCs such as +CEREG: ... or incoming data notifications) interleave on the same UART; parse line by line with a state machine.
  • Every command needs a timeout, and some take minutes (network search, AT+COPS).
  • Handle the module rebooting, the SIM missing, registration denied, and the network dropping the PDP context.
  • Use hardware flow control and keep the UART receive path DMA-based.
  • Keep a power-on/reset GPIO to recover a hung module.

SIMs and eSIM

Every device needs a subscription. Options:

  • Plug-in SIM: simple; a slot adds cost and is unreliable under vibration.
  • MFF2 (soldered SIM chip): robust, standard for industrial devices.
  • eSIM / eUICC: profiles can be downloaded and switched remotely (SGP.32 for IoT), so devices can change operator after deployment without physical access.
  • iSIM: the SIM function integrated in the modem chip.

IoT connectivity providers offer multi-operator global SIMs and data plans sized for kilobytes per month.

Designing for cellular

  • Check coverage for the specific technology and band where the device will be installed, including indoors or underground.
  • Peak current is high (up to ~500 mA for LTE-M/NB-IoT bursts, 2 A for 2G): the battery and supply must deliver it without browning out; add bulk capacitance.
  • Certification: the module is pre-certified, but the end product may need operator certification (PTCRB, GCF, carrier-specific) depending on market.
  • Plan firmware updates for both the MCU and the modem; LTE-M is much better suited to them than NB-IoT.

Pitfall: Opening a new TCP + TLS connection for every report on NB-IoT can cost tens of seconds of radio time due to latency. Prefer UDP with DTLS (or CoAP), keep sessions, batch data, and use RAI.

Interview question: Compare NB-IoT and LTE-M for an asset tracker in vehicles.

Answer: LTE-M is the better fit: it supports full mobility with handover between cells, higher data rates (around 1 Mbit/s), low latency and even voice, and is better for firmware updates. NB-IoT has limited mobility (re-selection rather than handover, so connections break while moving), long latency and very low throughput, but excels for static devices in deep-indoor locations. Many trackers use a module supporting both, preferring LTE-M, with coverage and operator availability in the target countries deciding the final choice.

Interview question: How do PSM and eDRX extend battery life?

Answer: Both let the device stay registered with the network so it avoids the costly attach procedure, while keeping the radio off most of the time. With PSM, after a short active window the device becomes unreachable and draws microamps until its periodic tracking-area-update timer expires or it has data to send, suitable when the device initiates all communication. With eDRX, the device sleeps between paging occasions spaced seconds to hours apart, staying reachable with that latency. The network grants the timer values, so firmware must read and adapt to them.

Build it: report from the port over NB-IoT

This is step 4 of the module project, the shipping-container tracker tag. Between depots, the tag reports over NB-IoT through a cellular module it drives with AT commands. Two things decide whether the battery lasts: sending only when the module is actually registered, and asking the network for a long PSM sleep, so the tag is not woken to re-register every hour.

Lab: Read the module's status lines, and request a PSM timer

  • modem_line(c, line) is called with every line the module sends. Update c from two kinds and ignore the rest:
  • +CSQ: <rssi>,<ber>: the signal is -113 + 2 × rssi dBm for rssi 0 to 31; 99 means unknown, stored as 0.
  • +CEREG: ... comes in two forms. The answer to AT+CEREG? is +CEREG: <n>,<stat>,... (the setting first), while the unsolicited report the module sends by itself is +CEREG: <stat> or +CEREG: <stat>,"<tac>",... (the second field, if any, is in quotes). Take <stat> from the right place: 1 is registered on the home network, 5 registered while roaming, anything else not registered.
  • psm_encode(seconds, out) writes the periodic update timer to request in AT+CPSMS, as 8 characters of 0 and 1 and a terminating zero: 3 bits of unit, then a 5-bit value from 0 to 31. Use the finest unit whose value fits, rounding the value up so the tag never asks for less sleep than it wants. The units, from finest: 011 2 s, 100 30 s, 101 1 min, 000 10 min, 001 1 h, 010 10 h, 110 320 h. Return 0, or -1 (leaving out alone) when even 31 × 320 h is too short.

Going deeper

Interview question: How would you design a shipping-container tracker that reports for five years on one battery?

Answer: Sleep almost always, wake on a timer or motion, get a GNSS fix quickly (with assistance data), and send a few bytes over NB-IoT or LTE-M using PSM and eDRX to keep the modem off between reports. Budget the energy of each report including network attach failures, adapt the reporting rate to battery level, and test in poor coverage.

Interview question: What is the PDP context or PDN connection in cellular IoT?

Answer: It is the data session between the device and the operator's packet network, established using an APN that identifies which network to connect to and which IP address type to use. Without an active context the device is registered but cannot send IP data. The network may deactivate it, so drivers must detect that (through unsolicited result codes) and re-establish it.

Interview question: Why must a cellular IoT design handle the peak current carefully?

Answer: During transmission bursts an LTE-M or NB-IoT module can draw several hundred milliamps for milliseconds (2G modules up to about 2 A). A battery with high internal resistance, a coin cell or a long thin supply trace causes the voltage to sag, resetting the module or the MCU. Bulk capacitance near the module, a low-impedance battery chemistry and a regulator rated for the peak are required.

Explain it: In your own words, explain how PSM lets a cellular device last years on a battery.

Answer: Normally a cellular device must stay reachable, listening for the network regularly, which costs energy. With Power Saving Mode, after sending its data the device stays reachable only for a short active time and then becomes unreachable, switching its radio off and drawing a few microamps, while remaining registered with the network. It does not have to repeat the expensive registration when it wakes, either to send new data or when its periodic update timer expires, perhaps hours or days later. Downlink messages wait until it wakes.