27  Cellular IoT Practical Knowledge

In 60 Seconds

Practical cellular IoT implementation centers on AT commands – the standard serial interface for controlling cellular modems. Key skills include network registration diagnostics (AT+CEREG for NB-IoT, AT+COPS for carrier selection), PDP context activation for data sessions, signal quality assessment (RSRP/RSRQ/SINR), and module selection based on your mobility, data rate, and coverage requirements (SIM7020 for NB-IoT, SIM7070 for LTE-M, BG96 for dual-mode).

Key Concepts
  • AT+CEREG: AT command for checking NB-IoT/LTE-M network registration status; response +CEREG: where stat=1 means registered home, stat=5 means registered roaming
  • AT+CSQ: Signal quality query returning RSSI (0–31 scale, 99=unknown) and BER; map to dBm: RSSI=-113+2×value; readings <10 indicate poor signal conditions
  • SARA-R4/SARA-R5: u-blox cellular IoT modules for NB-IoT/LTE-M respectively; used in production IoT devices with USB/UART AT command interface
  • Quectel BG96: Multi-technology cellular module supporting LTE-M, NB-IoT, EGPRS, and integrated GNSS; widely used for asset tracking and cellular IoT development
  • Network Registration States: 0=not registered searching, 1=registered home, 2=not registered but searching, 3=registration denied, 5=registered roaming — critical states for application logic
  • OTDOA (Observed Time Difference of Arrival): LTE positioning method using timing measurements from multiple base stations; achieves 50–200 m accuracy without GPS for asset tracking
  • AT+QCFG: Quectel extended configuration command for setting RAT (Radio Access Technology) preference, band selection, and operating mode; critical for network optimization
  • Current Measurement Validation: Verify PSM operation by measuring quiescent current with µA-resolution ammeter; NB-IoT PSM should show <5 µA; any higher indicates PSM failed to activate

This chapter provides practical knowledge for working with cellular IoT modules:

  • AT Commands: The standard way to control cellular modems
  • Troubleshooting: How to diagnose and fix common connectivity issues
  • Module Selection: Choosing the right hardware for your project
  • Real-World Scenarios: Practice exercises based on actual deployment challenges

Work through the examples and quizzes to build confidence before your first deployment.

“AT commands are how you talk to a cellular modem,” explained Max the Microcontroller, typing on a serial terminal. “Every command starts with AT – short for Attention. Then you add specific instructions. It is like texting the modem and getting text messages back.”

Sammy the Sensor watched the screen. “What are the most important commands?” Max listed them. “AT+CEREG tells you if the device has registered with the network. AT+CSQ shows signal strength. AT+CGDCONT sets up the data connection. And AT+COPS lets you pick which carrier to use. These four commands solve 80 percent of connectivity problems.”

“Module selection matters too,” added Lila the LED. “The SIM7020 is great for NB-IoT only – small, cheap, low power. The SIM7070 handles both NB-IoT and LTE-M, giving you flexibility. And the Quectel BG96 is the Swiss army knife – it does NB-IoT, LTE-M, and even has a GPS receiver built in.”

Bella the Battery shared troubleshooting wisdom. “When things do not work, check in order: Is the SIM card activated? Is the antenna connected? Is the signal strong enough? Is the APN configured correctly? These four checks solve 90 percent of problems. Do not start debugging your code until the hardware basics check out.”

27.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Execute AT Commands: Construct and interpret AT command sequences for network registration, signal measurement, and PDP context activation
  • Diagnose Connectivity Failures: Apply a systematic troubleshooting workflow to resolve registration, PDP context, and signal quality issues
  • Justify Module Selection: Evaluate cellular modules (SIM7020, SIM7000G, BG96, SIM7600) against project requirements including mobility, power budget, and data rate
  • Interpret Signal Metrics: Convert CSQ values to RSSI in dBm and assess link margin for NB-IoT/LTE-M deployments
  • Contrast Technology Trade-offs: Analyze cost, coverage, and infrastructure differences between cellular IoT and LoRaWAN for specific deployment scenarios

27.2 Prerequisites

Required Chapters:

Technical Background:

  • Basic understanding of NB-IoT and LTE-M
  • Familiarity with serial communication
  • Understanding of IP networking basics

Estimated Time: 30 minutes

27.3 AT Commands Reference

⏱️ ~10 min | ⭐⭐⭐ Advanced | 📋 P09.C21.U04

AT (Attention) commands are the standard interface for controlling cellular modules.

27.3.1 Essential AT Commands

