MQTT
Lightweight messaging protocol for IoT systems.
Quick Start
# Install Mosquitto broker
sudo apt-get install mosquitto mosquitto-clients
# Subscribe to topic
mosquitto_sub -h localhost -t "sensors/temperature"
# Publish message
mosquitto_pub -h localhost -t "sensors/temperature" -m "23.5"
When to Use
- ✅ IoT devices with limited resources
- ✅ Pub/Sub pattern for data exchange
- ❌ Not for large files or complex RPC
Step-by-Step Instructions
- Install MQTT broker (Mosquitto)
- Configure broker settings
- Connect clients to broker
- Publish and subscribe to topics
Dependencies
sudo apt-get install mosquitto mosquitto-clients
# or for Python: pip install paho-mqtt
Examples
Input: mosquitto_pub -t "test" -m "hello" → Output: Subscriber receives "hello"
Resources
Validation
- Broker starts and listens on port 1883
- Messages delivered between clients
- QoS levels work correctly