10  Sensor Application Architecture

System Design Patterns and Data Flow

10.1 Learning Objectives

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

  • Diagram System Architecture: Illustrate sensor network topology and data flow patterns
  • Apply Design Patterns: Select proven architectural patterns for different deployment scenarios
  • Plan Deployment Lifecycle: Follow systematic processes from requirements to operations
  • Analyze Sensor Coverage: Determine optimal sensor placement and network design
  • Select Appropriate Connectivity: Match network protocols to application requirements
In 60 Seconds

Sensor applications follow a layered architecture: sensors collect raw physical data, gateways aggregate and preprocess at the edge, networks transport to the cloud, cloud platforms store and analyze, and applications present insights. The critical design decision is where to process data — edge processing reduces latency and bandwidth for time-critical control, while cloud processing enables complex analytics at scale. Always design based on your latency requirements, data volume, and connectivity constraints.

Key Concepts
  • IoT Reference Architecture Layers: Perception layer (sensors, actuators), network layer (gateways, connectivity), processing layer (edge/cloud compute), application layer (dashboards, APIs, automation); each layer has distinct protocols, hardware, and design considerations
  • Gateway vs. Direct-to-Cloud: A gateway (Raspberry Pi, industrial PC) aggregates sensor data locally before transmitting to the cloud, enabling edge processing, protocol translation, and local buffering; direct-to-cloud (ESP32 Wi-Fi to MQTT broker) is simpler but lacks edge processing capability
  • Message Queue Architecture: Using MQTT brokers (Mosquitto, HiveMQ, AWS IoT Core) to decouple sensor data production from consumption; sensors publish to topics, multiple consumers subscribe independently; enables fan-out to multiple analytics pipelines without sensor-side changes
  • Time-Series Database Selection: InfluxDB, TimescaleDB, and Amazon Timestream are optimized for high-frequency timestamped sensor data; support automatic downsampling (retention policies), time-range queries, and aggregation functions native to time-series analysis
  • Pub-Sub vs. Request-Response for Sensor Data: Publish-subscribe (MQTT, Kafka) pushes data to subscribers as it arrives — ideal for high-frequency streaming sensor data; request-response (HTTP REST) pulls data on demand — better for infrequent queries and command-response actuator control
  • Data Schema Design for Sensor Applications: Time-series schema: (timestamp, device_id, metric, value, unit, quality_flag); storing quality flags alongside readings enables downstream filtering of questionable data without discarding it
  • Horizontal Scaling for Sensor Data Ingestion: As sensor networks grow from 100 to 10,000 devices, single-broker and single-database architectures hit throughput limits; horizontal scaling uses broker clustering (MQTT cluster), database sharding (by device_id or time range), and CDN caching of dashboard queries
  • Sensor Data Security Architecture: Each layer requires security: sensor authentication (TLS client certificates), data integrity (message signing), transport encryption (TLS 1.2+), cloud access control (IAM policies), and audit logging of all sensor data access

10.2 MVU: Minimum Viable Understanding

Core concept: Sensor applications follow a layered architecture pattern: sensors collect data, gateways aggregate and filter, networks transport, clouds store and analyze, applications present insights. Why it matters: Understanding this architecture helps you identify bottlenecks, plan for scale, and make informed decisions about where to process data (edge vs. cloud). Key takeaway: Design your architecture based on latency requirements, data volume, and connectivity constraints - not all data needs to reach the cloud.

Architecture is the “big picture” of how an IoT system fits together. Just like a building has a floor plan showing how rooms connect, a sensor system architecture shows how data flows from sensors, through gateways and networks, up to the cloud where it gets analyzed and turned into useful insights. Understanding this layered structure helps you plan projects that work reliably at any scale.

In This Series:

Architecture Topics:

10.3 Sensor Application Domain Hierarchy

Hierarchical diagram of IoT application domains including healthcare, agriculture, industrial, and smart home with sensor categories
Figure 10.1: IoT Application Domains: Healthcare, Agriculture, Industrial, and Smart Home

This layered view categorizes sensors by criticality level - from safety-critical to convenience - helping you understand different reliability and accuracy requirements.

Layered diagram of sensor criticality levels from safety-critical at top to convenience at bottom with reliability requirements
Figure 10.2: Criticality-based sensor selection: Safety-critical applications (medical, gas detection) demand certified sensors with redundancy. Operational applications (industrial monitoring) need high reliability. Informational applications (smart home) can use lower-cost consumer sensors. Match sensor grade to application criticality.

