31  Software Platforms and Frameworks

31.1 Learning Objectives

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

  • Categorize IoT Software Platforms: Distinguish cloud platforms, application frameworks, and edge solutions by their architectural roles
  • Select Appropriate Platforms: Choose cloud, edge, or open-source solutions based on scale, budget, and integration needs
  • Deploy Device Management: Configure fleet provisioning, OTA updates, and remote monitoring platforms
  • Evaluate Platform Trade-offs: Assess vendor lock-in, cost, and scalability when making platform decisions

Key Concepts

  • Microcontroller Unit (MCU): Integrated circuit combining CPU, RAM, flash, and peripherals optimised for embedded control applications.
  • Microprocessor Unit (MPU): High-performance processor requiring external RAM, storage, and peripherals, used in Linux-based IoT devices like Raspberry Pi.
  • Schematic: Electrical diagram showing component connections using standardised symbols, used to guide PCB layout.
  • PCB (Printed Circuit Board): Fiberglass substrate with etched copper traces connecting electronic components into a permanent assembly.
  • ESD Protection: Diodes and resistors protecting sensitive IC pins from electrostatic discharge during handling and in-field use.
  • Decoupling Capacitor: Small capacitor placed close to IC power pins to suppress high-frequency noise on the supply rail.
  • Design Rule Check (DRC): Automated PCB verification ensuring trace widths, clearances, and drill sizes meet the fabrication process constraints.

31.2 Prerequisites

Before diving into this section, you should be familiar with:

  • IoT Reference Models: Understanding the layered IoT architecture provides context for where software platforms fit
  • Prototyping Software: Knowledge of development environments helps evaluate platform support
  • MQTT Protocol: MQTT is the dominant messaging protocol for IoT platforms

Think of IoT platforms like app stores + operating systems for smart devices.

Just like your phone needs iOS or Android to run apps, your IoT devices need platforms to connect, communicate, and be managed. Platforms give you pre-built tools—authentication, device management, data storage—that would take months to build from scratch.

Three types of platforms you’ll encounter:

Platform Type What It Does Example
Cloud Platform Connect devices to internet, store data AWS IoT, Azure IoT Hub
Edge Platform Process data locally before sending to cloud Home Assistant, EdgeX
Development Framework Tools for building IoT applications Node-RED, Arduino IDE

Start simple: For hobbyists, Node-RED and Home Assistant are friendly entry points. For production, consider AWS IoT Core or Azure IoT Hub.

“Hardware without software platforms is like a phone without an app store!” said Max the Microcontroller. “IoT platforms handle all the plumbing – connecting devices, storing data, managing updates, and keeping everything secure. You just focus on building your application.”

Sammy the Sensor asked about options. “There are three main types,” Max explained. “Cloud platforms like AWS IoT Core and Azure IoT Hub run in the cloud and handle millions of devices. Application frameworks like Node-RED and Home Assistant make it easy to build IoT apps with visual tools. And edge platforms like EdgeX process data locally before sending it to the cloud.”

Lila the LED shared a tip. “For beginners, start with Node-RED. You drag and drop blocks to connect sensors, process data, and trigger actions – no heavy coding required. For a smart home, Home Assistant integrates with over 2,000 device types right out of the box.” Bella the Battery added the production perspective. “When you are ready to scale up to thousands or millions of devices, cloud platforms provide the infrastructure. But choose carefully – switching platforms later is expensive. Look for ones that support standard protocols like MQTT so you are not locked in.”

31.3 Section Overview

This section covers the complete IoT software platform landscape across four focused chapters:

31.3.1 Cloud IoT Platforms

Major cloud providers offer managed IoT services for device connectivity, data processing, and analytics:

  • AWS IoT Core: Maximum scalability with Lambda, S3, and DynamoDB integration
  • Azure IoT Hub: Enterprise Microsoft integration with Digital Twins and IoT Central
  • Google Cloud IoT: Deprecated IoT Core, migration to Pub/Sub and partner solutions
  • Other platforms: IBM Watson IoT, Oracle IoT, Alibaba Cloud IoT

31.3.2 Application Frameworks

Higher-level tools for rapid IoT application development:

  • Node-RED: Visual flow-based programming with 4,000+ community nodes
  • Home Assistant: Smart home automation with 2,000+ device integrations
  • Eclipse Kura: Java/OSGi framework for industrial gateways

31.3.3 Edge Computing Platforms

