33  Zigbee Review: Worked Examples

In 60 Seconds

Practice Zigbee engineering with five worked examples: warehouse mesh coverage calculation (router count and placement), AODV route discovery step-by-step, power budget analysis for 3-year battery life, group messaging efficiency comparison (unicast vs. multicast), and security key distribution during network formation. Each example includes detailed calculations, diagrams, and key insights for real-world application.

33.1 Learning Objectives

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

  • Calculate Mesh Coverage: Determine router count and placement for warehouse deployments using coverage area formulas and redundancy factors
  • Analyze Route Recovery: Trace AODV protocol timing step-by-step during router failures and predict recovery duration
  • Select Optimal Zigbee Channels: Apply frequency mapping to avoid Wi-Fi interference in congested 2.4 GHz environments
  • Design Multi-Endpoint Devices: Configure power strips with individual outlet control using ZCL clusters and endpoint architecture
  • Diagnose Binding Failures: Evaluate address cache staleness as a root cause and justify group-based binding as the solution

These worked examples walk through complete Zigbee network designs for real scenarios – smart homes, commercial buildings, and industrial facilities. Each example shows the thought process behind choosing device types, network topology, and configuration. Following along builds your ability to design Zigbee solutions independently.

33.2 Prerequisites

Required Chapters:

Technical Background:

  • Zigbee device types and roles
  • AODV routing protocol
  • Zigbee Cluster Library (ZCL)

Estimated Time: 35 minutes

33.3 Worked Example 1: Calculate Zigbee Mesh Network Coverage

Scenario: You are planning a Zigbee network for a warehouse facility. The warehouse is 100m x 50m (5,000 sqm) with metal shelving units creating partial obstructions. You need to ensure reliable mesh coverage for inventory tracking sensors.

Given:

  • Warehouse dimensions: 100m x 50m (5,000 sqm)
  • Ceiling height: 8m (sensors at 2m height, potential for ceiling-mounted routers)
  • Environment: Industrial with metal shelving (path loss exponent n = 3.5)
  • Zigbee indoor range (ideal): 10-30m
  • Effective range with obstructions: 10-15m between routers
  • Requirement: Every point within 10m of a router for 99% reliability
  • Sensors needed: 200 battery-powered inventory tags

Solution:

Step 1: Calculate Coverage Area per Router

With effective range of 10m and requirement for overlap: \[\text{Coverage radius} = 10\text{m}\] \[\text{Coverage area per router} = \pi r^2 = \pi \times 10^2 = 314 \text{ sqm}\]

With 30% overlap for redundancy: \[\text{Effective coverage} = 314 \times 0.7 = 220 \text{ sqm per router}\]

Step 2: Calculate Minimum Router Count

\[\text{Minimum routers} = \frac{\text{Total area}}{\text{Effective coverage}} = \frac{5000}{220} = 22.7 \approx 23 \text{ routers}\]

Step 3: Design Grid Layout

For a 100m x 50m space with 10m coverage:

Routers along 100m dimension: 100m / 15m spacing = 7 routers
Routers along 50m dimension: 50m / 15m spacing = 4 routers
Grid total: 7 x 4 = 28 routers

Using 15m spacing provides overlap since each router covers 10m radius.

Step 4: Apply Redundancy Factor

For industrial environment (metal interference, forklift movement): \[\text{Recommended routers} = \text{Grid total} \times 1.3 = 28 \times 1.3 = 36 \text{ routers}\]

Round to practical number: 36 routers (9 x 4 grid with extras at key points)

Step 5: Verify Mesh Connectivity

Metric Value Status
Router spacing 15m Within 10m overlap range
Paths to coordinator 2-4 per router Redundant
Max hops to coordinator 5-6 Within Zigbee limit (30)
Coverage redundancy 1.6x minimum Good

Step 6: Calculate Total Device Count

Coordinator:     1 (central location)
Routers:         36 (mains-powered, ceiling-mounted)
End Devices:     200 (battery-powered sensors)
Total:           237 devices
Network capacity: 65,000 (using 0.4%)

Step 7: Estimate Battery Life for Sensors

Assuming sensors report every 10 minutes: \[\text{Reports per day} = \frac{24 \times 60}{10} = 144 \text{ transmissions}\] \[\text{Energy per transmission} \approx 0.15 \text{ mJ}\] \[\text{Daily energy} = 144 \times 0.15 = 21.6 \text{ mJ}\] \[\text{Average quiescent draw} \approx 6 \mu\text{A} \times 24\text{h} = 0.144 \text{ mAh/day}\]

(The 6 µA average accounts for 2 µA deep sleep plus periodic polling and MAC duty cycling overhead.)

With CR2450 battery (620 mAh): \[\text{Battery life} \approx \frac{620}{0.144 + 0.02} \approx 3,780 \text{ days} = 10.4 \text{ years}\]

Warehouse sensor battery life calculations must account for both active transmission energy and sleep current to optimize deployment costs.

\[\text{Total Daily Energy (mAh)} = \frac{N_{\text{tx}} \times I_{\text{tx}} \times T_{\text{tx}}}{3600} + I_{\text{sleep}} \times 24\]

Worked example: For 200 inventory sensors reporting every 10 minutes: - Transmissions/day: 144 - TX current: 30 mA for 10ms → 144 × 30 × 0.01 / 3600 = 0.012 mAh/day - Sleep current: 2 µA × 24h = 0.048 mAh/day - Total: 0.06 mAh/day (TX + sleep)

Note: The main text above uses a simplified model with 0.144 mAh/day sleep current (accounting for periodic polling overhead beyond pure sleep), yielding ~10.4 years. This PNtI calculation uses pure 2 µA sleep current, yielding a theoretical maximum:

Battery life (CR2450, 620 mAh): 620 / 0.06 = 10,333 days (~28 years theoretical)

In practice, factors such as polling overhead, MAC retries, and self-discharge reduce real-world battery life to 5-10 years.

For 200 sensors × $15/sensor = $3,000 investment, avoiding 5-year battery replacements saves $1,200 in labor, justifying higher-quality sensors with 2 µA sleep current versus 10 µA alternatives.

Result: The warehouse requires 36 routers in a 9x4 grid pattern with 15m spacing, plus 1 coordinator and 200 end device sensors. Total cost estimate:

Component Quantity Unit Cost Total
Coordinator 1 $50 $50
Routers (smart plugs) 36 $25 $900
Sensor tags 200 $15 $3,000
Total 237 - $3,950

Key Insight: In industrial environments, use 1.3-1.5x the minimum router count for reliability. The mesh topology ensures that even if 2-3 routers fail (power outage, damage), the network self-heals via alternate paths. Place routers at ceiling level to avoid obstruction by shelving and forklifts. Budget 30% extra capacity for future sensor additions.

33.3.1 Interactive: Mesh Coverage Calculator

33.4 Worked Example 2: Zigbee Mesh Route Recovery After Router Failure

Scenario: A smart home Zigbee network has 45 devices across a two-story house. Router R4 (a smart plug in the hallway) suddenly loses power, breaking the primary route from the coordinator to 8 end devices in the upstairs bedrooms.

Given:

  • Network: PAN ID 0x1A2B, Channel 15 (2425 MHz)
  • Coordinator at Node 0x0000 (ground floor living room)
  • Failed router R4 at Node 0x0012, previously routing to:
    • 3 door sensors (0x0045, 0x0046, 0x0047)
    • 2 temperature sensors (0x0048, 0x0049)
    • 3 motion detectors (0x004A, 0x004B, 0x004C)
  • Alternate routers available: R2 (0x0008) and R5 (0x0015)
  • AODV route timeout: 3000ms
  • MAC ACK timeout: 54ms (with 3 retries)

Steps:

  1. Failure Detection (0-162ms):
    • End device 0x0045 sends status update to R4
    • MAC layer waits 54ms for ACK (no response)
    • Retries 3 times: 54ms x 3 = 162ms total
    • After 3 failed attempts, MAC declares link failure
  2. Route Error Propagation (162-200ms):
    • Node 0x0045 generates RERR (Route Error) frame
    • RERR broadcast to all neighbors: “Route via 0x0012 invalid”
    • RERR format: Frame Control | Dest=0xFFFF | Error Code=0x01 | Failed Node=0x0012
  3. Route Request Initiation (200-250ms):
    • Node 0x0045 broadcasts RREQ (Route Request)
    • RREQ: Src=0x0045 | Dest=0x0000 | Hop Count=0 | Sequence=42
    • Neighboring routers R2 and R5 receive RREQ
  4. Route Discovery Flooding (250-400ms):
    • R2 (0x0008) receives RREQ, increments hop count to 1
    • R2 rebroadcasts: Src=0x0045 | Dest=0x0000 | Hop=1 | Via=0x0008
    • R5 (0x0015) also rebroadcasts with its path
    • Coordinator receives multiple RREQs via different paths
  5. Route Reply Selection (400-500ms):
    • Coordinator selects shortest path: 0x0045 -> 0x0008 -> 0x0000 (2 hops)
    • Generates RREP: Src=0x0000 | Dest=0x0045 | Hop Count=2 | Path Quality=0xC5
    • RREP unicast back along discovered path
  6. Route Table Update (500-550ms):
    • Node 0x0045 receives RREP, updates routing table
    • New entry: Dest=0x0000, NextHop=0x0008, HopCount=2, Status=ACTIVE
    • Old entry via 0x0012 marked INVALID

