25  Bluetooth Applications and Labs

In 60 Seconds

BLE powers real-world IoT across healthcare (glucose monitors, heart rate sensors), smart home (locks, lighting), wearables (fitness trackers), and retail (proximity beacons). BLE beacons broadcast identifiers without pairing for zone-based detection, while Bluetooth Mesh extends BLE for multi-hop building automation.

Key Concepts
  • GATT Profile: A standardized blueprint defining services and characteristics for a specific use case (e.g., Heart Rate Profile, Environmental Sensing Profile)
  • BLE Beacon: A one-way BLE advertiser that continuously broadcasts small data packets (UUID, Major, Minor) without establishing a connection
  • iBeacon / Eddystone: Apple’s and Google’s respective BLE beacon frame formats used for proximity detection and location services
  • A2DP (Advanced Audio Distribution Profile): Classic Bluetooth profile for high-quality stereo audio streaming to headphones and speakers
  • HID (Human Interface Device): Profile enabling keyboards, mice, and game controllers to communicate over Bluetooth without custom drivers
  • BLE Mesh: Extension of BLE for many-to-many device communication, used in large-scale lighting control and building automation
  • Proximity Profile: Uses RSSI (Received Signal Strength Indicator) to estimate distance between BLE devices for asset tracking
  • OTA (Over-the-Air) Update: Firmware delivery mechanism over BLE using DFU (Device Firmware Upgrade) profiles like Nordic’s NRF DFU
Minimum Viable Understanding

Bluetooth Low Energy (BLE) powers real-world IoT applications across healthcare (continuous glucose monitors, heart rate sensors), smart home (locks, lighting, thermostats), wearables (fitness trackers, smartwatches), and retail (proximity beacons for indoor navigation and marketing). BLE beacons broadcast identifiers without requiring pairing, enabling zone-based proximity detection, while Bluetooth Mesh extends BLE for multi-hop building automation like lighting control across floors.

25.1 Learning Objectives

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

  • Distinguish Bluetooth Use Cases: Analyze healthcare, smart home, industrial, and retail applications to select the appropriate BLE approach for each scenario
  • Implement BLE Beacons: Configure iBeacon and Eddystone for proximity-based services
  • Design Wearable Solutions: Apply BLE for fitness trackers, health monitors, and smart accessories
  • Construct BLE Applications: Develop client and server applications using standard BLE APIs
  • Evaluate Cloud Integration: Assess strategies to connect BLE devices to cloud platforms for data analytics
  • Diagnose BLE Deployments: Identify and resolve connection issues, range problems, and interference

25.2 Prerequisites

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

  • Bluetooth Fundamentals and Architecture: Understanding BLE architecture, GATT services, characteristics, and connection models is essential for building practical applications
  • Application Protocols Overview: Knowledge of protocol selection criteria helps you understand when to use Bluetooth versus other IoT protocols
  • Networking Fundamentals: Basic understanding of wireless communication, frequency bands, and interference is necessary for troubleshooting deployments

Deep Dives:

Comparisons:

Learning Resources:

Bluetooth Low Energy (BLE) is everywhere in IoT—from your fitness tracker to smart locks. This chapter shows how to build real applications, not just understand the theory.

Three Main Application Types:

Type How It Works Examples
Connected Devices Your phone pairs with a device for two-way communication Fitness bands, smart locks, medical devices
Beacons Small devices broadcast their location; phones detect them nearby Store navigation, museum guides, proximity alerts
Mesh Networks Devices relay messages to cover large areas Smart lighting, building automation

Common BLE Profiles:

BLE uses “profiles” that define how devices communicate for specific purposes:

  • Heart Rate Profile: Fitness devices send pulse data
  • Battery Service: Any device can report battery level
  • Device Information: Manufacturer, model, serial number
  • Proximity Profile: Detect when devices are nearby

Beacons Explained Simply:

A beacon is like a lighthouse—it constantly broadcasts “I’m here!” and an identifier such as “display #23”. As a phone walks past and detects that ID, the app can decide to show information or trigger an action for that specific location.

Two Beacon Standards:

  • iBeacon (Apple): Uses UUID + major + minor numbers
  • Eddystone (Google): Can broadcast URLs directly

When to Use Bluetooth:

Good for: Short range (<50m), phone connection, wearables, small data ❌ Bad for: Long range, large networks, high bandwidth, no phone involved

Quick Example - Fitness Tracker:

  1. Tracker has heart rate sensor
  2. BLE advertises “I have heart rate data”
  3. Phone app connects and subscribes to heart rate
  4. Tracker sends readings every second
  5. App displays your pulse in real-time

This chapter guides you through building these types of applications yourself.