Local processing for reduced latency and offline operation:

  • AWS IoT Greengrass: Edge Lambda functions and ML inference
  • Azure IoT Edge: Docker containers as modules with Azure integration
  • EdgeX Foundry: Vendor-neutral microservices architecture (Linux Foundation)

31.3.4 Device Management and Selection

Fleet management, open-source alternatives, and selection criteria:

  • Balena: Docker-based fleet management for Raspberry Pi
  • Mender: Open-source OTA updates with robust rollback
  • ThingsBoard, FIWARE, Mainflux: Self-hosted open-source platforms
  • Selection criteria: Scale, budget, expertise, integration needs

Compare cloud platform costs vs self-hosted MQTT for your IoT deployment:

Key Insight: Below ~36 million messages/month, cloud platforms are often cheaper due to free tiers. Above 100 million messages/month, self-hosted can save $1,000+/month, but requires DevOps expertise for setup, security, monitoring, and maintenance.

31.4 Platform Selection Quick Reference

Decision flowchart for selecting IoT software platforms based on device scale, showing three tiers: less than 100 devices (open-source or cloud free tiers), 100-10,000 devices (managed cloud platforms like AWS IoT or Azure IoT), and over 10,000 devices (enterprise cloud or custom infrastructure)

Scale Recommended Approach
< 100 devices Open-source (Home Assistant, ThingsBoard) or cloud free tiers
100-10,000 Managed cloud platforms (AWS IoT, Azure IoT)
> 10,000 Enterprise cloud or custom infrastructure

31.6 Concept Relationships

Platform Layer Dependencies:

┌─────────────────────────────────────┐
│   Application Layer                 │
│   (Node-RED, Home Assistant)        │
└──────────────┬──────────────────────┘
               │
┌──────────────▼──────────────────────┐
│   Edge Computing Layer               │
│   (Greengrass, IoT Edge, EdgeX)     │
└──────────────┬──────────────────────┘
               │
┌──────────────▼──────────────────────┐
│   Cloud Platform Layer               │
│   (AWS IoT, Azure IoT Hub, MQTT)    │
└──────────────┬──────────────────────┘
               │
┌──────────────▼──────────────────────┐
│   Device Layer                       │
│   (Firmware, RTOS, protocols)       │
└─────────────────────────────────────┘

Related Concepts:

Common Misconceptions:

  • Myth: “Cloud platforms lock you in permanently” Reality: Using standard protocols (MQTT, HTTP) with abstraction layers enables migration between platforms
  • Myth: “Open-source means free” Reality: Self-hosting requires DevOps expertise, servers, and maintenance - often higher TCO than managed cloud for small scales

Common Pitfalls

Sending raw sensor readings at maximum frequency consumes unnecessary bandwidth and storage, and can cause broker backpressure that drops messages from other devices. Apply edge-side dead-band filtering and send only meaningful updates; reserve full-rate data for local debug sessions.

Publishing all sensor types to one flat topic prevents selective subscriptions, makes stream processing complex, and inhibits per-sensor access control. Use a structured topic hierarchy (e.g. iot/{deviceId}/{sensorType}) that enables selective consumption and per-topic ACL policies.

When multiple clients update the device shadow simultaneously without conflict resolution, the device receives contradictory desired-state updates and enters an oscillating state. Implement optimistic locking with version numbers on shadow updates and define a clear precedence order for conflicting state sources.

31.7 Summary

  • Cloud platforms (AWS, Azure, GCP) provide managed infrastructure for scalability, security, and enterprise integration
  • Application frameworks (Node-RED, Home Assistant) enable rapid development through visual programming and pre-built integrations
  • Edge platforms (Greengrass, Azure IoT Edge, EdgeX) bring cloud capabilities to local devices for latency and offline requirements
  • Device management (Balena, Mender) solves operational challenges of fleet updates and monitoring
  • Open-source options (ThingsBoard, FIWARE, Mainflux) provide flexibility and cost savings for self-hosted deployments
  • Platform selection depends on scale, budget, expertise, integration needs, and strategic priorities

31.8 See Also

Cloud Platforms:

Edge & Local Processing:

Development Tools:

Device Management:

31.9 Try It Yourself

Project 1: Platform Cost Calculator

Difficulty: Beginner Time: 1 hour Equipment: Spreadsheet software (Excel, Google Sheets)

What You’ll Build: A cost comparison calculator for different IoT platforms.

Steps:

  1. Create columns for: Device count, Messages/device/day, AWS IoT, Azure IoT, ThingsBoard self-hosted
  2. Calculate monthly message volume: devices × messages/day × 30
  3. Apply pricing: AWS ($1/million messages), Azure ($0.80/million), Self-hosted ($50 VPS + bandwidth)
  4. Graph costs from 100 to 100,000 devices