Command Description Example Response
AT Test communication OK
AT+CREG? Network registration status +CREG: 0,1 (registered)
AT+CSQ Signal quality +CSQ: 18,99 (good signal)
AT+CGDCONT Define PDP context (APN) OK
AT+CGACT Activate PDP context OK
AT+CGPADDR Show IP address +CGPADDR: 1,"10.0.0.1"
AT+CPSMS Configure PSM OK
AT+CEDRXS Configure eDRX OK
AT+CNMP Set network mode OK
AT+CMNB Set NB-IoT/LTE-M mode OK

27.3.2 Network Registration Status (+CREG)

The second value in +CREG: 0,X indicates registration status:

Value Meaning
0 Not registered, not searching
1 Registered, home network
2 Not registered, searching
3 Registration denied
4 Unknown
5 Registered, roaming

27.3.3 Signal Quality (+CSQ)

The first value (0-31) maps to RSSI:

CSQ Value RSSI (dBm) Quality
0-1 < -111 No signal
2-9 -109 to -95 Marginal
10-14 -93 to -85 OK
15-19 -83 to -75 Good
20-31 > -73 Excellent
99 Unknown Error

Formula: RSSI (dBm) = -113 + (2 × CSQ value)

Let’s calculate signal quality from AT+CSQ readings. If your module returns +CSQ: 18,99, the first number maps to RSSI using the formula:

\[\text{RSSI (dBm)} = -113 + (2 \times \text{CSQ value})\]

For CSQ = 18: \[\text{RSSI} = -113 + (2 \times 18) = -113 + 36 = -77 \text{ dBm}\]

This is good signal quality (15-19 range). For comparison: - CSQ = 10 → RSSI = -93 dBm (marginal for NB-IoT) - CSQ = 25 → RSSI = -63 dBm (excellent)

The link budget tells us if communication succeeds. With RSRP = -77 dBm and NB-IoT sensitivity of -141 dBm (CE Level 2), the link margin is:

\[\text{Margin} = -77 - (-141) = 64 \text{ dB}\]

This 64 dB margin means the device can tolerate 64 dB of additional path loss (walls, distance) before losing connectivity. Since each concrete wall adds ~20 dB loss, this signal can penetrate 3 walls reliably.

Try It: CSQ Signal Quality Calculator

Adjust the CSQ value returned by AT+CSQ to see the corresponding RSSI in dBm, signal quality rating, and link budget analysis for NB-IoT penetration.

27.3.4 Basic Connection Sequence

// 1. Test communication
sendAT("AT");
// Response: OK

// 2. Check SIM status
sendAT("AT+CPIN?");
// Response: +CPIN: READY

// 3. Check network registration
sendAT("AT+CREG?");
// Response: +CREG: 0,1 (registered)

// 4. Check signal quality
sendAT("AT+CSQ");
// Response: +CSQ: 18,99 (good signal, -77 dBm)

// 5. Configure APN
sendAT("AT+CGDCONT=1,\"IP\",\"iot.1nce.net\"");
// Response: OK

// 6. Attach to GPRS
sendAT("AT+CGATT=1");
// Response: OK

// 7. Activate PDP context
sendAT("AT+CGACT=1,1");
// Response: OK

// 8. Get IP address
sendAT("AT+CGPADDR=1");
// Response: +CGPADDR: 1,"10.0.0.123"

27.3.5 LTE-M Fleet Tracker Configuration

void configureLTEMTracker() {
  // Set LTE-only mode
  sendAT("AT+CNMP=38");
  delay(1000);

  // Select Cat-M1 (LTE-M)
  sendAT("AT+CMNB=1");
  delay(1000);

  // Automatic operator selection (for handover)
  sendAT("AT+COPS=0");
  delay(1000);

  // Configure APN
  sendAT("AT+CGDCONT=1,\"IP\",\"iot.carrier.com\"");
  delay(1000);

  // Enable eDRX for battery backup (not PSM due to frequent updates)
  sendAT("AT+CEDRXS=1,4,\"0101\"");  // Wake every 81.92s
  delay(1000);

  Serial.println("LTE-M tracker configured:");
  Serial.println("- Mode: LTE-M (Cat-M1) with handover support");
  Serial.println("- Power: eDRX enabled for battery backup");
}

27.4 Troubleshooting Common Issues

27.4.1 Issue 1: Network Registration Fails

Symptom: +CREG: 0,0 or +CREG: 0,2 (not registered)

Diagnostic Steps:

// Check signal
sendAT("AT+CSQ");
// If CSQ < 10: Signal too weak