“Guess what? I am inside a fitness tracker right now!” Sammy the Sensor said, bouncing with excitement. “Every time someone takes a step or their heart beats, I measure it and send the data over Bluetooth to their phone. That is how fitness apps know how many steps you have walked today!”

“And I am in the smart light bulb at home!” Lila the LED added. “When someone opens their phone app and picks a color, the Bluetooth signal tells me exactly what to do. I can turn sunset orange for movie night or bright white for homework time. Beacons are even cooler – they are like little lighthouses that broadcast signals so your phone knows exactly where you are in a store or museum!”

Max the Microcontroller grinned. “I am the one making it all work behind the scenes. In a smart lock, I receive the Bluetooth signal from your phone, check if you are authorized, and then unlock the door. In a hospital, I help glucose monitors send real-time data to nurses’ stations. The possibilities are endless!”

“The best part about all these Bluetooth applications,” Bella the Battery said wisely, “is that BLE was designed to sip power, not gulp it. A heart rate sensor can run for months on a single battery, and a beacon can broadcast for years. That is why Bluetooth is everywhere in IoT – from your wrist to your front door!”

Scenario: You’re deploying a proximity experience for a medium-sized retail store with ~30 product display areas. You want customers’ phones to show product details and promotions when they stand near specific displays. Beacons are battery-powered and should last months-to-years between maintenance.

Think about:

  1. Should you use iBeacon or Eddystone (UID/URL/EID)? What platform constraints drive the choice?
  2. How do beacon density, TX power, and advertising interval affect detection latency, battery life, and proximity granularity?
  3. If you need sub-meter positioning, what technology would you consider instead of RSSI-based proximity?

Suggested approach:

  • Start with a standard beacon format (Eddystone-UID or iBeacon) and a backend mapping from beacon IDs → locations/displays.
  • Pilot first: place beacons per zone/display, then adjust based on measured RSSI variability and user experience.
  • Tune advertising interval and TX power to meet latency/battery goals (shorter intervals improve discovery but increase power).
  • Remember: RSSI is noisy—avoid promising fixed “meter-level” accuracy without calibration.

Verify Your Understanding:

  • Why does shorter advertising interval reduce battery life?
  • When would Bluetooth Mesh be a better fit than beacons in a retail deployment?
How It Works: BLE Beacon Discovery and Connection

When you walk past a retail store with BLE beacons:

  1. Beacon Broadcasts: Every 100-1000ms, the beacon sends a 31-byte advertisement on channels 37, 38, 39 containing UUID, major, minor, and TX power
  2. Phone Scans: Your phone’s BLE scanner (if the app is running) listens on advertising channels during scan windows
  3. RSSI Measurement: Phone measures signal strength (RSSI) from each received advertisement
  4. Distance Estimation: Phone uses path loss formula: d = 10^((TxPower - RSSI)/(10×n)) where n≈2.5 indoors
  5. Zone Classification: App determines proximity: Immediate (<0.5m), Near (0.5-3m), Far (>3m) based on RSSI thresholds
  6. Content Trigger: When zone changes (e.g., entering “Near”), app fetches relevant content from backend using beacon’s UUID/major/minor as lookup key

No pairing needed - beacons are one-way broadcasters. The phone is a passive listener that never connects.

Question: A retail store deploys 100 BLE beacons with 20ms advertising intervals for “instant detection.” After 2 months, 80% of beacons have dead CR2032 batteries. What is the most effective fix?

25.3 Real-World Applications

⏱️ ~15 min | ⭐⭐ Intermediate | 📋 P08.C08.U01

Bluetooth technology spans multiple application domains, each leveraging specific capabilities of the protocol. The following diagram illustrates the major application areas:

Diagram showing BLE core technology branching into five domains: healthcare monitoring, smart home automation, wearable fitness, retail proximity services, and industrial sensor networks
Figure 25.1: Bluetooth Low Energy application domains spanning healthcare monitoring, smart home automation, wearable fitness devices, retail proximity services, and industrial sensor networks.

This variant shows the same BLE application domains organized by their typical data communication patterns - helping you understand which BLE features each domain relies on most.

BLE applications organized by data pattern: continuous streaming for wearables using notifications, beacons for retail using advertising only, smart locks using command response with security, and medical devices using reliable connections with encryption
Figure 25.2: BLE applications categorized by data communication pattern

Key Insight: Understanding the data pattern helps you choose the right BLE features. Continuous streaming needs connection with notifications. Beacons need only advertising. Smart locks need secure command/response. Matching your pattern to BLE capabilities optimizes battery life and responsiveness.

25.3.1 Healthcare and Medical Devices

BLE has revolutionized personal health monitoring by enabling continuous data collection with minimal power consumption. Medical-grade devices use standardized BLE profiles to ensure interoperability across platforms.

Key Applications:

  • Heart Rate Monitors: Chest straps and wristbands transmit real-time pulse data using the Heart Rate Profile (HRP)
  • Blood Glucose Meters: Continuous glucose monitors (CGMs) like Dexcom G6 send readings every 5 minutes to smartphones
  • Pulse Oximeters: SpO2 sensors provide oxygen saturation levels for respiratory monitoring
  • Temperature Sensors: Continuous fever monitoring for infants and post-operative patients

Real-World Example - Continuous Glucose Monitoring:

The Dexcom G6 CGM system demonstrates BLE’s capabilities in medical IoT:

  • Sensor transmits glucose readings every 5 minutes via BLE
  • 10-day sensor life with coin cell battery in transmitter
  • Range: Often on the order of a few meters in real use, but varies with placement and environment
  • Data stored locally on phone, synchronized to cloud for clinician access
  • Some CGM systems are cleared for insulin dosing decisions; check product labeling and jurisdiction-specific approvals

Regulatory Considerations:

Medical requirements vary widely by jurisdiction and device class. As a rule of thumb:

  • Plan for applicable medical-device regulatory pathways (e.g., US FDA, EU MDR/CE) based on intended use.
  • Treat security and privacy as design requirements (encryption, authentication, auditability) because health data is sensitive and may be regulated depending on who collects/processes it.
  • Some device categories may fall under medical electrical equipment standards (e.g., IEC 60601 family).

Always consult current regulatory guidance for your product and region.

25.3.2 Smart Home and Consumer Electronics

BLE powers the modern smart home ecosystem, providing low-power connectivity for devices that don’t require continuous high-bandwidth communication.

Key Applications:

  • Smart Locks: August, Yale, Schlage use BLE for keyless entry and access control
  • Light Bulbs: Philips Hue, LIFX enable smartphone control and automation
  • Thermostats: Nest, Ecobee use BLE for initial setup and local control
  • Audio Devices: Wireless speakers, headphones, soundbars

BLE Mesh for Smart Buildings:

Bluetooth Mesh extends BLE for large-scale building automation:

Three-floor smart building with BLE Mesh network showing lights, switches, and sensors on each floor connected via mesh topology, with gateway linking to cloud management platform
Figure 25.3: Bluetooth Mesh network for smart building lighting control across three floors, showing mesh connectivity between lights, switches, and sensors with gateway connection to cloud management platform.

BLE Mesh Capabilities (high level):

  • Scale (theoretical): large address space, but practical deployments depend on traffic, relay density, and environment
  • Reliability: managed flooding with relays/retransmissions can improve delivery (at the cost of airtime)
  • Security: built-in AES-CCM encryption with network/application keys (plan provisioning and key rotation)
  • Power Efficiency: Low Power Node + Friend features for battery-powered sensors

Example deployment (illustrative):

  • Multi-floor lighting + sensors + wall switches in a retrofit building
  • Over-the-air provisioning and group addressing for rooms/zones
  • Gateways bridge mesh to dashboards for monitoring and updates
  • Design considerations: relay placement, TTL, message rates, firmware update strategy, and safe fallback behavior if the cloud is down

25.3.3 Wearables and Fitness

Wearables rely heavily on BLE for phone connectivity and low-power sensor telemetry. They highlight the main engineering trade-off: always-on sensing and notifications, with a small battery.

Key Applications:

  • Fitness Trackers: Step counting, heart rate, sleep tracking (Fitbit, Garmin, Whoop)
  • Smartwatches: Notifications, activity tracking, contactless payments (Apple Watch, Galaxy Watch)
  • Activity Monitors: Specialized sports tracking (Polar, Suunto)
  • Sleep Trackers: Ring-based sleep analysis (Oura Ring)

BLE Profile Usage in Wearables:

Profile Purpose Data Rate Typical Update Interval
Heart Rate Profile (HRP) Pulse monitoring 1 byte/sec 1 second
Running Speed & Cadence Running metrics 5 bytes/sec 1 second
Cycling Power Power meter data 8 bytes/sec 1 second
Battery Service Battery level 1 byte 60 seconds
Device Information Model, firmware 20 bytes On connection

Example: Fitness Tracker Battery Life Budgeting

A tracker’s battery life is set by its average power draw. Major contributors are usually the radio (notifications/sync), sensors (PPG/IMU), display, and MCU.

Illustrative power budget (numbers vary by device and usage):

BLE radio (notifications + sync):      ~5 mW
Optical heart-rate sensing (duty):     ~6 mW
Display (intermittent):               ~2 mW
IMU + MCU (low-power processing):     ~2 mW
-------------------------------------------
Average power:                         ~15 mW