What to Observe:

  • At what device count does self-hosted become cheaper than cloud?
  • How does message frequency affect the break-even point?
  • Impact of data storage and analytics services on total cost

Extension Challenge: Add labor costs - DevOps time for self-hosted vs. zero for managed cloud


Project 2: MQTT Platform Migration

Difficulty: Intermediate Time: 3 hours Equipment: Raspberry Pi or ESP32, MQTT broker (Mosquitto), ThingsBoard

What You’ll Build: An abstraction layer that allows switching MQTT backends without changing device firmware.

Steps:

  1. Set up local Mosquitto broker and ThingsBoard
  2. Write ESP32 firmware with configurable MQTT endpoint (stored in EEPROM)
  3. Implement web configuration portal to change broker URL/credentials
  4. Test switching between Mosquitto and cloud MQTT (HiveMQ Cloud free tier)
  5. Observe data continuity across backend changes

What to Observe:

  • Connection re-establishment time when switching brokers
  • Message loss during switchover (use QoS 1 to minimize)
  • Impact on battery life of frequent reconnections

Extension Challenge: Implement dual-publish mode - send to both primary and backup broker simultaneously


Project 3: Edge vs Cloud Latency Test

Difficulty: Intermediate Time: 2 hours Equipment: ESP32, local MQTT broker, cloud MQTT service, LED

What You’ll Build: A button-to-LED latency measurement comparing local vs cloud processing.

Setup:

  • Local path: Button → ESP32 → Mosquitto (same LAN) → ESP32 → LED
  • Cloud path: Button → ESP32 → AWS IoT Core (via internet) → ESP32 → LED

Steps:

  1. Wire button and LED to ESP32
  2. Publish button press to MQTT topic
  3. Subscribe to response topic and measure time to LED activation
  4. Run 100 trials for each path, calculate average and p95 latency

What to Observe:

  • Local latency: Typically 5-20 ms
  • Cloud latency: Typically 100-500 ms (depends on internet)
  • Latency variability (cloud has much higher jitter)

What to Learn: When is edge processing essential vs. nice-to-have?

Development:

Hardware Platforms:

Architecture:

Protocols:

  • MQTT - Message brokers
  • CoAP - RESTful services

31.10 Knowledge Check

Scenario: A company built their smart home product on a proprietary IoT platform (fictional “CloudConnect”) in 2020. In 2023, CloudConnect raised prices from $0.10/device/month to $2.00/device/month. With 10,000 deployed devices, monthly costs jumped from $1,000 to $20,000 — unsustainable for a $39 product. The team decides to migrate to self-hosted Mosquitto MQTT + ThingsBoard.

Step 1: Analyze the Existing Architecture

Current (CloudConnect proprietary):

// Device firmware (locked to CloudConnect)
#include <CloudConnect.h>

CloudConnect cloud("device-id-12345");

void loop() {
  float temp = readSensor();
  cloud.send("temperature", temp);  // Proprietary API
  cloud.loop();  // Proprietary event handling
}

Backend:

  • CloudConnect cloud (black box, no access)
  • Data stored in CloudConnect database (no export)
  • Mobile app uses CloudConnect SDK

Problems:

  1. Device firmware hard-coded to CloudConnect API
  2. No OTA update capability (firmware can’t be changed remotely)
  3. Historical data trapped in CloudConnect (2 years of sensor data)
  4. Mobile app tightly coupled to CloudConnect SDK

Step 2: Design the Open-Source Replacement

New architecture (Mosquitto MQTT + ThingsBoard):

Device firmware (rewritten for MQTT):

#include <WiFi.h>
#include <PubSubClient.h>  // Standard MQTT library

WiFiClient espClient;
PubSubClient mqtt(espClient);

void setup() {
  WiFi.begin(SSID, PASSWORD);
  mqtt.setServer(MQTT_BROKER, 1883);
  mqtt.connect("device-12345", MQTT_USER, MQTT_PASS);
}

void loop() {
  float temp = readSensor();

  // Publish to standard MQTT topic
  String payload = "{\"temperature\":" + String(temp) + "}";
  mqtt.publish("v1/devices/me/telemetry", payload.c_str());

  mqtt.loop();
}

Backend:

  • Self-hosted Mosquitto MQTT broker (open-source, free)
  • ThingsBoard CE (Community Edition, open-source)
  • Self-hosted on AWS EC2 or DigitalOcean VPS

