When Publisher sends a message to a topic,
the Subscriber subscribing to the topic receives the message through the MQTT Broker.
-
Download the windows installation file.
mosquitto-1.4.15a-install-win32.exe
from https://mosquitto.org/download/ -
Click the link and download.
-
Win32 OpenSSL v1.0.2o Light
-
pthreadVC2.dll
-
-
Open " C:\OpenSSL-Win32 ".
Copy all .dll files and paste on " C:\Program Files (x86)\mosquitto ".
-
Copy the pthreadVC2.dll file that was downloaded earlier on " C:\Program Files (x86)\mosquitto ".
-
Open two Command Prompt programs.
-
cd / cd "Program Files (x86)\mosquitto"
-
First cmd
mosquitto_sub -h "host" -t "topic name" -p "port number"
ex) mosquitto_sub -h 192.168.0.15 -t /home/set -p 1883
-
Second cmd
mosquitto_pub -h "host" -t "topic name" -m "message" -V mqttv311
ex) mosquitto_pub -h 192.168.0.15 -t /home/set -m "ON" -V mqttv311
-
Check communication.
sudo apt-get install python-pip
sudo pip3 install paho-mqtt
-
Open two terminals.
-
First terminal
python3 sub.py
-
Second terminal
python3 pub.py
-
Check communication