Battery energy: 200 mAh × 3.7 V ≈ 740 mWh
Estimated life: 740 mWh / 15 mW ≈ 49 hours (~2 days)

Note: Real products extend battery life by reducing average power (duty-cycling sensors, batching data, longer connection intervals, aggressive sleep). Use the calculation to reason about trade-offs, not as a guarantee.

25.3.4 BLE Beacons for Retail and Location Services

BLE beacons enable proximity-based services without requiring device pairing. They broadcast identifiers that smartphones can detect to trigger location-aware applications.

Two Major Beacon Standards:

Comparison showing iBeacon with UUID Major Minor TX power structure versus Eddystone with multiple frame types including UID URL telemetry and ephemeral ID, both broadcast by beacon hardware for app consumption
Figure 25.4: Comparison of iBeacon and Eddystone beacon standards showing identifier structures, frame types, and application integration approaches.

Beacon Applications:

  1. Proximity Marketing: Retail stores send promotions when customers approach specific products
  2. Indoor Navigation: Museums and airports guide visitors with beacon-based wayfinding
  3. Asset Tracking: Hospitals track medical equipment using beacon tags
  4. Contactless Check-in: Hotels and events enable automatic check-in via beacons
  5. Smart Parking: Parking garages detect available spaces and guide drivers

Example deployment: Museum navigation

  • Place beacons to create zones near exhibits/galleries.
  • App triggers audio/content when a beacon ID is seen (no pairing required).
  • Provide accessibility options (languages, captions) in the app.
  • Measure aggregate dwell time/flows only with clear user consent and privacy controls.

Beacon Battery Life Factors:

Parameter Longer Life Balanced Faster Discovery
Advertising Interval Longer (slower) Medium Shorter (faster)
TX Power Lower Medium Higher
Range Shorter Medium Longer
Battery Life Longer Medium Shorter
Proximity Granularity Coarse Medium Finer

Note: Actual range and battery life vary widely across hardware, configuration, and the physical environment—treat the table as a qualitative trade-off guide.

The beacon battery life trade-off is quantifiable. Consider a CR2032 coin cell (220 mAh capacity) with different advertising intervals.

\[\text{Average Current} = \frac{\text{Active Current} \times \text{Active Time} + \text{Sleep Current} \times \text{Sleep Time}}{\text{Total Time}}\]

For a 20ms advertising interval (3 channels × 1.2ms = 3.6ms active per event):

\[\text{Avg} = \frac{15\text{mA} \times 0.0036\text{s} + 0.002\text{mA} \times 0.0164\text{s}}{0.020\text{s}} \approx 2.7\text{mA}\]

Battery life: \(220\text{mAh} / 2.7\text{mA} \approx 81\) hours ≈ 3.4 days.

For a 1000ms interval: Average ≈ 0.055mA → 167 days (nearly 50× longer).

Pitfall: Setting Beacon Advertising Interval Too Short for Battery Life Goals

The Mistake: Deploying beacons with 20-100ms advertising intervals to “maximize discoverability,” then discovering batteries drain in weeks instead of the expected 2-3 years.

Why It Happens: Marketing materials emphasize fast discovery, and developers assume shorter intervals are “better.” But advertising is the dominant power consumer for beacons. A 20ms interval causes 50 radio wake-ups per second, each consuming approximately 15-25uA average current per advertisement event (including radio startup, TX, and settling time).

The Fix: Match advertising interval to your actual discovery latency requirements. Most retail/museum deployments work well with 300-1000ms intervals:

Battery life estimation (CR2032, ~220mAh):
- 20ms interval:  ~15uA avg → 220mAh / 0.015mA = ~14,667 hours (~1.7 years theoretical, often <1 year in practice)
- 100ms interval: ~8uA avg  → 220mAh / 0.008mA = ~27,500 hours (~3.1 years theoretical)
- 1000ms interval: ~3uA avg → 220mAh / 0.003mA = ~73,333 hours (~8.4 years theoretical)

Recommended starting points:
- Fast discovery needed (pairing flow): 20-50ms for a few seconds, then switch to slower
- Retail proximity: 300-500ms (sub-second discovery is fine for walking customers)
- Asset tracking: 1000-2000ms (discovery within seconds is acceptable)
- Presence detection: 2000-10240ms (10.24s is BLE max advertising interval)
Pitfall: Expecting Consistent RSSI-Based Distance Estimates from BLE Beacons

The Mistake: Building proximity features that assume RSSI (Received Signal Strength Indicator) provides meter-level accuracy, then finding that “1 meter away” sometimes reads as 0.5m and sometimes as 5m depending on user orientation and environment.

Why It Happens: RSSI is affected by multipath reflections, body absorption (humans absorb 2.4GHz signals), antenna orientation, and environmental changes. A person turning 90 degrees can cause 10-20 dBm RSSI variation—equivalent to a 3-10x distance change in naive distance calculations.

