Practical applications

Applications of Microcontrollers in IoT

Learn how microcontrollers like ESP32, STM32, and nRF52 are used in IoT sensor nodes, edge gateways, smart meters, and industrial monitoring systems.

Visual

SensorsPower MgmtMicrocontrollerADC / MCU / RadioCloud / MQTTGatewayIoT Sensor Node

Concept overview

A microcontroller (MCU) integrates a CPU core, flash memory, RAM, and a set of peripherals including timers, ADC, UART, SPI, I2C, and GPIO into a single chip. In IoT applications, the MCU reads physical-world data through sensors, performs local processing or filtering, and transmits results over a wireless or wired network. The choice of MCU depends on the trade-off between processing capability, power consumption, available peripherals, and wireless connectivity options.

Real-world applications

ESP32 in Smart Home Sensors
Smart Home
The Espressif ESP32-C3 combines a 160 MHz RISC-V core with 802.11b/g/n Wi-Fi and Bluetooth LE 5.0 on a single die. It reads temperature and humidity from a DHT22 sensor over a single-wire protocol, then publishes readings to an MQTT broker over Wi-Fi every 30 seconds. Thousands of commercial IoT devices including Sonoff switches and Shelly relays use this exact SoC.
STM32L4 in Industrial Vibration Monitors
Industrial IoT
The STM32L476 operates down to 1.71 V with a run-mode current of 100 microamps per MHz. In predictive maintenance nodes such as those from SKF and Fluke, it samples a MEMS accelerometer at 25.6 kHz over SPI, computes an FFT in its FPU, identifies spectral peaks corresponding to bearing defect frequencies, and transmits an alarm flag over LoRaWAN using an attached SX1276 radio module.
nRF52840 in BLE Asset Trackers
Asset Tracking
Nordic Semiconductor's nRF52840 includes a 64 MHz ARM Cortex-M4F, 1 MB flash, and a multiprotocol 2.4 GHz radio supporting BLE 5.2, Zigbee, and Thread. In Tile and similar asset tracking tags, the MCU wakes from 2 microamp sleep mode on a BLE advertisement interval, transmits a beacon packet encoding the device ID, then returns to sleep. The entire wake-transmit-sleep cycle completes in under 5 milliseconds.

How it works in practice

A typical IoT sensor node operates as an event loop driven by interrupts and timers. At startup, the MCU initialises peripherals, establishes a network connection, and enters a low-power sleep mode. A real-time clock or watchdog timer wakes the MCU at the programmed interval. The ADC samples the sensor output, firmware applies a calibration polynomial, and the result is formatted as a JSON or CBOR payload. The payload is passed to the wireless driver, which manages the MAC layer handshake and radio state machine. After acknowledgement, the MCU cuts power to the sensor and radio and re-enters sleep. Power budgeting is critical: on a coin cell with 220 mAh capacity, transmitting every 60 seconds at 15 mA for 10 ms and sleeping at 2 microamps otherwise gives a lifetime of approximately three years. Security at the MCU level involves storing TLS session keys or pre-shared keys in a dedicated secure element such as the ATECC608B, which communicates with the MCU over I2C and performs elliptic-curve operations without exposing key material on the bus.

Examples

ESP32 MQTT Temperature Node
An ESP32 DevKit reads a DS18B20 one-wire temperature sensor on GPIO4. On boot, the firmware reads the sensor, connects to Wi-Fi using stored credentials in NVS flash, publishes the reading to the topic home/sensor/temperature as a floating-point string over MQTT at QoS 1, waits for the PUBACK, disconnects, and enters deep sleep for 60 seconds. Deep sleep current is approximately 10 microamps. On a 3.7 V lithium cell of 1000 mAh, the node lasts approximately 600 days assuming 200 ms active time per wake cycle.
STM32 LoRaWAN Vibration Alert
The STM32L476 samples an ADXL345 accelerometer at 800 Hz over SPI. After 512 samples, it runs a 512-point FFT using CMSIS-DSP library functions in about 4 ms on the 80 MHz FPU. It searches the magnitude spectrum between 50 Hz and 300 Hz for peaks exceeding a threshold that corresponds to bearing outer-race defect frequencies. If a peak is found, it encodes a 4-byte payload with the peak frequency and amplitude, calls the LoRaWAN stack to join and transmit on the AS923 band, then resets the sample buffer. The LoRa transmission adds about 60 mA for 200 ms per alert.

Future scope

Microcontrollers with integrated neural processing units (NPUs) such as the Arm Ethos-U55 are entering the IoT market through devices like the Alif Ensemble E7 and the Arduino Nicla Vision. These NPUs execute quantised convolutional neural network inference at under 1 mW for keyword spotting and anomaly detection workloads, eliminating the need to transmit raw sensor data to the cloud. Matter, the new IoT interoperability standard from the Connectivity Standards Alliance, is driving adoption of Thread-enabled MCUs such as the nRF54L15 in smart home devices. Secure boot chains and remote attestation using on-chip trust anchor hardware are becoming mandatory in products shipped into the EU under the Cyber Resilience Act, which takes effect in 2027.