Bird
Raised Fist0
IOT Protocolsdevops~20 mins

Topic design patterns for IoT in IOT Protocols - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
IoT Topic Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Publish-Subscribe Pattern in IoT

Which statement best describes the publish-subscribe pattern commonly used in IoT messaging?

ADevices publish messages to a broker, and subscribers receive messages from the broker.
BDevices store messages locally and share them when requested.
CDevices send messages directly to each other without a broker.
DDevices use a centralized database to read and write messages synchronously.
Attempts:
2 left
💡 Hint

Think about how messages flow through a middleman in this pattern.

💻 Command Output
intermediate
2:00remaining
MQTT Topic Wildcard Matching Output

Given an MQTT broker subscription to the topic home/+/temperature, which published topic will NOT match this subscription?

Ahome/livingroom/temperature
Bhome/livingroom/humidity
Chome/kitchen/temperature
Dhome/bedroom/temperature
Attempts:
2 left
💡 Hint

The + wildcard matches exactly one level in the topic hierarchy.

❓ Configuration
advanced
2:00remaining
Configuring Retained Messages in MQTT

Which MQTT client configuration will ensure that the last message published on a topic is stored by the broker and sent immediately to new subscribers?

ASubscribe with the clean session flag set to true.
BSubscribe with QoS level 0.
CPublish messages with QoS level 2 only.
DPublish messages with the retain flag set to true.
Attempts:
2 left
💡 Hint

Consider how the broker knows to keep the last message for a topic.

❓ Troubleshoot
advanced
2:00remaining
Troubleshooting MQTT Topic Subscription Issues

An IoT device subscribes to the topic devices/+/status but does not receive messages published to devices/device1/status. What is the most likely cause?

AThe broker does not support wildcard subscriptions.
BThe subscription used the wildcard <code>#</code> instead of <code>+</code>.
CThe device subscribed with a clean session flag set to false.
DThe device published messages with QoS 0 instead of QoS 1.
Attempts:
2 left
💡 Hint

Think about broker capabilities and wildcard support.

🔀 Workflow
expert
3:00remaining
Designing a Scalable IoT Topic Hierarchy

You need to design an MQTT topic hierarchy for a smart city project with thousands of sensors across multiple districts and sensor types. Which topic design pattern will best support scalability and easy filtering?

AUse a single topic for all sensors, like <code>all_sensors</code>.
BUse a flat topic structure with sensor IDs only, like <code>sensor123</code>.
CUse a hierarchical topic structure like <code>city/district/sensor_type/sensor_id</code>.
DUse random topic names generated at runtime for each sensor.
Attempts:
2 left
💡 Hint

Think about how to organize topics for filtering by location and type.

Practice

(1/5)
1. What is the main purpose of using topic design patterns in IoT communication?
easy
A. To increase the battery life of sensors
B. To encrypt messages for security
C. To reduce the size of IoT devices
D. To organize messages clearly and make communication scalable

Solution

  1. Step 1: Understand the role of topics in IoT

    Topics help organize messages by categorizing them into levels separated by slashes.
  2. Step 2: Identify the benefit of good topic design

    Good topic design makes communication clear and scalable, allowing easy message filtering and management.
  3. Final Answer:

    To organize messages clearly and make communication scalable -> Option D
  4. Quick Check:

    Topic design = Clear, scalable communication [OK]
Hint: Topics organize messages for clarity and scale [OK]
Common Mistakes:
  • Confusing topic design with security features
  • Thinking topic design affects device hardware
  • Assuming topic design saves battery life
2. Which of the following is the correct syntax for a multi-level wildcard subscription in MQTT topics?
easy
A. home/#/temperature/+
B. home/temperature/+/+
C. home/+/temperature/#
D. home/temperature/#/+

Solution

  1. Step 1: Recall MQTT wildcard rules

    The plus sign (+) matches one topic level, and the hash (#) matches multiple levels at the end.
  2. Step 2: Check syntax correctness

    home/+/temperature/# uses + for one level and # at the end for multiple levels, which is valid syntax.
  3. Final Answer:

    home/+/temperature/# -> Option C
  4. Quick Check:

    Multi-level wildcard ends with # [OK]
Hint: Use + for single level, # only at end [OK]
Common Mistakes:
  • Placing # in the middle of the topic
  • Using + to match multiple levels
  • Mixing order of + and # incorrectly
3. Given the subscription topic building/+/floor1/#, which published topic will NOT be received by the subscriber?
medium
A. building/roomC/floor2/temperature
B. building/roomB/floor1/humidity
C. building/room/floor1/temperature
D. building/roomA/floor1/temperature

Solution

  1. Step 1: Analyze the subscription pattern

    The + matches exactly one level after 'building', and # matches any levels after 'floor1'.
  2. Step 2: Test each published topic

    Options A, B, and C match 'building/roomX/floor1/...' correctly. building/roomC/floor2/temperature has 'floor2' instead of 'floor1', so it does not match.
  3. Final Answer:

    building/roomC/floor2/temperature -> Option A
  4. Quick Check:

    Subscription requires floor1 level [OK]
Hint: Check each topic level matches + and # rules [OK]
Common Mistakes:
  • Ignoring the exact match required by + wildcard
  • Assuming # matches levels before floor1
  • Confusing floor1 and floor2 levels
4. Identify the error in this MQTT subscription topic: home/+/+/temperature/#/humidity
medium
A. The # wildcard is not allowed in the middle of the topic
B. Using multiple + wildcards consecutively is invalid
C. The topic must start with a slash
D. Wildcards cannot be combined with normal topic levels

Solution

  1. Step 1: Review MQTT wildcard placement rules

    The # wildcard must be the last character in the topic filter and can only appear once.
  2. Step 2: Check the given topic

    The # wildcard appears in the middle before /humidity, which is invalid syntax.
  3. Final Answer:

    The # wildcard is not allowed in the middle of the topic -> Option A
  4. Quick Check:

    # only at end of topic [OK]
Hint: # wildcard only at topic end [OK]
Common Mistakes:
  • Thinking multiple + wildcards are invalid
  • Believing topics must start with slash
  • Assuming wildcards can't mix with normal levels
5. You want to design MQTT topics to monitor sensors in multiple buildings, floors, and rooms. Which topic pattern best supports scalable subscription to all temperature sensors on floor 2 across all buildings?
hard
A. building/+/+/floor2/temperature
B. building/+/floor2/+/temperature
C. building/#/floor2/temperature
D. building/+/floor2/temperature/#

Solution

  1. Step 1: Understand the hierarchy needed

    Topics should include building, floor, room, and sensor type levels.
  2. Step 2: Analyze each option for scalability and correctness

    building/+/floor2/+/temperature uses + to match any building and any room on floor2, then temperature sensor, which is clear and scalable. building/#/floor2/temperature misplaces # wildcard. building/+/+/floor2/temperature has extra + before floor2, which breaks hierarchy. building/+/floor2/temperature/# places # after temperature, which is unnecessary and less clear.
  3. Final Answer:

    building/+/floor2/+/temperature -> Option B
  4. Quick Check:

    Use + for flexible levels, keep clear order [OK]
Hint: Use + for each flexible level, keep order clear [OK]
Common Mistakes:
  • Misplacing # wildcard inside topic
  • Adding extra + levels breaking hierarchy
  • Using # after sensor type unnecessarily
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard