Requirements
Cloud access is enabled in LOGO!Soft Comfort
Procedures
Follow these steps to set up IoT connection between LOGO! BM and Mosquitto MQTT.
Download Mosquitto MQTT application in Mosquitto Website.
Click the .exe file to install the application on your PC.
Open the mosquitto.conf file under the root folder of the installed application. Configure the host PC's IP address and Port in mosquitto.conf file.
Change the configuration of "allow anonyous false" into "allow anonymous true" in mosquitto conf file.
Disable the firewall in your PC to ensure the stable connection between LOGO! BM and Mosquitto MQTT.
Open the cmd window in root folder of the installed Mosquitto appliction. Input command mosquitto -c mosquitto.conf -v to start Mosquitto application.
|
Note
Leave the cmd window open during the whole process of connection. Otherwise, the IoT connection will be interrupted. |
Register Mosquitto MQTT IoT thing through Tools -> Transfer -> Cloud Connection Settings in LOGO!Soft Comfort. Click Register Thing button to start the process.
Select "MQTT" in Cloud Type and click "Next" button.
Enter MQTT Broker URL, Port which you have configured in step 3; set MQTT Client ID. Then click"Next" button.
Select "TCP" as the Authentication Type. Then click "Next" button. For how to configure Mosquitto when selecting other authentication type, refer to Mosquitto Website.
Enter "Publish Topic" and "Subscribe Topic". You can name them by yourself. Then click "Next" button. Remember these two topic names, which will be used later to subscribe or publish data on Mosquitto MQTT client.
The Register Status page shows you that your registration is successful. Click "Finish" button to close the registration dialog.
Subscribe data from LOGO!
Open cloud data transfer settings window through Tools -> Transfer -> Cloud Connection Settings.
Add a data item. In this example we use "Array Data Format". Click "Write to LOGO!" to finish the configuration.
Input command in the cmd window: mosquitto_sub -h 192.168.0.66 -p 1883 -t "Topic 1". You will see messages in the cmd window sent from LOGO! BM.
Publish data to LOGO!
Open another cmd window in root folder of the installed Mosquitto appliction.
Input the following commands in the new cmd window to publish data to LOGO! BM:
mosquitto_pub.exe -h 192.168.0.66 -p 1883 -t "Topic 2" -m "{\"state\":{\"var1\":{\"value\":[0,0]},\"var2\":{\"value\":[0]}}}
mosquitto_pub.exe -h 192.168.0.66 -p 1883 -t "Topic 2" -m "{\"state\":{\"var1\":{\"value\":[50,100]},\"var2\":{\"value\":[1]}}}
In the subscribe cmd window, you can see the successfully published messages, and you can also see the data is successfully changed in LOGO! BM.