10.4 Sensors Per Domain

Mapping of sensor types to IoT domains showing smart city, healthcare, agriculture, and industrial sensor assignments
Figure 10.3: Sensor-to-domain mapping: Each IoT domain has characteristic sensors. Smart cities use ultrasonic (parking), cameras (traffic), and PM2.5 (air quality). Healthcare relies on PPG (heart rate), accelerometer (falls), and SpO2 (oxygen). Agriculture needs soil moisture, climate sensors, and GPS. Industrial IoT uses vibration, current, and flow sensors. Know your domain to select appropriate sensors.

10.5 Sensor Selection Decision Tree

Decision tree for sensor selection showing indoor vs outdoor deployment paths with connectivity options
Figure 10.4: Sensor Selection Decision Tree: Indoor vs Outdoor Deployment Paths

This decision tree helps you quickly narrow down connectivity options based on key deployment criteria. The path from indoor battery-powered leads to BLE for ultra-low power, while outdoor real-time applications typically require cellular connectivity.

10.6 Data Flow Architecture

End-to-end IoT data flow architecture from sensors through gateway and cloud to user applications
Figure 10.5: End-to-End IoT Data Flow: Sensors to Cloud to Application

Key Architecture Decisions:

  1. Edge Processing: Filter and aggregate data at the gateway to reduce network traffic and cloud costs
  2. Protocol Selection: MQTT for low-bandwidth, HTTP for compatibility, WebSocket for real-time
  3. Bidirectional Communication: Enable control commands from application back to sensors
  4. Analytics Placement: Real-time alerts at edge, batch analytics in cloud

10.7 Sensor Usage Statistics

Pie chart showing IoT sensor market distribution with temperature sensors leading at 28 percent
Figure 10.6: IoT Sensor Market Distribution: Temperature Leads at 28%

Temperature sensors dominate IoT deployments because they are: - Universal: Needed across all domains (cities, homes, industry, agriculture, health) - Low-cost: Starting at $1-2 for basic sensors - Easy to integrate: Simple analog or digital interfaces - Well-understood: Mature technology with predictable behavior

10.8 Sensor Type Comparison by Application

Comparison chart of sensor types organized by application domain: smart cities, agriculture, healthcare, and industrial
Figure 10.7: Sensor Types by Application Domain: Smart Cities, Agriculture, Healthcare, Industrial

10.9 Sensor Deployment Lifecycle

Flowchart of sensor deployment lifecycle from requirements analysis through optimization to scaling
Figure 10.8: Sensor Deployment Lifecycle: From Requirements to Scale and Optimization

Lifecycle Phases Explained:

  1. Requirements Analysis (Week 1-2): Define what you need to measure, where, how accurately, and within what budget
  2. Sensor Selection (Week 2-3): Match sensor specifications to requirements using the Selection Wizard
  3. System Design (Week 3-4): Plan network topology, gateway placement, and data flow architecture
  4. Prototype & Test (Week 4-8): Deploy 5-10% of planned sensors to validate assumptions
  5. Optimization (Week 8-10): Adjust sensor placement, sampling rates, and connectivity based on prototype results
  6. Full Deployment (Week 10-16): Install all sensors, configure network, calibrate, and test end-to-end
  7. Operations & Monitor (Ongoing): Collect data, manage alerts, track performance metrics
  8. Maintenance (Quarterly): Calibrate sensors, replace batteries, update firmware
  9. Scale & Expand (As needed): Add sensors, new locations, or additional sensor types based on operational insights

10.10 Architecture Design Patterns

10.10.1 Pattern 1: Star Topology (Simple)

     Sensor1 ---+
                |
     Sensor2 ---+--- Gateway --- Cloud
                |
     Sensor3 ---+

Use when: Small deployments (<20 sensors), all sensors within gateway range, Wi-Fi/BLE connectivity Example: Smart home, single office floor, small greenhouse

10.10.2 Pattern 2: Mesh Topology (Resilient)

     Sensor1 --- Sensor2
        |     X     |
     Sensor3 --- Sensor4 --- Gateway --- Cloud

Use when: Large area coverage, redundancy required, Zigbee/Thread connectivity Example: Industrial floor, smart city block, large farm

10.10.3 Pattern 3: Hierarchical (Scalable)

     Sensors --- Edge1 ---+
                          |
     Sensors --- Edge2 ---+--- Cloud
                          |
     Sensors --- Edge3 ---+

Use when: Large-scale deployments (100+ sensors), edge processing needed, LoRaWAN/cellular Example: City-wide deployment, multi-site enterprise, large agricultural operation

10.10.4 Pattern 4: Hybrid (Complex Requirements)

     Critical Sensors --- Direct Cloud (Cellular)
                              |
     Bulk Sensors --- Edge ---+ (LoRaWAN)
                              |
     Local Sensors --- Hub ---+ (Wi-Fi)

Use when: Mixed requirements (real-time + batch), different criticality levels, cost optimization Example: Hospital (critical patient monitors + environmental sensors), factory (safety + monitoring)

10.11 Coverage Planning

10.11.1 Sensor Coverage Radius Guidelines

Sensor Type Indoor Coverage Outdoor Coverage Notes
Temperature 50-100 m2 500-1000 m2 Depends on HVAC zones
Motion (PIR) 5-12 m cone Not recommended Line of sight required
Gas (CO2, VOC) 50 m2 100-500 m2 Diffusion-limited
Particulate (PM2.5) 100 m2 1-2 km2 Wind disperses particles
Noise 20-50 m radius 100-200 m radius Inverse square law
Ultrasonic 2-4 m direct 4-8 m direct Point measurement

10.11.2 Coverage Calculation Example

Scenario: Monitor air quality in 10,000 m2 office building

  1. Naive approach: 10,000 m2 / 50 m2 per sensor = 200 sensors (expensive!)
  2. Optimization: Place sensors near HVAC returns (8 zones) + high-occupancy areas (10 conference rooms) + open office (5 clusters) = 23 sensors
  3. Validation: Pilot with 5 sensors, interpolate missing areas, adjust as needed
  4. Result: 80% coverage with 90% fewer sensors

10.12 Network Bandwidth Planning

10.12.1 Data Rate Calculation

Formula: Data Rate = Sensors × Sample Rate × Bytes per Sample × Overhead

Example: 100 temperature sensors, 1 sample/minute, 4 bytes/sample, 2× overhead = 100 × (1/60) × 4 × 2 = 13.3 bytes/second = 0.1 kbps

Network Bandwidth vs. Cloud Cost Relationship

For 1,000 sensors sampling every 5 minutes: - Raw data rate: \(1000 \times \frac{1}{300\text{s}} \times 10\text{ bytes} \times 1.5\text{ overhead} = 50\text{ bytes/s}\) - Daily volume: \(50 \times 86400 = 4.32\text{ MB/day} \approx 130\text{ MB/month}\)

Cloud storage cost (AWS IoT Core at \(0.08/million messages):\)\(\text{Cost} = \frac{1000 \times 12 \times 30}{1,000,000} \times 0.08 = \$0.029/\text{month}\)$

But data transfer (egress) costs $0.09/GB, so: \(0.13\text{ GB} \times 0.09 = \$0.012/\text{month}\)

Key insight: For low-frequency IoT sensors, messaging costs dominate bandwidth concerns—network capacity is rarely the bottleneck; pricing models are. This math justifies edge aggregation strategies that reduce message counts rather than raw bytes.

10.12.2 Bandwidth Requirements by Application

Application Sensors Sample Rate Data per Sensor Total Bandwidth
Smart Parking 1000 0.01 Hz 10 bytes 0.1 kbps
Air Quality 100 0.1 Hz 50 bytes 0.5 kbps
Industrial Vibration 20 1000 Hz 4 bytes 640 kbps
Video Surveillance 10 30 fps 100 KB/frame 240 Mbps

Key Insight: Video dominates bandwidth. For sensor-only deployments, bandwidth is rarely the bottleneck; power and cost are.

10.13 Knowledge Checks

    1. Star Topology – all sensors connect to one gateway
    1. Mesh Topology – sensors relay data through each other
    1. Hierarchical – sensors connect through edge gateways
    1. Hybrid – different connectivity tiers for different criticality levels

Answer: D) Hybrid – different connectivity tiers for different criticality levels

A hospital has mixed requirements: critical patient monitors need real-time, ultra-reliable cellular/Wi-Fi connections directly to the cloud, while environmental sensors (temperature, humidity) can use lower-cost LoRaWAN or Wi-Fi through edge gateways with batch uploads. The hybrid pattern optimizes cost by using expensive high-reliability connections only where needed, while still providing comprehensive coverage.

    1. About the same bandwidth
    1. About 10x more bandwidth
    1. About 1000x more bandwidth
    1. About 30,000x more bandwidth