Result: Total recovery time = 550ms. The affected end devices automatically discover alternate routes through R2 and R5. Network resumes normal operation with no user intervention. The 8 affected devices now route through:

  • Devices 0x0045, 0x0046, 0x0047, 0x0048 -> R2 (0x0008) -> Coordinator
  • Devices 0x0049, 0x004A, 0x004B, 0x004C -> R5 (0x0015) -> Coordinator

Key Insight: Zigbee’s AODV routing protocol provides sub-second self-healing (typically 200-800ms) without requiring a centralized controller. The critical factors for fast recovery are router density (providing alternate paths) and MAC-layer failure detection (fast ACK timeouts). Networks should maintain at least 2-3x minimum router count for reliable self-healing. Battery-powered end devices experience brief communication interruption but no data loss due to application-layer retries.

33.5 Worked Example 3: Zigbee Channel Selection for Wi-Fi Coexistence

Scenario: A new Zigbee smart home network is being deployed in an apartment building with heavy Wi-Fi congestion. A site survey reveals active Wi-Fi networks on channels 1, 6, and 11, plus a neighbor’s legacy 40MHz-wide Wi-Fi on channel 3.

Given:

  • Zigbee operates on IEEE 802.15.4 channels 11-26 (2405-2480 MHz)
  • Each Zigbee channel is 2 MHz wide with 5 MHz center spacing
  • Wi-Fi channel 1 center: 2412 MHz (spans 2401-2423 MHz at 20 MHz)
  • Wi-Fi channel 6 center: 2437 MHz (spans 2426-2448 MHz at 20 MHz)
  • Wi-Fi channel 11 center: 2462 MHz (spans 2451-2473 MHz at 20 MHz)
  • Neighbor’s 40MHz Wi-Fi on channel 3: 2422 MHz center (spans 2402-2442 MHz)
  • Required interference margin: 2 MHz minimum separation

Steps:

  1. Map Zigbee Channels to Frequencies:

    Channel 11: 2405 MHz    Channel 19: 2445 MHz
    Channel 12: 2410 MHz    Channel 20: 2450 MHz
    Channel 13: 2415 MHz    Channel 21: 2455 MHz
    Channel 14: 2420 MHz    Channel 22: 2460 MHz
    Channel 15: 2425 MHz    Channel 23: 2465 MHz
    Channel 16: 2430 MHz    Channel 24: 2470 MHz
    Channel 17: 2435 MHz    Channel 25: 2475 MHz
    Channel 18: 2440 MHz    Channel 26: 2480 MHz
  2. Identify Wi-Fi Interference Zones:

    • Wi-Fi Ch 1 (20MHz): 2401-2423 MHz -> Blocks Zigbee 11-14
    • Wi-Fi Ch 6 (20MHz): 2426-2448 MHz -> Blocks Zigbee 15-19
    • Wi-Fi Ch 11 (20MHz): 2451-2473 MHz -> Blocks Zigbee 20-24
    • Neighbor 40MHz Ch 3: 2402-2442 MHz -> Blocks Zigbee 11-18
  3. Calculate Available Channels:

    • Channels 11-14: BLOCKED (Wi-Fi 1 + neighbor 40MHz)
    • Channels 15-18: BLOCKED (neighbor 40MHz + Wi-Fi 6)
    • Channels 19: MARGINAL (2445 MHz, edge of Wi-Fi 6)
    • Channels 20-24: BLOCKED (Wi-Fi 11)
    • Channels 25-26: CLEAR (2475-2480 MHz, above all Wi-Fi)
  4. Verify Channel 25 Clearance:

    • Channel 25 center: 2475 MHz
    • Nearest Wi-Fi (channel 11) upper edge: 2473 MHz
    • Separation: 2475 - 2473 = 2 MHz (meets minimum margin)
    • No microwave oven interference (peak at 2450 MHz)
  5. Configure Network:

    PAN ID: 0x3C4D (unique to avoid conflicts)
    Channel: 25 (2475 MHz)
    Extended PAN ID: 0x0123456789ABCDEF
    Network Key: [128-bit AES key]
    TX Power: 0 dBm (default, reduces interference)

Result: Channel 25 selected as optimal. Expected performance:

  • Packet Error Rate (PER): <1% (vs 15-30% on congested channels)
  • Throughput: 240 kbps effective (vs <100 kbps with interference)
  • Latency: <50ms round-trip (vs 200-500ms with retries)

