How to use MQTT Publish, Subscribe & Unsubscribe commands

MQTT Subscribe commands

Here is the MQTT Subscribe syntax to a particular topic (Hello_world)

 mosquitto_sub -h  'SERVER_IP_ADDRESS'  -t 'Hello_world' 

Here is the MQTT Subscribe syntax to a particular topic Hello_world with MQTT server with username and password

 mosquitto_sub -h  'SERVER_IP_ADDRESS' -u user -P pass -t 'Hello_world' 

Subscribing to all topics

 mosquitto_sub -h 'SERVER_IP_ADDRESS' -t \# -d 

MQTT Publish a message topic Hello_world

 mosquitto_pub -t ‘Hello_world’ -m hello 

My Thought

Your email address will not be published. Required fields are marked *