Recall & Review
beginner
What is the main purpose of the paho-mqtt library?
The paho-mqtt library helps devices like Raspberry Pi send and receive messages using the MQTT protocol, which is a simple way for devices to talk to each other over the internet.
Click to reveal answer
beginner
How do you connect a Raspberry Pi client to an MQTT broker using paho-mqtt?
You create a client object, then use the connect() method with the broker's address and port to connect. For example: <br>client = mqtt.Client()<br>client.connect('broker.hivemq.com', 1883)
Click to reveal answer
intermediate
What is the role of the on_message callback in paho-mqtt?
The on_message callback is a function you define to handle messages that arrive on topics you subscribed to. It runs automatically when a new message comes in.
Click to reveal answer
beginner
How do you subscribe to a topic using paho-mqtt?
After connecting, you call client.subscribe('topic/name') to listen for messages sent to that topic.
Click to reveal answer
beginner
What method do you use to send a message to a topic with paho-mqtt?
Use client.publish('topic/name', 'message') to send a message to the MQTT broker on the chosen topic.
Click to reveal answer
Which method connects your Raspberry Pi client to the MQTT broker?
✗ Incorrect
The connect() method establishes the connection to the MQTT broker.
What does the subscribe() method do in paho-mqtt?
✗ Incorrect
subscribe() tells the client to listen for messages on a specific topic.
Which callback function handles incoming messages?
✗ Incorrect
on_message is called when a new message arrives on a subscribed topic.
What is the purpose of client.loop_forever()?
✗ Incorrect
loop_forever() keeps the client active to send and receive messages.
How do you publish a message 'Hello' to topic 'test/topic'?
✗ Incorrect
publish() sends the message 'Hello' to the specified topic.
Explain the basic steps to set up a Raspberry Pi client using paho-mqtt to receive messages.
Think about how the client connects, listens, and reacts to messages.
You got /5 concepts.
Describe how to send a message from Raspberry Pi to an MQTT topic using paho-mqtt.
Focus on connection and publishing steps.
You got /4 concepts.