The Fix: Design for zone-based proximity (near/medium/far) rather than precise distances. Apply filtering and calibration:

// WRONG: Direct RSSI to distance conversion
function getDistance(rssi, txPower) {
    return Math.pow(10, (txPower - rssi) / (10 * 2.0)); // Unreliable!
}

// BETTER: Zone-based classification with hysteresis
const ZONES = {
    IMMEDIATE: { threshold: -50, name: "touching" },    // <0.5m typical
    NEAR:      { threshold: -65, name: "nearby" },      // 0.5-2m typical
    MEDIUM:    { threshold: -80, name: "in room" },     // 2-5m typical
    FAR:       { threshold: -90, name: "detectable" }   // >5m typical
};

// Apply moving average filter (5-10 samples)
// Add hysteresis (require 3+ consecutive readings before zone change)
// Calibrate thresholds per-venue with real measurements

25.3.5 BLE Application Selection Decision Tree

Choosing the right BLE approach depends on your use case requirements. This decision tree guides you through the selection process:

Decision tree flowchart guiding BLE architecture selection based on connection needs, multi-hop coverage requirements, and device roles, with branches for beacons, mesh, and GATT peripheral versus central configurations
Figure 25.5: Decision tree for selecting BLE application architecture based on connection requirements, coverage needs, and device roles.

25.3.6 BLE Deployment Workflow Timeline

Successful BLE deployments follow a structured workflow from requirements through production:

Six-phase BLE deployment workflow timeline from requirements analysis through hardware selection, firmware development, field testing, production deployment, to ongoing monitoring and OTA updates
Figure 25.6: BLE deployment workflow showing six phases from requirements analysis through ongoing operations with OTA updates and monitoring.

25.3.7 Industrial IoT Applications

Industrial environments increasingly adopt BLE for sensor networks, predictive maintenance, and safety monitoring. The protocol’s low power consumption and smartphone integration make it ideal for retrofitting existing equipment.

Key Applications:

  • Vibration Monitoring: Detect bearing failures in rotating equipment
  • Temperature Monitoring: Cold chain tracking for pharmaceuticals and food
  • Pressure Sensors: Hydraulic system monitoring in manufacturing
  • Gas Detection: Safety monitoring for hazardous environments

Industrial BLE Sensor Network Example:

Industrial sensor network architecture with BLE sensors connecting to zone gateways that aggregate data and forward to backend systems including MQTT broker, time-series database, ML anomaly detection, and alerting dashboard
Figure 25.7: Industrial BLE sensor network architecture showing sensors communicating via BLE to gateways, which forward data to backend systems for storage, ML analysis, and alerting.

Example: Predictive maintenance (illustrative):

  • Deploy vibration/temperature sensors on motors, pumps, or conveyors.
  • Gateways aggregate BLE data and forward it to backend storage and analytics.
  • Analysis can range from simple thresholds and spectral features to ML models; design for false positives and a human-in-the-loop workflow.

Industrial BLE Advantages vs Traditional Systems:

Aspect Traditional Wired BLE Wireless
Installation effort Higher (cabling) Lower (retrofit-friendly)
Ongoing maintenance Lower (no batteries) Battery management required
Scalability Harder (wiring) Easier (add sensors/gateways)
Retrofit existing equipment Often difficult Often simpler
Data rate Higher (continuous) Usually lower/moderate (periodic)
Reliability Predictable cabling Depends on RF environment; mitigated with gateway placement

25.4 Cross-Hub Connections

Deepen your understanding of Bluetooth applications with these curated resources:

Interactive Learning:

  • Simulations Hub: Try the BLE Beacon Range Estimator to calculate optimal beacon placement and advertising parameters for your deployment
  • Quizzes Hub: Test your knowledge with the Bluetooth Applications Quiz covering beacon deployment, wearable design, and industrial IoT scenarios

Video Tutorials:

  • Videos Hub: Watch demonstrations of BLE mesh network configuration, iBeacon setup, and real-world industrial sensor deployments

Knowledge Reinforcement:

  • Knowledge Gaps Hub: Understand common misconceptions about BLE range, battery life calculations, and beacon vs mesh selection criteria

Knowledge Mapping:

  • Knowledge Map: Visualize how Bluetooth applications connect to GATT profiles, security mechanisms, and other short-range protocols

25.5 Common Misconceptions

The reality: Beacons are one-way broadcasters. They cannot receive, so a beacon does not know who is nearby. Any “tracking” requires a phone/app that chooses to log beacon sightings.

What must be true for tracking to happen:

  1. A customer installs an app that listens for beacons
  2. The customer grants permissions (Bluetooth and often location/background, depending on platform)
  3. The app reports sightings to a server (with explicit consent and a privacy policy)