Key Insight: Zigbee channels 25 and 26 are the safest choices in most environments because they sit above the commonly used Wi-Fi channels. The trade-off is slightly reduced range at higher frequencies (inverse square law), but in a typical apartment (<100m max distance), this is negligible. Always perform a Wi-Fi site survey before Zigbee deployment - the 2.4 GHz band is increasingly congested. For severely congested environments, consider Thread or Z-Wave which can operate on less crowded spectrum.

33.6 Worked Example 4: Configuring Multi-Endpoint Device with Multiple Clusters

Scenario: You are designing a Zigbee 3.0 smart power strip with 4 individually controllable outlets, each with energy monitoring. The device must appear as a single network node but allow independent control of each outlet from any Zigbee 3.0 hub.

Given:

  • Device: 4-outlet smart power strip (mains-powered, Router capable)
  • Network Address: 0x0055 (assigned by Coordinator)
  • IEEE Address: 0x00124B00CAFE1234
  • Profile: Zigbee 3.0 Home Automation (0x0104)
  • Requirements: Independent on/off, individual energy metering, total power limiting

Steps:

  1. Design Endpoint Architecture:

    Endpoint Assignment:
    - Endpoint 1: Outlet 1 (top-left)
    - Endpoint 2: Outlet 2 (top-right)
    - Endpoint 3: Outlet 3 (bottom-left)
    - Endpoint 4: Outlet 4 (bottom-right)
    - Endpoint 242: Green Power Proxy (required for Zigbee 3.0)
    
    Why multiple endpoints?
    - Single network address (0x0055) saves address space
    - Each outlet independently addressable via endpoint number
    - Hub can control Outlet 2 without affecting others
    - Binding works per-endpoint (switch A -> Outlet 1 only)
  2. Configure Endpoint 1 (Outlet 1) Clusters:

    Simple Descriptor for Endpoint 1:
    - Endpoint: 1
    - Profile ID: 0x0104 (Zigbee HA)
    - Device ID: 0x0051 (Smart Plug)
    - Device Version: 1
    
    Server Clusters (Outlet provides):
    - Basic (0x0000):
      - Attribute 0x0004: ManufacturerName = "SmartStrip Inc"
      - Attribute 0x0005: ModelIdentifier = "SS-4P-ZB"
      - Attribute 0x0007: PowerSource = 0x01 (Mains)
    
    - Identify (0x0003):
      - Attribute 0x0000: IdentifyTime = 0 (seconds)
      - Command: Identify (blink LED)
    
    - On/Off (0x0006):
      - Attribute 0x0000: OnOff = 0x00 (Off) or 0x01 (On)
      - Commands: Off (0x00), On (0x01), Toggle (0x02)
    
    - Electrical Measurement (0x0B04):
      - Attribute 0x0505: RMSVoltage = 1200 (120.0V)
      - Attribute 0x0508: RMSCurrent = 85 (0.85A)
      - Attribute 0x050B: ActivePower = 102 (102W)
      - Attribute 0x0600: ACVoltageMultiplier = 1
      - Attribute 0x0601: ACVoltageDivisor = 10
    
    - Metering (0x0702):
      - Attribute 0x0000: CurrentSummationDelivered = 15234 (15.234 kWh)
      - Attribute 0x0300: UnitOfMeasure = 0x00 (kWh)
      - Attribute 0x0301: Multiplier = 1
      - Attribute 0x0302: Divisor = 1000
    
    Client Clusters: None (outlet doesn't send commands)
  3. Replicate Configuration for Endpoints 2-4:

    Each endpoint has identical cluster configuration:
    
    | Endpoint | Device ID | On/Off | Power | Energy |
    |----------|-----------|--------|-------|--------|
    | 1 | 0x0051 | Independent | Outlet 1 | Outlet 1 |
    | 2 | 0x0051 | Independent | Outlet 2 | Outlet 2 |
    | 3 | 0x0051 | Independent | Outlet 3 | Outlet 3 |
    | 4 | 0x0051 | Independent | Outlet 4 | Outlet 4 |
    
    Hardware Mapping:
    - Endpoint 1 -> GPIO Relay 1, CT Sensor 1
    - Endpoint 2 -> GPIO Relay 2, CT Sensor 2
    - Endpoint 3 -> GPIO Relay 3, CT Sensor 3
    - Endpoint 4 -> GPIO Relay 4, CT Sensor 4
  4. Handle Active Endpoints Discovery:

    ZDO: Active_EP_req to 0x0055
    
    Response: Active_EP_rsp
    - Status: SUCCESS
    - NWKAddrOfInterest: 0x0055
    - ActiveEPCount: 5
    - ActiveEPList: [1, 2, 3, 4, 242]
    
    Hub receives list, queries each endpoint's Simple Descriptor
    to discover device types and supported clusters.
  5. Process Independent Control Commands:

    Scenario: Turn on Outlet 2 only
    
    Hub sends ZCL command:
    - Destination: 0x0055 (network address)
    - Destination Endpoint: 2 (Outlet 2 specifically)
    - Cluster: 0x0006 (On/Off)
    - Command: 0x01 (On)
    
    Device firmware routes to Endpoint 2 handler:
    on_zcl_command(endpoint=2, cluster=0x0006, cmd=0x01):
        set_relay(outlet=2, state=ON)
        update_attribute(ep=2, cluster=0x0006, attr=0x0000, value=0x01)
        send_default_response(status=SUCCESS)
    
    Result: Only Outlet 2 turns on; Outlets 1, 3, 4 unchanged
  6. Report Total Device Power:

    Application requirement: Total power across all outlets
    
    Option A: Hub sums individual outlet readings
    - Read ActivePower from endpoints 1, 2, 3, 4
    - Calculate total in hub software
    
    Option B: Device reports aggregate (custom cluster or attribute)
    - Add Endpoint 0 (ZDO) or dedicated Endpoint 5
    - Electrical Measurement cluster with summed values
    - Not standard but useful for display
    
    Recommended: Option A (standards-compliant)
    Hub polling sequence:
    1. Read 0x0055/EP1/Cluster 0x0B04/Attr 0x050B -> 102W
    2. Read 0x0055/EP2/Cluster 0x0B04/Attr 0x050B -> 0W
    3. Read 0x0055/EP3/Cluster 0x0B04/Attr 0x050B -> 45W
    4. Read 0x0055/EP4/Cluster 0x0B04/Attr 0x050B -> 200W
    Total: 347W
  7. Configure Attribute Reporting:

    Enable automatic energy reporting to hub:
    
    Configure Reporting Command (per endpoint):
    - Cluster: 0x0B04 (Electrical Measurement)
    - Attribute: 0x050B (ActivePower)
    - Data Type: 0x29 (signed 16-bit)
    - Min Interval: 10 seconds
    - Max Interval: 300 seconds (5 minutes)
    - Reportable Change: 5 (5W threshold)
    
    Result: Each outlet reports power changes automatically
    when delta > 5W or every 5 minutes (whichever comes first)

Result: The 4-outlet power strip appears as one Zigbee device (address 0x0055) with 4 independent endpoints. Each outlet can be controlled, monitored, and bound separately while sharing a single network address.

Endpoint Purpose Key Clusters Attributes
1 Outlet 1 On/Off, Metering, ElecMeas Power, Energy
2 Outlet 2 On/Off, Metering, ElecMeas Power, Energy
3 Outlet 3 On/Off, Metering, ElecMeas Power, Energy
4 Outlet 4 On/Off, Metering, ElecMeas Power, Energy
242 Green Power GP Proxy (Zigbee 3.0 req)

Key Insight: Zigbee’s endpoint architecture enables multi-function devices on a single network address. Each endpoint is like a “virtual device” with its own cluster configuration, bindings, and group memberships. This design conserves the 65,534-address network space while supporting complex devices like power strips, multi-gang switches, or sensor hubs. When designing multi-endpoint devices, ensure each endpoint has the complete cluster set required by Zigbee certification (Basic, Identify, plus device-specific clusters). Hubs discover capabilities via Active Endpoints and Simple Descriptor queries.

33.7 Worked Example 5: Troubleshooting Intermittent Device Binding Failures

Scenario: A smart home installation has a Zigbee wall switch (0x0022) that should directly control a ceiling light (0x0038) via binding. The binding was created successfully, but the light only responds to the switch about 70% of the time. The remaining 30% of button presses are ignored.

Given:

  • Wall Switch: Address 0x0022, Endpoint 1, IEEE 0x00158D0001234567
  • Ceiling Light: Address 0x0038, Endpoint 1, IEEE 0x00158D0009876543
  • Coordinator: Address 0x0000
  • Network: PAN ID 0x5A5A, Channel 20
  • Binding: Switch EP1 On/Off cluster -> Light IEEE address EP1
  • Symptom: 30% command failures, no error messages in hub log
  • Distance: Switch and light are 8 meters apart (within range)

Steps:

  1. Verify Binding Table Entry:

    ZDO: Mgmt_Bind_req to Switch 0x0022
    
    Response - Binding Table:
    +-------+----------+--------+---------+--------------------+--------+
    | Index | Cluster  | SrcEP  | DstType | Destination        | DstEP  |
    +-------+----------+--------+---------+--------------------+--------+
    | 0     | 0x0006   | 1      | IEEE    | 0x00158D0009876543 | 1      |
    +-------+----------+--------+---------+--------------------+--------+
    
    Status: Binding exists and is correctly configured
    Problem is NOT missing binding
  2. Check Network Address Resolution:

    Issue identified: Binding uses IEEE (64-bit) address
    
    When switch sends command:
    1. APS layer looks up binding -> finds IEEE address
    2. APS must resolve IEEE -> 16-bit network address
    3. If address cache is stale, resolution fails
    
    Diagnosis query:
    ZDO: NWK_Addr_req for 0x00158D0009876543
    
    Response timing:
    - Cache hit: 0-5ms (immediate send)
    - Cache miss: 50-200ms (broadcast query, wait for response)
    - Cache stale: Light may have different address after rejoin
    
    Check light's current address:
    Hub -> Light: ZDO IEEE_Addr_req
    Response: IEEE=0x00158D0009876543, NWKAddr=0x0038 (correct)
    
    Light's address hasn't changed, but switch's cache may be stale
  3. Analyze Packet Capture:

    Sniff Zigbee traffic during button press:
    
    Successful sequence (70% of presses):
    T=0ms:  Switch button interrupt
    T=5ms:  APS lookup binding -> IEEE address
    T=6ms:  Address cache HIT -> NWK 0x0038
    T=10ms: ZCL On/Off Toggle sent to 0x0038
    T=25ms: Light ACK received
    T=30ms: Light turns on/off
    
    Failed sequence (30% of presses):
    T=0ms:  Switch button interrupt
    T=5ms:  APS lookup binding -> IEEE address
    T=6ms:  Address cache MISS or STALE
    T=10ms: NWK_Addr_req broadcast (resolving address)
    T=50ms: No response (light busy, missed broadcast)
    T=100ms: Retry NWK_Addr_req
    T=150ms: No response (timeout)
    T=200ms: APS gives up, command dropped
    
    Root cause: Address resolution timeouts
  4. Investigate Address Cache Staleness:

    Why is address cache unreliable?
    
    Possible causes:
    A. Light rejoined network (got new address) - UNLIKELY
       - Light address still 0x0038
    
    B. Switch rebooted (cache cleared) - PARTIAL
       - Switch is mains-powered, rare reboots
       - But explains some failures after power flickers
    
    C. Cache entry expired (timeout) - LIKELY
       - Default cache timeout: 3-5 minutes on some stacks
       - If light doesn't communicate for 5+ minutes,
         cache entry expires
       - Next button press must re-resolve address
    
    D. Limited cache size - POSSIBLE
       - Switch may only cache 5-10 addresses
       - If other devices added, light entry evicted
    
    Investigation: Check switch's cache settings
    Vendor documentation: Cache size = 8 entries, timeout = 180s
  5. Identify Contributing Factor - Traffic Pattern:

    Network traffic analysis:
    
    Light communication pattern:
    - No periodic reporting configured
    - Light only communicates when controlled
    - Typical usage: 4-6 times per day
    
    Gap between commands: 2-4 hours average
    
    Cache timeout: 180 seconds (3 minutes)
    
    Timeline:
    T=0:        User presses switch -> light responds
    T=0+10ms:   Switch caches light's address (0x0038)
    T+3min:     Cache entry expires (no light traffic)
    T+2hr:      User presses switch again
               -> Cache MISS
               -> Address resolution required
               -> 30% failure rate during resolution
    
    Correlation: Failures occur after long idle periods
  6. Implement Solution - Use Network Address Binding:

    Solution: Change binding from IEEE to Group addressing
    
    Why?
    - Group addresses don't require resolution
    - Multicast is more reliable than unicast+resolution
    - No cache staleness issues
    
    Implementation:
    1. Create group for the light:
       ZCL: Add Group (0x000F) to Light 0x0038/EP1
    
    2. Update binding on switch:
       Delete old binding:
       ZDO: Unbind_req(0x0022, EP1, 0x0006, IEEE, 0x00158D0009876543)
    
       Create new binding:
       ZDO: Bind_req(0x0022, EP1, 0x0006, GROUP, 0x000F)
    
    3. Test button press:
       - Switch sends to Group 0x000F (no address resolution)
       - Light receives multicast immediately
       - 100% reliability achieved
    
    Binding table after fix:
    +-------+----------+--------+---------+-------------+
    | Index | Cluster  | SrcEP  | DstType | Destination |
    +-------+----------+--------+---------+-------------+
    | 0     | 0x0006   | 1      | Group   | 0x000F      |
    +-------+----------+--------+---------+-------------+
  7. Alternative Solution - Periodic Keep-Alive:

    If group binding isn't desired (e.g., one-to-one control only):
    
    Configure light to report periodically:
    ZCL: Configure Reporting
    - Cluster: 0x0006 (On/Off)
    - Attribute: 0x0000 (OnOff)
    - Min Interval: 60 seconds
    - Max Interval: 120 seconds
    - Reportable Change: N/A (discrete attribute)
    
    Result:
    - Light sends OnOff status every 60-120 seconds
    - Switch receives reports, refreshes address cache
    - Cache never expires, address always resolved
    - Slight increase in network traffic (1 packet/minute)

Result: The intermittent binding failure was caused by address cache expiration on the switch. After changing from IEEE-based binding to group-based binding, command reliability improved from 70% to 100%.

Binding Type Address Resolution Cache Dependency Reliability
IEEE (64-bit) Required at runtime High (cache expires) 70-90%
Network (16-bit) Required at bind time Medium (address change) 85-95%
Group None (multicast) None 99%+

Key Insight: Zigbee bindings using 64-bit IEEE addresses require runtime address resolution via NWK_Addr_req broadcasts. On resource-constrained devices with small address caches, stale entries cause intermittent failures. For reliable direct device-to-device control, prefer group-based bindings which use multicast (no address resolution needed). If IEEE bindings are required, configure attribute reporting on the target device to keep the source device’s address cache populated. This is a common issue in Zigbee deployments where devices have long idle periods between interactions.

Sammy the Sensor is learning by example: “These worked examples show me exactly how engineers solve real Zigbee problems!”

Max the Microcontroller walks through the first example: “For a 5,000 sqm warehouse, we calculate that each Router covers about 314 sqm (circle with 10m radius, minus 30% overlap). That means we need at least 24 Routers, but we add 30% redundancy for a total of 36. It’s like making sure every spot in the warehouse can talk to at least two Routers.”

Lila the LED adds: “The binding example is fascinating! When a wall switch is bound directly to a ceiling light, commands travel in just 25ms instead of 100ms through the Coordinator. But if the address cache gets stale, 30% of commands fail. The fix? Use group-based bindings – multicast never needs address resolution!”

Bella the Battery explains power: “The battery calculation shows that with 3µA sleep current and 5-minute reporting intervals, a 3000mAh battery lasts over 4 years. But change reporting to every 10 seconds and you’re down to months. The reporting interval is everything!”

Key ideas for kids:

  • Coverage calculation = Math to figure out how many Routers you need
  • Route recovery = How fast the network fixes itself when a Router fails (~550ms)
  • Address cache = A device’s memory of other devices’ addresses (can get outdated)
  • Group binding = Sending commands to a group name instead of a specific address
Common Mistake: Ignoring IEEE 802.15.4 MAC Layer Retry Limits

The Problem: A developer configures Zigbee application-layer retries to 5 attempts, expecting 5 full end-to-end message retransmissions. In production, messages still fail after only 3 attempts, causing intermittent control failures for critical lighting commands.

Why It Happens:

Zigbee has two separate retry mechanisms operating at different layers:

  1. MAC Layer Retries (IEEE 802.15.4):
    • Automatic retransmission for each hop
    • Default: 3 retries per link
    • Timeout: ~50ms per retry
    • Total per-hop budget: ~150-200ms
  2. Application Layer Retries (APS):
    • End-to-end retransmission of entire multi-hop path
    • Default: Configurable (often 3)
    • Timeout: ~500ms per attempt

The Confusion: Developers assume application retries = total attempts, but reality is:

  • Each application retry traverses the full multi-hop path
  • Each hop in the path has its own 3 MAC retries
  • If a 3-hop path has 1 weak link, that link burns through all 3 MAC retries
  • Application sees 1 failure, but the network sent ~10 packets (original + 3×3 MAC retries)

Real Example:

Command: Coordinator → Router A (weak LQI) → Router B → Light

Sequence: 1. App Attempt 1: - Coordinator → Router A: Success (1st MAC try) - Router A → Router B: Fail, retry, fail, retry, fail (3 MAC tries exhausted) - Application layer sees “delivery failed” after 150ms

  1. App Attempt 2:
    • Same path, Router A→B link still weak
    • 3 more MAC retries exhausted
    • Application layer sees “delivery failed” after 300ms
  2. App Attempt 3:
    • Final application retry
    • 3 more MAC retries exhausted
    • Light finally responds (or application gives up)
    • Total packets sent: 1 + 3 + 3 + 3 = 10 packets for 1 command

The Fix:

  1. Don’t Over-Retry: Application retries beyond 3 rarely help if the MAC layer can’t deliver. Fix the RF link instead (add routers, reposition devices).

  2. Monitor MAC-Layer Failures:

    // Read MAC retry count after transmission
    uint8_t macRetries = getLastMACRetryCount();
    if (macRetries > 2) {
      // Link is weak, trigger route rediscovery or alert
    }
  3. Use Alternate Paths: If MAC retries are consistently high, force route discovery to find better paths:

    if (consecutiveMACRetries > 5) {
      invalidateRoute(destination);
      sendRouteRequest(destination);
    }
  4. Set Realistic Timeouts: Application-layer timeout must account for multi-hop MAC retries:

    Timeout = (Hop Count) × (MAC Retry Time) × (App Retries) + Routing Overhead
    Example: 3 hops × 200ms × 3 app retries + 500ms = 2.3 seconds minimum

Key Numbers:

Metric Value Why It Matters
MAC retry limit 3 Cannot be exceeded per IEEE 802.15.4 spec
MAC retry timeout ~50ms Adds 150ms per weak hop
Max hops 30 (Zigbee), 5-7 practical Each hop multiplies retry impact
Application timeout 2-5 seconds Must account for worst-case multi-hop retries

Key Insight: Zigbee’s layered retry architecture means you can’t brute-force reliability by increasing application retries. If a link is weak, the MAC layer burns through retries quickly, and no amount of application-layer retries will help. Focus on network topology (add routers, improve placement) instead of retry counts. A well-designed mesh with good LQI (>150) rarely needs more than 1 application retry.

Common Pitfalls

Zigbee network design errors discovered during deployment are expensive to fix — require rework of device placement, channel selection, and coordinator configuration. Invest time in design review before physical deployment.

Without documented rationale for channel selection, router placement, and security configuration choices, network maintenance becomes difficult when the original designer is unavailable.

Worked examples solve specific scenarios. Directly copying a worked example design to a different application without adapting for different traffic patterns, device counts, and RF environments leads to underperforming deployments.

33.8 Summary

This chapter covered five detailed Zigbee worked examples:

  1. Mesh Coverage Calculation: 36 routers for 5,000 sqm warehouse with 1.3x redundancy factor
  2. Route Recovery Timing: AODV self-healing completes in ~550ms after router failure
  3. Channel Selection: Channels 25-26 optimal for Wi-Fi congested environments
  4. Multi-Endpoint Design: 4-outlet power strip with independent control via separate endpoints
  5. Binding Troubleshooting: Address cache staleness fixed with group-based bindings

Key Formulas:

  • Coverage area per router: \(\pi r^2 \times 0.7\) (with 30% overlap)
  • Battery life: \(\frac{\text{Capacity (mAh)}}{\text{Daily drain (mAh/day)}}\)
  • Recovery time: MAC ACK timeout + AODV discovery (~140-800ms)

33.9 Knowledge Check

::

::

Key Concepts

  • Design Review: A systematic evaluation of a Zigbee network design checking topology, channel selection, security configuration, and performance expectations before deployment.
  • Worked Example Analysis: The process of examining a complete design solution to understand the reasoning behind decisions and identify alternative approaches.
  • Network Commissioning Plan: A documented procedure for sequentially commissioning devices into a Zigbee network, including order of joining, security configuration, and binding setup.
  • Performance Validation: Post-deployment testing verifying that a Zigbee network meets its design requirements for latency, packet delivery ratio, and battery life.

33.10 Concept Relationships

Concept Related To How They Connect
Coverage Calculation Router Placement Math-based approach determines minimum router count for area
AODV Route Recovery Self-Healing Timing ~550ms recovery time from failure detection to new route
Channel Selection Interference Mitigation Channels 25-26 avoid Wi-Fi overlap for best performance
Multi-Endpoint Design ZCL Clusters Multiple endpoints enable complex devices like 4-outlet strips
IEEE Address Binding Cache Staleness Address resolution failures cause intermittent binding issues
Group-Based Binding Reliability Multicast eliminates address resolution, achieving 99%+ reliability

33.11 What’s Next

Chapter Focus Area
Zigbee Comprehensive Review Return to the review index for all Zigbee review topics
Zigbee Worked Examples Exercises Practice problems extending the five worked examples in this chapter
Zigbee Review: Deployment Network planning, site survey, and installation best practices
Zigbee Review: Protocol Selection Compare Zigbee against Thread, Z-Wave, and BLE Mesh for specific use cases
Thread Introduction IPv6-based mesh networking as a modern alternative to Zigbee