1. Why to use MQTT
In the past when we need to connect one hardware and to manage it remotely, we were necessary to make our own protocols, the device must have its own IP address and etc. This were a big challenge and required knowledge of protocols, network architecture and generally it required a huge volume of work and as well as a lot of time for it realisation.
Through we use of MQTT server a most part of problems wrote above will be dropped and in generally we stay to do the device management logic.
With MQTT technology it is easy. We use the topics to communicate with the device. For example to do switch a relay on, the topic look like at this: device/relay/1/set [on]. It is easy, isn’t It?
Now in a little more details
To operate the device in this way it has to connected to MQTT server (MQTT servers are in Internet (Cloud based) or locals). When the device have already connected to server, we can receive data form it and we can send it commands which it will execute.