What beacons can and cannot do:

  • ✅ Enable proximity triggers (content, navigation, check-in) for opted-in users
  • ❌ Provide “exact location” on their own—RSSI is noisy and most deployments are zone-based

Privacy design tips:

  • Make consent explicit and revocable
  • Minimize identifiers; rotate IDs where feasible (e.g., ephemeral IDs)
  • Prefer aggregate analytics where possible instead of per-user tracking

Note: Other radio systems (Wi-Fi, cellular) can also be used for analytics, but OS privacy protections and regulations vary—design with transparency and consent either way.

25.6 Original Source Figures (Alternative Views)

The following figures from the CP IoT System Design Guide provide alternative perspectives on Bluetooth application concepts.

BLE architecture diagram highlighting key features for IoT applications such as low power consumption, fast connection setup (actual latency varies by configuration and platform), suitability for sensors/beacons with intermittent data transfer, and broad smartphone compatibility

BLE architecture for IoT applications

Source: CP IoT System Design Guide, Chapter 4 - Networking

Three Bluetooth power classes for application design: Class 1 at 100mW for industrial and long-range applications up to 100m, Class 2 at 2.5mW for mobile devices and wearables at 10m range, and Class 3 at 1mW for ultra-low-power proximity applications within 1m

Bluetooth power classes for application design

Source: CP IoT System Design Guide, Chapter 4 - Networking

Bluetooth operational modes for application power management: Active mode for real-time streaming, Sniff mode for periodic sensor updates, Hold mode for scheduled data bursts, and Park mode for devices maintaining network presence while conserving maximum power

Bluetooth modes for power management in applications

Source: CP IoT System Design Guide, Chapter 4 - Networking

Technology comparison table for IoT application selection: Bluetooth Classic for audio streaming, BLE for sensors and wearables, Zigbee for home automation mesh networks, and Wi-Fi for high-bandwidth connected devices requiring internet access

Wireless technology comparison for IoT applications

Source: CP IoT System Design Guide, Chapter 4 - Networking

Serial Port Profile (SPP) application showing wireless serial communication for embedded IoT devices: microcontrollers like Arduino or ESP32 connecting to smartphones or computers through virtual serial ports over Bluetooth for debugging, configuration, and data transfer

Bluetooth SPP for IoT device communication

Source: CP IoT System Design Guide, Chapter 4 - Networking

25.8 Worked Examples

Worked Example: Designing GATT Service Architecture for Environmental Monitoring Station

Scenario: An outdoor environmental monitoring station measures temperature, humidity, barometric pressure, UV index, and air quality (PM2.5). The device connects to a mobile app for configuration and real-time monitoring, and must support firmware updates over BLE (DFU).

Given:

  • Environmental Sensing Service UUID: 0x181A (Bluetooth SIG standard)
  • Custom Configuration Service UUID: f47ac10b-58cc-4372-a567-0e02b2c3d479
  • DFU Service UUID: 0xFE59 (Nordic standard)
  • Maximum MTU after negotiation: 247 bytes
  • Sensor sampling rate: configurable 1-60 seconds
  • Alert thresholds: user-configurable per measurement

Steps:

  1. Map measurements to standard characteristics where available:
    • Temperature: 0x2A6E (sint16, 0.01°C resolution)
    • Humidity: 0x2A6F (uint16, 0.01% resolution)
    • Pressure: 0x2A6D (uint32, 0.1 Pa resolution)
    • UV Index: 0x2A76 (uint8)
    • PM2.5: Custom characteristic (no SIG standard)
  2. Design GATT service hierarchy:
GATT service hierarchy diagram for environmental monitoring showing five services: Environmental Sensing with temperature, humidity, pressure, UV, and PM2.5 characteristics, plus Device Information, Battery, Configuration, and DFU services
Figure 25.8: GATT service hierarchy for environmental monitoring device showing five services with their characteristics and descriptors.
  1. Calculate notification payload sizes:
    • Combined sensor reading (all 5 values): 2+2+4+1+2 = 11 bytes
    • With ATT header (3 bytes): 14 bytes per notification
    • Fits easily in default 23-byte MTU
  2. Design batch mode for efficiency (optional):
    • Create aggregate characteristic combining all readings
    • Single notification instead of 5 separate ones
    • Reduces connection events by 80%

Result: GATT architecture uses 4 services with 16 characteristics. Standard UUIDs ensure compatibility with generic BLE scanner apps. Configuration service enables remote device management. DFU service supports field firmware updates. Aggregate characteristic option reduces power consumption for continuous monitoring.

