In this post is showed the MQTT library recommended for Industrial Shields. This library has been tested and used in several installations without any issue. So we can assure that is stable and reliable.
Download and additional information: MQTT Library
To install the library we just have to download the .zip file and go to our Arduino IDE. Go to --> Sketch --> Include library --> Add ZIP library. Then select the downloaded file and click to OK button to install this library into the Arduino IDE.
Now we are ready to use it.
HOW TO USE IT
There are several functions to use in this library.
First of all we must include the library and set up our network connection properly (Wi-Fi, Ethernet, GSM...).
Then we must indicate the server IP address, initialize a client for our network and for our MQTT connection
IPAddress server(xxx, xxx, xxx, xxx);
Initialize client and callback function (optional).
After the initialization of the client we have different functions to check, connect, receive and send information.
Use client.connected to verify if the client is connected and use client.connect() to establish communication.
To subscribe and publish
Apart of this functions you must place the function client.loop() in the loop function to maintain the communication.
These are the bases to use this MQTT library. Check the Github to know further information.
Enjoy the library!