fg71
Q. How to make MQTT to work in your local network.
A. You need to have MQTT Broker installed on SBC or general-purpose computer.
 
In this example we will install Mosquitto on Windows platform but its the same for other system.
We will configure the mosquitto.conf so we could connect ex. Nano ESP32 to MQTT Broker.
 
# ======================================================================
# User Settings
# ======================================================================
allow_anonymous true
listener 1883
 
This allow any device on the local network to access the port 1883, if we need a more secure connection we need to
add more things to the mosquitto.conf but for this example its enough.
 
In Windows you could start Mosquitto Broker as Service, but I'm not sure it include the configure file. At least I didn't get
that to work (investigate). We could solve this by starting Mosquitto from terminal.
 
-> <PATH_TO_MOSQUITTO>\mosquitto.exe -c <PATH_TO_MOSQUITTO>\mosquitto.conf
 
Now we have started the Mosquitto Broker on your local computer. If you couldn't start it on windows platform make sure the Mosquitto Broker Service is not started, if so stop it. And try again.
 
Open OpenPLC and load the example MQTT_Send, change the Broker test.mosquitto.org to your <IP_Local>
Optional change the topic message. Make sure you have Modbus TCP enabled
[203128%2F9238645%2Fmceclip0]
 
Now we will open MQTT Explorer to visual the message. We configure before we connect as you could see in picture below.
And click connect
[203128%2F9238646%2Fmceclip0]
 
We would now see the message Nano ESP32 is sending, meaning the IP of Nano ESP32 board is communicate on the local network to publish a message in interval of 500ms. We use MQTT Explorer to connect to Mosquitto Broker so we could debug the message.
[203128%2F9238650%2Fmceclip0]
 
So if we like to have 2 devices connected, we need to publish a message with topic on the first device and on the second device we subscript with topic. When the first device measure the temperature from a livingroom. The second device could subscript to topic sensors/livingroom/temp and use the information to trigger a event.
 
Raspberry Pi a very cheap general-purpose computer could be your MQTT Broker. Or use Docker...
 
I hope this explain how MQTT is working.
Reply 0 0
Grz
Hello Fg71,
 
I find it quite complicated just to send a message.
 
The best thing would be to be able to send an email.
 
I currently find that the Forum topics are moving away from automation and closer to IT, not to mention the number of times the topic response is "update the editor."
 
In the new version of OpenPLC, why improve the LADDER language input since there are few or no topics in the Forum? (Very few new FBDs, more topics on PLCs and hardware configurations...).
 
Thank you for your tutorials, which are interesting but often too complicated for me.
 
Best regard.
 
Pierre
Reply 0 0
fg71
Lets say you have heater that could configure with a app on your mobile.
When you use this mobile app for the first time you need to create a account. This account have a id and encrypted connection.
When your heater send (publish) some data to a reference (topic) to the Cloud. You mobile app have already setup a subscription to reference (topic)
And you mobile app only have to return the value of your payload from your subscripted object.
 
The heater company only have to maintain the Broker with your id account. And you only need to make sure there is a communication.
In other words the Client could connect to the Broker every minute without your request and in that regards your message is not so old.
If we are talking about temperature to measure a Livingroom that is slow process 1 minute is maybe overkill.
 
Remember that Industry 4.0 is the 4th industrial revolution there IoT and cloud based service is very common. It means the data could be access anywhere.
 
So I do not think its enough to only have IEC-61131-3 knowledge to become a Automation Engineer.
Reply 0 0
Reply