Key Insight: Use Bluetooth SIG standard service and characteristic UUIDs (16-bit) whenever possible for interoperability. Reserve 128-bit custom UUIDs for application-specific data. Group related configuration parameters in a custom service separate from sensor data for cleaner architecture and access control.

Worked Example: iBeacon Deployment for Museum Indoor Navigation

Scenario: A museum deploys BLE beacons to provide audio guide triggers and indoor navigation. Visitors use the museum app to receive exhibit information when approaching displays. The system must distinguish between 200 exhibit locations across 3 floors with accurate “which exhibit am I near?” detection.

Given:

  • Beacon format: iBeacon
  • Proximity UUID: B9407F30-F5F8-466E-AFF9-25556B57FE6D
  • Major values: Floor numbers (1, 2, 3)
  • Minor values: Exhibit IDs (001-999)
  • TX power at 1m reference: -59 dBm (calibrated)
  • Desired proximity zones: Immediate (<1m), Near (1-3m), Far (3-10m)

Steps:

  1. Design beacon identifier scheme:

    • UUID: Single value for entire museum (identifies “this museum” vs others)
    • Major = Floor: 0x0001 (Floor 1), 0x0002 (Floor 2), 0x0003 (Floor 3)
    • Minor = Exhibit: 0x0001 (Exhibit 001) through 0x00C8 (Exhibit 200)
    • Example: Major=2, Minor=47 → Floor 2, Exhibit 47
  2. Calculate RSSI thresholds for proximity zones (using log-distance path loss model):

    RSSI = TxPower - 10 * n * log10(distance)
    
    Where n = 2.5 (typical indoor path loss exponent)
    TxPower = -59 dBm at 1 meter
    
    At 1m:  RSSI = -59 - 10*2.5*log10(1) = -59 dBm
    At 3m:  RSSI = -59 - 10*2.5*log10(3) = -71 dBm
    At 10m: RSSI = -59 - 10*2.5*log10(10) = -84 dBm
  3. Set zone thresholds with hysteresis:

    • Immediate: RSSI > -55 dBm (exit at -58 dBm)
    • Near: RSSI -55 to -73 dBm (exit Near at -76 dBm)
    • Far: RSSI -73 to -85 dBm
    • Out of range: RSSI < -85 dBm
  4. Implement smoothing algorithm in app:

    // Exponential moving average for RSSI smoothing
    smoothed_rssi = 0.7 * previous_smoothed + 0.3 * new_rssi
    
    // Require 3 consecutive readings in new zone before triggering
    if (consecutive_zone_readings >= 3) {
        trigger_zone_change(current_zone);
    }
  5. Plan beacon placement:

    • Mount beacons at consistent height (2.5m recommended)
    • Aim antenna downward toward visitor standing position
    • Space beacons 6-8m apart to minimize overlap
    • Place at exhibit center, not edges
  6. Configure advertising parameters:

    • Advertising interval: 350 ms (balance discovery vs battery)
    • TX power: 0 dBm (adequate for 10m range)
    • Expected battery life (CR2032): ~18 months

Result: 200 beacons deployed with systematic Major.Minor addressing. App triggers exhibit content when visitor enters “Near” zone (1-3m) with 3-reading confirmation. Hysteresis prevents zone flapping at boundaries. Smoothed RSSI provides stable proximity classification despite RF variability.

Key Insight: Never promise meter-level accuracy from RSSI alone—design for zone-based proximity (Immediate/Near/Far) rather than precise distances. The iBeacon Major.Minor hierarchy maps naturally to physical hierarchies (building.floor.room or floor.exhibit). Hysteresis and temporal filtering are essential for stable user experience despite RSSI fluctuations from body absorption and multipath.

25.9 Knowledge Check

25.10 Summary

This chapter covered Bluetooth applications across major IoT domains:

  • Healthcare: BLE enables continuous health monitoring (glucose, heart rate, SpO2) with standardized profiles for interoperability and regulatory considerations for medical devices
  • Smart Home: BLE powers locks, lighting, and thermostats, with Bluetooth Mesh extending coverage for building-scale automation through managed flooding and relay nodes
  • Wearables: Fitness trackers and smartwatches rely on BLE for low-power phone connectivity, with battery life determined by radio duty cycle, sensor usage, and display activity
  • Beacons: iBeacon and Eddystone standards enable proximity-based services without pairing; advertising interval and TX power trade off discovery latency against battery life
  • Industrial IoT: BLE retrofits existing equipment for vibration monitoring, temperature tracking, and predictive maintenance with gateway-based architectures
  • RSSI Limitations: Design for zone-based proximity (Immediate/Near/Far) rather than precise distances, using smoothing and hysteresis for stable user experience
  • GATT Architecture: Use standard Bluetooth SIG UUIDs where possible for interoperability, with custom UUIDs for application-specific data