Step 3: Execute the Migration

Phase 1: Add OTA update to existing firmware (if possible) - Push OTA update with new MQTT firmware to all devices - If no OTA: Devices must be physically updated (mail USB programmer to customers)

Phase 2: Data export and migration

  • Use CloudConnect API to export historical data (if available)
  • If no export API: Accept data loss (painful lesson)
  • Import to ThingsBoard via REST API

Phase 3: Mobile app rewrite

  • Replace CloudConnect SDK with MQTT library (e.g., Eclipse Paho)
  • Update API endpoints to point to ThingsBoard REST API
  • Release mobile app update

Step 4: Cost Analysis

Old (CloudConnect):

  • Monthly cost: $2.00/device × 10,000 = $20,000/month
  • Annual cost: $240,000

New (Mosquitto + ThingsBoard self-hosted):

  • VPS hosting (4 vCPU, 8 GB RAM): $40/month
  • Bandwidth (50 GB/month): $10/month
  • Backup storage: $5/month
  • Monthly operational cost: $55/month
  • Annual cost: $660 (99.7% savings!)

Migration costs (one-time): - Firmware rewrite: 80 hours × $100/hr = $8,000 - Backend setup and testing: 40 hours × $100/hr = $4,000 - Data export scripts: 20 hours × $100/hr = $2,000 - Mobile app update: 60 hours × $100/hr = $6,000 - Total migration cost: $20,000

Payback period: $20,000 / ($20,000 - $55) = 1 month

After 1 month, the company saves $19,945/month forever.

Step 5: Lessons Learned

What went wrong initially:

  1. No OTA update mechanism → couldn’t migrate remotely (some devices needed physical update)
  2. Hard-coded vendor API → required full firmware rewrite instead of just changing endpoint
  3. No data export plan → lost 2 years of historical data
  4. Proprietary mobile SDK → required mobile app rewrite

What they should have done from day 1:

  1. ✅ Use standard MQTT from the start (no vendor lock-in)
  2. ✅ Build OTA update capability (migrate devices remotely)
  3. ✅ Store data locally + mirror to cloud (always have backup)
  4. ✅ Use open SDKs in mobile app (easy to switch backends)
  5. ✅ Abstract backend API into a separate service layer

The abstraction pattern (prevents future lock-in):

// backend.h (abstraction interface)
class IoTBackend {
  virtual void connect() = 0;
  virtual void sendData(const char* key, float value) = 0;
};

// mqtt_backend.cpp (MQTT implementation)
class MQTTBackend : public IoTBackend {
  void connect() { mqtt.connect(...); }
  void sendData(const char* key, float value) {
    mqtt.publish(topic, json);
  }
};

// main.cpp (use abstraction)
IoTBackend* backend = new MQTTBackend();
backend->connect();
backend->sendData("temperature", temp);

// Switching backends later: just change the implementation, not the application code

Key takeaway: The convenience of a proprietary platform (CloudConnect) becomes a trap when: (1) vendor raises prices, (2) vendor shuts down, or (3) vendor changes terms. Always use standard protocols (MQTT, HTTP) with abstraction layers to maintain the ability to migrate.

Factor Cloud Platform (AWS IoT, Azure) Self-Hosted (Mosquitto, ThingsBoard)
Setup time 1-2 days (managed service) 1-2 weeks (install, configure, secure)
Operational burden None (vendor manages) High (updates, backups, monitoring)
Scalability Automatic (millions of devices) Manual (add servers as needed)
Cost at 100 devices $10-50/month $10-20/month (small VPS)
Cost at 10,000 devices $1,000-5,000/month $100-500/month (larger VPS + bandwidth)
Cost at 1M devices $50,000-200,000/month $5,000-20,000/month (cluster + engineering)
Vendor lock-in risk High (proprietary APIs) None (open-source, portable)
Data ownership Vendor holds data You own data completely
Expertise required Low (managed service) High (DevOps, security, databases)
Uptime SLA 99.9%+ guaranteed You manage (no SLA)

Use cloud platform when:

  • Rapid prototyping (need working backend in hours)
  • No DevOps expertise on team
  • Unpredictable scale (could be 100 or 100,000 devices)
  • Enterprise integrations (Salesforce, SAP, etc.)
  • Compliance requirements (HIPAA, SOC 2) covered by vendor certifications
  • Startup raising VC funding (show enterprise-grade infrastructure)

