11.1 IoT stack at a glance
Sensors/Actuators
^ v
Edge node (MCU + radio) <-- MQTT, CoAP, LWM2M
^ v
Gateway (Wi-Fi router, hub) <-- TLS, VPN
^ v
Cloud (broker, DB, dashboards) <-- AWS IoT, Azure IoT, ThingsBoard
^ v
User app (mobile, web)Each layer has its own protocols, security model, and failure modes. Embedded engineering "ends" at the edge node, but you have to understand the whole stack to make rational decisions.
11.2 Application-layer protocols
- MQTT. Publish/subscribe over TCP. Tiny header, QoS 0/1/2, retained messages, Last Will. The IoT default. Eclipse Mosquitto, AWS IoT, HiveMQ. Battery-friendly: a 100-byte sensor reading is a few hundred bytes including TCP overhead; over Wi-Fi tens of milliseconds.
- CoAP. RESTful over UDP. Designed for constrained devices, very small footprint. Fewer brokers in the wild than MQTT but more efficient over LoRa/NB-IoT.
- AMQP. Industrial messaging. Heavier than MQTT, used in enterprise systems (RabbitMQ, Azure Service Bus).
- OPC-UA. Industrial automation. Servers expose namespaces; clients read/write tags. Used in factory floors, increasingly secure (X.509 auth).
- HTTP REST. Familiar, heavy. Fine for occasional uploads or device provisioning.
- WebSocket. Persistent bi-directional over HTTP upgrade. Sometimes used in lieu of MQTT for browser-friendly devices.
11.3 LWM2M and device management
OMA's LWM2M defines a CoAP/UDP-based device management protocol: register, observe, read, write, execute. Often used over NB-IoT/LTE-M for smart meters, asset trackers. Includes FOTA semantics.
11.4 Cloud platforms
AWS IoT Core, Azure IoT Hub, Google Cloud IoT (deprecated 2023), ThingsBoard (open-source), Particle, Tuya. They provide message routing, device shadows, OTA orchestration, dashboards, alerting.
11.5 Edge computing and TinyML
"The cloud is great, but every byte costs energy and latency." Edge computing pushes processing closer to the sensor. Examples:
- A smart camera that runs a person-detector on-device and only sends the metadata (no video upload) to save bandwidth and protect privacy.
- A vibration sensor that runs an FFT and a classifier locally, alerts only on bearing failure.
- A smart speaker that does keyword spotting ("Hey ___") on-device 24/7, only streams to cloud after the wake word.
TinyML is the discipline of running neural networks on microcontrollers. Frameworks (TensorFlow Lite Micro, Edge Impulse, Arm CMSIS-NN) compile quantized models into a few KB of code. Typical Cortex-M4 at 100 MHz can do small CNNs at tens of frames per second.
Hardware accelerators are appearing on MCUs: ARM Ethos-U55 NPU, ESP32-S3 vector unit, Renesas DRP-AI, NXP MCX-N. Specifically designed to run quantized nets at sub-mW.
The security implication is significant: on-device inference means the model is on the chip, available to anyone who can dump flash. Model confidentiality requires encrypted model storage and a hardware root of trust.