// Check SIM
sendAT("AT+CPIN?");
// If not "READY": SIM issue

// Check operator
sendAT("AT+COPS=?");
// Lists available networks

// Force registration
sendAT("AT+COPS=1,2,\"310410\"");  // Example: AT&T

Solutions:

  • Improve antenna placement (near window)
  • Add external antenna (3-5 dBi gain)
  • Check SIM activation with carrier
  • Verify NB-IoT/LTE-M coverage in area

27.4.2 Issue 2: PDP Context Activation Fails

Symptom: Module registers (+CREG: 0,1) but HTTP/MQTT fails with timeout

Diagnostic Steps:

// Check PDP context
sendAT("AT+CGDCONT?");
// Should show configured APN

// Check IP address
sendAT("AT+CGPADDR=1");
// If empty: PDP not activated

// Check attachment
sendAT("AT+CGATT?");
// Should be +CGATT: 1

Solutions:

// Correct sequence:
sendAT("AT+CGDCONT=1,\"IP\",\"YOUR_APN\"");  // Configure APN
sendAT("AT+CGATT=1");                         // Attach to GPRS
sendAT("AT+CGACT=1,1");                       // Activate PDP context

Common APNs:

Provider APN
1NCE iot.1nce.net
Hologram hologram
Twilio wireless.twilio.com
Soracom soracom.io

27.4.3 Issue 3: Poor Signal Quality

Symptom: CSQ < 10 (marginal signal), frequent disconnections

Solutions:

  1. Add external antenna: 3-5 dBi gain improves signal by +3-5 dB
  2. Relocate device: Move closer to window (indoor attenuation 10-30 dB)
  3. Check carrier coverage: Use carrier coverage maps
  4. Try different carrier: Dual-SIM modules can switch carriers

RSRP Thresholds for NB-IoT/LTE-M:

RSRP (dBm) Quality Action
> -80 Excellent Optimal
-80 to -100 Good Acceptable
-100 to -110 Fair Consider antenna
-110 to -120 Marginal External antenna needed
< -120 Poor Relocate device
Try It: Signal Troubleshooting Diagnostic

Simulate an NB-IoT/LTE-M connection problem by setting signal and registration parameters. The diagnostic engine will walk you through the troubleshooting steps, just like a real deployment.

27.5 Module Selection Guide

27.5.2 Module Comparison Table

Feature SIM7020 SIM7000G BG96 SIM7600
Technology NB-IoT LTE-M/NB-IoT LTE-M/NB-IoT 4G LTE
Data Rate 127 kbps 375 kbps 375 kbps 10 Mbps
PSM Sleep 3 µA 7 µA 5 µA N/A
GPS No Yes Yes Yes
Price $8-12 $15-20 $20-25 $35-45
Best For Static sensors Mobile tracking Dual-mode High BW
Try It: Cellular IoT Module Selector

Select your project requirements below to get a module recommendation with rationale. Adjust parameters to see how different needs lead to different hardware choices.

27.6 Practical Exercises

27.6.1 Exercise 1: Mobile Fleet Tracking Scenario

Scenario: A logistics company needs to track 500 delivery vehicles across the country, reporting location and diagnostics every 5 minutes while vehicles move at highway speeds (60-120 km/h).

Requirements Analysis:

Requirement NB-IoT LTE-M Decision
Mobility (60-120 km/h) No handover Full handover (160 km/h) LTE-M
5-min GPS updates OK OK Either
Firmware OTA (200 KB) 6.4s (250 kbps) 1.6s (1 Mbps) LTE-M
Real-time alerts 1.6-10s latency 10-15 ms latency LTE-M

Conclusion: LTE-M is required for mobile applications with handover support.

Implementation:

// LTE-M configuration for fleet tracker
sendAT("AT+CNMP=38");      // LTE-only mode
sendAT("AT+CMNB=1");       // Cat-M1 (LTE-M)
sendAT("AT+COPS=0");       // Automatic operator selection (for handover)
sendAT("AT+CGDCONT=1,\"IP\",\"iot.carrier.com\"");  // APN
sendAT("AT+CEDRXS=1,4,\"0101\"");  // Wake every 81.92s for battery backup

27.6.2 Exercise 2: Cellular vs LoRaWAN Comparison

Scenario: Smart parking deployment (1,000 sensors, report every 5 minutes, 10-year battery life)

Cost Analysis:

Factor Cellular (NB-IoT) LoRaWAN
Module $10 $15
SIM/Activation $5 $0
Data Plan (10 yr) $10-100 $0
Gateway N/A $500 shared
Per Device $25-115 $16-17
1,000 Devices $25K-115K $16K-22K

Battery Life:

Technology PSM Sleep Battery Life
NB-IoT 10 µA 10+ years
LoRa 1-2 µA 10+ years

Conclusion: LoRaWAN is 2-5x cheaper for localized deployments where gateways can be installed. Cellular wins for global coverage and no gateway infrastructure.

Try It: Cellular vs LoRaWAN TCO Calculator

Compare the 10-year total cost of ownership for NB-IoT cellular versus LoRaWAN deployments. Adjust device count, data plan costs, and gateway sharing to see which technology is more cost-effective for your scenario.

27.7 Knowledge Check

27.9 Summary

This chapter covered practical cellular IoT knowledge:

  • AT Commands: Essential commands for module control including AT+CREG, AT+CSQ, AT+CGDCONT, AT+CPSMS
  • Signal Interpretation: CSQ values map to RSSI via formula: RSSI (dBm) = -113 + (2 × CSQ); target CSQ >= 15 for reliable operation
  • Troubleshooting: Common issues include network registration failure (check signal/SIM), PDP context problems (configure APN correctly), and poor signal (add external antenna)
  • Module Selection: SIM7020 for static NB-IoT sensors, SIM7000G for mobile LTE-M tracking, BG96 for dual-mode global deployments
  • Technology Comparison: LoRaWAN offers 2-5x lower TCO for localized deployments; cellular wins for global coverage and mobility

Next Steps:

  1. Get a SIM7000 module and IoT SIM card (Hologram or 1NCE)
  2. Test basic AT commands and network registration
  3. Implement MQTT communication to cloud broker
  4. Enable PSM/eDRX and measure power consumption
  5. Deploy a real-world cellular IoT sensor project

27.10 Concept Relationships

AT command implementation connects to: Cellular IoT Overview architecture (AT+CEREG checks MME registration), Power Optimization (AT+CPSMS/AT+CEDRXS configure timers), and Technology Selection (AT+CNMP/AT+CMNB select NB-IoT vs LTE-M mode). Module selection links to NB-IoT Applications and LTE-M Lab deployment scenarios.

27.11 See Also

Common Pitfalls

Cellular modules require 1–5 seconds after power-up before they respond to AT commands. Sending AT+CEREG? immediately after asserting PWRKEY low results in no response or garbage characters, causing firmware state machine confusion. Wait for the module’s power-on indication (e.g., “RDY” URC for Quectel modules, “+SYSSTART” for u-blox) before sending any AT commands. Set a 10-second hardware timeout as a fallback if the ready indication is not received.

Cellular modules asynchronously emit URCs for network events: +CEREG:5 (roaming registration), +CREG:0 (connection lost), +QIURC: “recv”,0 (data received), +CTZV: (time zone change). Firmware that only polls AT commands and discards unsolicited lines misses critical events like unexpected disconnection or incoming data. Implement a separate UART receive buffer that checks each incoming line against known URC prefixes before assuming it is a response to the last AT command.

Setting the APN with AT+CGDCONT does not immediately reconnect using the new APN. The device must deactivate the current PDP context (AT+CGACT=0,1) and reactivate it (AT+CGACT=1,1) or restart the module. Changes to APN configuration that are not followed by PDP context reconnection continue using the old APN until the module resets. Always follow APN changes with explicit PDP context management commands and verify connectivity with AT+CGPADDR.

Cellular modules occasionally lock up due to modem firmware bugs, memory corruption, or unexpected network events. A module that stops responding to AT commands cannot recover without a hardware reset (PWRKEY toggle or module VCC power cycle). Always implement: AT command timeout watchdog (trigger reset if no response in 60 s), periodic heartbeat check (AT every 60 s), and hardware reset capability from MCU GPIO. Log reset events for field diagnostics.

27.12 What’s Next

Now that you understand cellular IoT technologies, explore application-layer protocols:

Next Chapter Description
1 MQTT The most widely-used IoT messaging protocol for cellular connectivity
2 CoAP Lightweight request-response protocol optimized for constrained NB-IoT devices
3 AMQP Advanced message queuing for enterprise IoT and reliable delivery
4 NB-IoT Fundamentals Deep dive into Narrowband IoT technology and AT command specifics
5 LoRaWAN Overview Alternative LPWAN technology for cost comparison with cellular IoT

Deep Dives:

Comparisons:

Application Protocols:

Learning: