I have read below link and other link but I still don't understand clearly what is payload in mqtt
Can someone please explain clearly what is payload in mqtt and what are its benefits?
I have read below link and other link but I still don't understand clearly what is payload in mqtt
Can someone please explain clearly what is payload in mqtt and what are its benefits?
The payload is simply the data (information) carried in the packet
A payload is simply a formatted package of information that is transferred from one system to another
For instance, suppose that you have a temperature sensor connected to an ESP32 and that you want to display the temperature on a second ESP32 system that is not in wireless range of the first one
If both systems are in range of a different WiFi router connected to the Internet, then one way of transferring the data is for the temperature to be read by the first ESP32, packaged up into a payload, and sent to an MQTT broker.
The second ESP32 can read messages received by the MQTT broker, download the payload, extract the temperature from it and display it
Taking this further, you could have multiple ESP32 clients reading and displaying the same data in any location that can access the MQTT broker
Communication can be either way. Suppose that the temperature is sent every hour but one of the clients wants to have it read more often. The client could publish a message requesting a reading, have it read by the EP32 with the temperature sensor and sent back. That would mean that every client received the temperature, which may not be required
To get round this the payload could contain a piece of data indicating whether the message was for a particular client or all of them. Thus the payload would now have 2 pieces of information, the target system and the temperature. All clients would receive the payload and only display it if it was for them
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.