Use self-hosted open-source when:

  • Cost-sensitive at scale (10,000+ devices)
  • Data sovereignty requirements (cannot store data in US/EU/etc.)
  • Custom features needed (modify open-source code)
  • Vendor lock-in is unacceptable (long-term product)
  • Team has DevOps expertise (or willing to hire)
  • Predictable scale (know device count within 2x)

Hybrid approach (common for mature products): 1. Year 1: Cloud platform (rapid development, validate product-market fit) 2. Year 2: Hybrid (keep cloud, add self-hosted for cost savings on high-volume data paths) 3. Year 3+: Primarily self-hosted (cloud as backup/disaster recovery)

Example progression:

  • 0-1,000 devices: AWS IoT Core ($50-100/month), fast development
  • 1,000-10,000 devices: AWS + self-hosted MQTT ($500/month), 70% cost reduction
  • 10,000+ devices: Primarily self-hosted ($2,000/month), AWS for enterprise customers only
In 60 Seconds

This chapter covers software platforms and frameworks, explaining the core concepts, practical design decisions, and common pitfalls that IoT practitioners need to build effective, reliable connected systems.

Common Mistake: Using Platform Free Tier in Production

The Problem: A developer builds an IoT product using AWS IoT Core free tier (250,000 messages/month free). During prototyping with 10 test devices, they never exceed the free tier. The product launches, and within 2 weeks, they have 500 paying customers. Month-end arrives, and AWS bills them $8,500.

What went wrong:

Free tier limits (AWS IoT Core example): - 250,000 messages/month (inbound/outbound combined) - After free tier: $1.00 per million messages

Actual usage:

  • 500 devices × 1 message/minute = 500 messages/minute
  • 500 × 60 minutes × 24 hours × 30 days = 21.6 million messages/month

Cost calculation:

  • Free: 250,000 messages = $0
  • Paid: 21,350,000 messages = 21.35 × $1.00 = $21.35
  • Wait, that’s not $8,500…what else?

Hidden costs missed:

  1. Rules engine: $0.15 per million actions (processing messages) = 21.35 × $0.15 = $3.20
  2. Device Shadow updates: 500 devices updating state every minute = 21.6M updates × $1.25 = $27.00
  3. Data transfer out: 21.6M messages × 500 bytes = 10.8 GB × $0.09/GB = $0.97
  4. S3 storage (archiving data): 10.8 GB/month × 12 months = 130 GB × $0.023 = $2.99
  5. Lambda invocations (data processing): 21.6M × $0.20 per million = $4.32
  6. DynamoDB writes (storing telemetry): 21.6M writes × $1.25 per million = $27.00
  7. CloudWatch logs: 5 GB/month × $0.50 = $2.50
  8. IoT Core registry (device management): 500 devices × $0.001/month = $0.50

Actual monthly AWS bill: $21.35 + $3.20 + $27.00 + $0.97 + $2.99 + $4.32 + $27.00 + $2.50 + $0.50 = $89.83

Still not $8,500. What really happened?

The killer: The developer didn’t realize they were sending one message per second (not per minute) due to a bug in retry logic. The actual message rate was: - 500 devices × 60 seconds × 60 minutes × 24 hours × 30 days = 1.296 billion messages/month

Corrected cost: 1,296 million messages = 1,296 × $1.00 = $1,296 (just for IoT Core) Plus all the other services scaling proportionally: $8,500 total bill

The fix (cost controls for production):

  1. Set billing alerts: AWS CloudWatch alarm at $100, $500, $1,000 thresholds
  2. Use AWS Budgets: Hard cap ($500/month) with email alerts
  3. Implement rate limiting in firmware:
const int MIN_SEND_INTERVAL = 60000;  // 1 minute minimum
unsigned long lastSend = 0;

void loop() {
  if (millis() - lastSend >= MIN_SEND_INTERVAL) {
    sendToCloud(data);
    lastSend = millis();
  }
}
  1. Test with realistic device count: 10 test devices is not representative of 500 production devices
  2. Calculate costs before launch: Use AWS Pricing Calculator with actual usage projections
  3. Consider hybrid approach: AWS for control plane, self-hosted MQTT for telemetry (90% cost reduction)

Lesson: Free tier is for prototyping, not production. Always calculate production costs based on actual device count and message frequency before launching.

31.11 What’s Next

If you want to… Read this
Learn about data visualisation for connected devices Data Visualisation Dashboards
Understand security for cloud-connected prototypes Privacy and Compliance
Explore full-stack IoT architecture patterns Application Domains Overview