Firmware Development for Cellular IoT Devices

Building a connected device?

Book a Free 30-min Call

Introduction

Cellular IoT hardware

Cellular IoT is what some might call the new kid on the block: in some ways it is; on the other hand it is based on an existing infrastructure: cellular networks, which is used on every mobile phone in the world. Cellular IoT is rapidly developing, and will eventually become the driving component of many businesses.

In this article, we’ll take a quick look at developing cellular IoT devices, and some of the major things to keep in mind during development.

To begin with, it is critical that you have a solid understanding of the hardware before diving into the firmware. Let’s consider an IoT device which uses a cellular modem for communications, has one or more sensors, and is battery powered:

IoT hardware architecture

Here you have the core components:

  • A battery
  • A microcontroller (typically low power)
  • A cellular modem (and antenna)
  • One or more sensors, depending on your application/use case
  • Power circuitry

In this setup, the cellular modem is by far the most complex component: mainly because it’s a self-contained system which we have virtually no control over. It runs its own firmware, and in many cases, the only method of communicating with a modem is via AT commands, typically using UART as the communication interface.

Power Management

Most cellular modems have a defined power up sequence, and you need to keep this in mind when writing initialization code. Moreover, power management needs to be a key consideration in your design especially since the cellular modem is typically the most power-hungry component. In your hardware design, be sure to accommodate peak current of up to 2 Amps.

One possible power management scenario:

  • The microcontroller is always powered on, but is in low power mode
  • The sensors are usually powered off until they are ready to be used
  • The cellular modem is usually powered off until data is ready to be transmitted or received

Looking specifically at the modem, you can apply one or more of these power management options:

  • Use AT commands to put the modem in some kind of low power mode, if supported
  • Use Power Saving Mode (PSM) or eDRX (Extended Discontinuous Reception), if supported: tread carefully here, as these may depend on cellular operators
  • Completely cut off power to the modem when it is not needed. Critical: ensure you gracefully shut down the modem (via AT commands) before cutting off power. Abrupt shutdowns can corrupt modem firmware or cause network registration issues

Core IoT Device Functionality

Functionally speaking, cellular modems in IoT devices serve one primary purpose: sending and receiving data remotely. The application firmware typically needs to implement, as a bare minimum:

  • Initialization: turn on the modem and gracefully shut it down, and initialize the AT/UART interface
  • Network functionality: setting up and tearing down a cellular network connection
  • PDP context: connecting to the internet and receiving an IP address
  • Server functionality: setting up and tearing down a connection to a remote host/server
  • Data transmission/reception: the actual sending and receiving of data (raw TCP, HTTP, MQTT, etc.)

To implement these features in firmware, a good approach is to develop:

  • An AT interface: built on top of your UART driver, responsible for sending AT commands and receiving raw responses
  • An AT response parser: all AT commands return responses in various formats; you need a parser to extract the necessary information

Using these two modules as a base, you can implement higher-level modules for:

  • Device level functionality: reading modem information and configuring it
  • Network level functionality: setup/teardown of network connections and PDP context
  • Server level functionality: setup and teardown of remote server connections, TLS, data transfer

On a final note, implement the ability to perform modem firmware upgrades. This is extremely important, as the modem firmware dictates how the modem works and communicates with the cellular network. For certain certifications, this is a major requirement.

Conclusion

Developing cellular IoT devices is a challenging endeavour, and there are a lot of key considerations:

  • Modem selection: pick modems that support the protocols and network technologies (LTE CAT-M1, NB-IoT, etc.) needed for your product
  • Efficient power management: implemented both in hardware and software
  • Ability to upgrade modem firmware: critical for long-term maintenance and certification
  • Developing modem drivers: abstract as much as possible, which will make it easy to switch modems when necessary

Tags

Cellular IoTIoTArchitectureBest Practices
TA

Timothy Adu

Senior embedded consultant based in Copenhagen, working with startups and product teams on connected hardware.

About Timothy →