
These sensors communicate with the thermostat using MQTT and the thermostat uses this information to regulate the home heating system.Įach sensor ( publisher) communicates its temperature by publishing on a specific MQTT topic and thermostat (s ubscriber) monitors temperatures by checking these topics below an example of the topics structure: myhome/groundfloor/kitchen myhome/groundfloor/dining myhome/groundfloor/livingroom myhome/groundfloor/bedroom1 myhome/groundfloor/bedroom2 myhome/groundfloor/bathroom PublishĪ client writes data on a topic using the PUBLISH message. Suppose you have temperature sensors scattered around your house.
Composed by one or more levels separated by “ /”. Topic is a string with the following characteristics: A s erver accepts each valid topic without any initialization. Broker will send this message, on behalf of the client, when the client “badly” disconnects.Īs mentioned before, MQTT broker uses topic to decide which subscriber receives which message.Ī client doesn’t create a topic before using it. WillMessage (optional) A client can specify its last will message in the form of a MQTT message and topic. Simple android app in eclipse password#
Username and Password (optional) Client can send a username and password to improve communication security. The client needs to send regular PING messages, within the KeepAlive period, to the broker to maintain the connection alive. KeepAlive This interval, express in seconds, defines the maximum period of time that broker and client can remain in contact without sending a message. Instead, if the flag is set to true, it means discarding all existing sessions and messages for that client (mandatory if the ClientId is empty). CleanSession If the CleanSession is set to false and the broker has information stored for that client, broker uses the existing session and delivers previously queued messages to the client. An empty ClientID means an “anonymous” connection: therefore, the broker does not memorize any information about the client. ClientID ClientID is an unique ID used by brokers to identify the client and store information (called session) about it. With this message, a client presents itself to a broker providing the following main information:
Before starting the message exchange over topics, the client needs to initiate the communication by sending the CONNECT message to the broker.