Raspberry Pi - MQTT for IoTIn an MQTT-based smart home system, how can you ensure that a device's unexpected disconnection is detected and handled?ADisable clean session flagBSet QoS to 0 for all messagesCSubscribe to all topics with wildcard '#'DUse Last Will and Testament (LWT) messagesCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand device disconnection detectionMQTT's Last Will and Testament sends a message if a client disconnects unexpectedly.Step 2: Evaluate other optionsQoS 0 doesn't help detect disconnection; wildcard subscription and clean session don't detect disconnects.Final Answer:Use Last Will and Testament (LWT) messages -> Option DQuick Check:MQTT LWT detects unexpected disconnects = Use Last Will and Testament (LWT) messages [OK]Quick Trick: LWT messages notify broker of unexpected disconnects [OK]Common Mistakes:MISTAKESThinking QoS controls disconnect detectionBelieving wildcard subscription detects disconnectsConfusing clean session with disconnect handling
Master "MQTT for IoT" in Raspberry Pi9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Raspberry Pi Quizzes Automation and Scheduling - systemd service for auto-start - Quiz 1easy Automation and Scheduling - Email alerts on sensor thresholds - Quiz 10hard Automation and Scheduling - Cron jobs for scheduled tasks - Quiz 7medium Automation and Scheduling - Process management with supervisor - Quiz 11easy MQTT for IoT - paho-mqtt library usage - Quiz 14medium MQTT for IoT - Subscribing to control topics - Quiz 3easy MQTT for IoT - MQTT broker setup (Mosquitto) - Quiz 14medium Security and Deployment - User authentication basics - Quiz 6medium Web Server and API - Controlling GPIO through web interface - Quiz 3easy Web Server and API - Flask web server on Raspberry Pi - Quiz 14medium