Answer: D) About 30,000x more bandwidth

The 1000 temperature sensors generate: 1000 × 0.1 Hz × 10 bytes = 1000 bytes/s = 0.008 Mbps. The 10 cameras generate: 10 × 30 fps × 100 KB/frame = 30 MB/s = 240 Mbps. The ratio is 240 / 0.008 = 30,000×. This demonstrates why video dominates bandwidth in IoT deployments and why edge processing (analyzing video locally) is critical for camera-based systems.

Key Takeaway

Sensor application architecture is about matching your design choices (topology, connectivity, edge vs. cloud processing) to your specific constraints (latency, data volume, power, cost, reliability). Not all data needs to reach the cloud – edge processing can reduce bandwidth by 100x. Start with the deployment lifecycle: define requirements, select sensors, design the architecture, prototype at 5-10% scale, optimize, then deploy fully.

Sammy the Sensor had a BIG project – helping design a sensor network for a whole city!

“There are so many sensors to organize,” Sammy said, looking at a map. “Parking sensors, air quality monitors, traffic counters, streetlights…”

Max the Microcontroller pulled out his planning board. “Let’s think about this like organizing a school. Not every student goes directly to the principal, right?”

“Right!” said Lila the LED. “Students talk to their teacher first. Teachers report to the department head. Department heads report to the principal. That’s a HIERARCHY!”

Max drew it out: “Exactly! Sensors talk to nearby gateways. Gateways send summaries to the cloud. The cloud shows everything on a dashboard. This way, the network doesn’t get overwhelmed.”

Bella the Battery raised a concern: “But what if a gateway breaks? Won’t all those sensors lose connection?”

“Good thinking, Bella!” Max replied. “For really important sensors – like gas leak detectors – we give them their own direct phone line to the cloud using cellular. Less important ones, like temperature sensors, can wait and send data in batches. That’s called a HYBRID design – mixing different connection types based on how important each sensor is.”

“So it’s like having a regular mailbox for birthday cards but a special emergency phone for 911?” Sammy asked.

“Perfect analogy! In IoT architecture, we always match the connection type to how critical the data is. Fast and reliable for emergencies, slow and cheap for routine check-ins!”

10.14 Worked Example: Smart Warehouse Sensor Network Design

Worked Example: Designing a Sensor Network for a 20,000 m2 Distribution Warehouse

Scenario: DHL Express is retrofitting a distribution warehouse in Rotterdam, Netherlands. The warehouse handles 45,000 packages/day and must monitor temperature zones, forklift traffic, and air quality for worker safety compliance (EU Directive 89/654/EEC).

Given:

  • Warehouse floor area: 20,000 m2 (200m x 100m), ceiling height 12m
  • Three temperature zones: Ambient (15-25C), Chilled (2-8C), Frozen (-25 to -18C)
  • Zone sizes: Ambient 12,000 m2, Chilled 5,000 m2, Frozen 3,000 m2
  • 35 forklifts operating across two shifts (06:00-22:00)
  • Budget: EUR 85,000 for hardware, EUR 15,000/year for cloud services
  • Existing infrastructure: Wi-Fi (15 access points), mains power throughout

Step 1 – Calculate sensor counts per zone:

Zone Area Sensor Type Coverage/Sensor Sensors Needed Unit Cost Zone Cost
Ambient 12,000 m2 Temperature (DHT22) 100 m2 120 EUR 8 EUR 960
Chilled 5,000 m2 Temperature (DS18B20, waterproof) 50 m2 100 EUR 12 EUR 1,200
Frozen 3,000 m2 Temperature (PT100 industrial) 50 m2 60 EUR 45 EUR 2,700
All zones 20,000 m2 CO2 (SCD30) 200 m2 100 EUR 55 EUR 5,500
Loading docks (x4) 800 m2 Door sensors + PIR Per dock 8 EUR 25 EUR 200
Forklift paths UWB anchors (Decawave DWM1001) 400 m2 radius 50 EUR 85 EUR 4,250
Total sensors 438 EUR 14,810