25.10.1 Knowledge Check: BLE Application Architecture

25.10.2 Knowledge Check: Beacon Battery Optimization

25.10.3 Knowledge Check: RSSI and Proximity

Scenario: A retail chain needs to decide on a BLE technology for customer engagement across 50 stores. Each store is 2000 square meters with 20-30 departments.

Criteria iBeacon Eddystone BLE Mesh
Best For iOS-first retail apps Cross-platform web integration Connected product displays
Deployment Simple: place beacons, map UUIDs Simple: place beacons, configure URLs Complex: provision mesh, plan relays
Battery Life 2-3 years (1000ms interval) 2-3 years (1000ms interval) Months (relay duty) to years (endpoints)
App Requirements Native iOS app required Web browser integration (Physical Web) Native app with mesh support
Infrastructure None (beacons only) None (beacons only) Gateway bridges + backend
Use Cases Zone entry/exit triggers URL-based content delivery Interactive displays, stock sync
Beacon Density 1 per zone (30 beacons/store) 1 per zone (30 beacons/store) Higher density for mesh coverage
Cost per Store $750 (beacons only) $750 (beacons only) $2,500+ (mesh nodes + gateways)
Maintenance Battery replacement only Battery replacement only Firmware updates, network management
Privacy Good (app controls collection) Lower (broadcast URLs publicly) Good (encrypted mesh)

Decision Matrix:

  • Choose iBeacon if: iOS dominates your customer base (>60%), you have a native app, and you need simple zone-based triggers
  • Choose Eddystone if: You want browser-based engagement without requiring app installation, or need telemetry data from beacons
  • Choose BLE Mesh if: You need bidirectional control (e.g., changing digital signage content), device-to-device communication, or building-wide automation beyond proximity

Hybrid Approach: Many retailers use iBeacon/Eddystone for customer engagement (passive) and BLE Mesh for operational systems (active control of displays, lighting, sensors).

Common Pitfalls

Using a custom GATT service when a standard profile (e.g., Battery Service 0x180F, Environmental Sensing 0x181A) already exists causes interoperability failures. Always check the Bluetooth SIG adopted profiles list before designing custom services. Custom UUIDs should only be used for proprietary application logic that has no standard equivalent.

Using raw RSSI values directly for distance estimation in beacon applications leads to ±2–3 meter errors due to multipath reflections, body attenuation, and antenna orientation. Apply a Kalman filter or use the path-loss formula (d = 10^((TxPower - RSSI) / (10 * n))) with an empirically calibrated path-loss exponent n for each environment.

Multiple organizations deploying iBeacons in the same space with the same UUID causes receivers to confuse beacon identities. Each deployment must use a unique UUID (generated with uuidgen or an online tool), with Major/Minor values encoding location hierarchy (e.g., Major=building floor, Minor=room number).

Attempting to stream audio over BLE using GATT notifications results in choppy playback due to BLE’s variable latency and limited throughput. Classic Bluetooth A2DP (up to 328 kbps with SBC codec) or BLE LE Audio (Bluetooth 5.2+ with LC3 codec) must be used for continuous audio applications.

25.11 What’s Next

In the next chapter, Bluetooth Comprehensive Review, we’ll synthesize all Bluetooth concepts with quiz questions, protocol stack deep-dives, and troubleshooting guidance for real-world deployments.

Chapter Focus Why Read It
Bluetooth Comprehensive Review Full BLE protocol stack synthesis and troubleshooting Consolidate everything from architecture through applications into a single reference
Bluetooth Security Pairing modes, encryption, and attack mitigations Essential before deploying healthcare or access-control BLE products
Bluetooth Implementations and Labs Hands-on ESP32 and nRF52 BLE development Translate the application patterns from this chapter into working firmware
Bluetooth Fundamentals and Architecture GATT, GAP, ATT, and BLE protocol stack internals Deepen your understanding of the stack underpinning all the applications covered here
Wi-Fi IoT Implementations Wi-Fi application patterns for IoT Compare BLE against Wi-Fi to choose the right radio for your use case
Zigbee Hands-On and Future Zigbee mesh applications and comparisons Evaluate Zigbee mesh as an alternative to Bluetooth Mesh for building automation

Key Takeaways:

  • BLE beacons enable passive proximity experiences without pairing (phones scan advertising packets)
  • iBeacon vs Eddystone is usually a platform/feature choice (UID/URL/ephemeral IDs, app ecosystem, backend mapping)
  • Advertising interval and TX power trade off discovery latency against battery life
  • Bluetooth Mesh suits multi-hop active control (lighting/HVAC) while beacons suit passive proximity context
  • Real deployments benefit from site surveys, calibration, and clear privacy/consent design