Step 2 – Select architecture pattern (Hierarchical):

  • Why hierarchical: 438 sensors exceed star topology limits. Mesh is unnecessary because mains power is available. Hierarchical with edge gateways matches the zone-based layout.
  • Gateway placement: 1 per zone boundary + 2 for loading docks = 5 ESP32 gateways (EUR 35 each = EUR 175)
  • Protocol: Wi-Fi for gateways (use existing APs), I2C/1-Wire for sensor buses within zones
  • Edge processing: Each gateway aggregates 60-120 sensors, computes zone averages every 30 seconds, transmits only zone summaries + threshold violations

Step 3 – Calculate bandwidth and cloud costs:

  • Sensor data rate: 438 sensors x 1 reading/30s x 20 bytes = 292 bytes/s = 25 MB/day
  • With edge aggregation (5 zone summaries/30s): 5 x 33 bytes/30s = 5.5 bytes/s = 0.5 MB/day
  • Cloud service (AWS IoT Core): 0.5 MB/day x 30 days x EUR 0.08/million msgs = EUR 36/month
  • Dashboard hosting (Grafana Cloud): EUR 49/month
  • Annual cloud cost: EUR 1,020 (well under EUR 15,000 budget)

Step 4 – Deployment timeline (hybrid lifecycle):

  • Weeks 1-2: Install 20 sensors in chilled zone (pilot) + 1 gateway
  • Weeks 3-4: Validate temperature accuracy (compare to calibrated reference)
  • Weeks 5-8: Roll out remaining zones at 100 sensors/week
  • Week 9: UWB anchor installation and forklift tag deployment
  • Week 10: Full system commissioning and staff training

Result: 438 sensors across 5 edge gateways providing zone-level temperature compliance, CO2 monitoring, and forklift tracking for EUR 15,000 hardware + EUR 1,020/year cloud. Edge aggregation reduced cloud data by 98% (25 MB/day raw to 0.5 MB/day aggregated). Temperature excursions in the frozen zone are detected within 30 seconds and trigger SMS alerts to warehouse managers.

Key Insight: The biggest cost driver is not the sensors (EUR 14,810) but the installation labor (estimated EUR 40,000 for cable runs, mounting, and commissioning). When budgeting, allocate 2-3x the hardware cost for professional installation. Hierarchical architecture with edge gateways reduces ongoing cloud costs to under EUR 100/month.

10.15 Summary

This chapter covered sensor application architecture patterns:

  • Domain Hierarchy: Understanding how 61+ applications map across 12 IoT domains
  • Criticality Levels: Safety-critical vs. operational vs. informational sensor requirements
  • Data Flow Architecture: Six-layer model from sensors to applications
  • Decision Trees: Systematic approaches to sensor and connectivity selection
  • Deployment Lifecycle: Nine-phase process from requirements to continuous operation
  • Design Patterns: Star, mesh, hierarchical, and hybrid topologies for different scales
  • Coverage Planning: Guidelines for sensor placement and density optimization
  • Bandwidth Planning: Calculating network requirements for different application types

10.16 Knowledge Check

Common Pitfalls

A single MQTT broker and a single-node InfluxDB instance handle 100 sensors easily, but adding 1,000 sensors may overwhelm them. Plan for 10x growth at design time by choosing broker and database solutions that support clustering and horizontal scaling, even if you start with single-node deployments.

Storing 1-Hz raw readings from 500 sensors indefinitely generates 15 TB/year. Design data retention tiers upfront: keep raw data for 7-30 days, 1-minute aggregates for 1 year, hourly averages permanently. Retroactively re-architecturing data retention after the database is full is significantly more difficult than designing it upfront.

HTTP REST requires a new TCP connection for each request, adding 50-200 ms latency per reading. For sensors reporting every second or faster, this overhead is unacceptable and the bandwidth cost is significant. Use MQTT or WebSocket for streaming sensor data, and reserve REST APIs for configuration and historical data queries.

Network connectivity between the gateway and cloud is not guaranteed. Without local buffering at the gateway (RabbitMQ, SQLite, file-based queue), sensor readings are lost during connectivity outages. Design gateways to buffer at least 24-72 hours of sensor data locally and replay it to the cloud when connectivity is restored.

10.17 What’s Next

If you want to… Read this
Learn which sensors to choose for specific application domains Sensor Apps: Selection Wizard
Practice building sensor applications in hands-on labs Sensor Application Labs
Explore edge computing architecture for sensor applications Edge Computing
Learn about IoT reference models and standardized architectures IoT Reference Models