refro
refro

Reputation: 209

MQTT write to device

At the moment we're looking at mqtt for connecting our controls to the internet. In our application a thermostat would be the server/sender, a phone app could be the client.

As far as I see the protocol is suited for sending measured temperatures to the connected clients. But I see no way to write back a setpoint. It could be done over a second connection were the thermostat subscribes to the phone app. Can it be done in another way?

Upvotes: 1

Views: 507

Answers (1)

hardillb
hardillb

Reputation: 59608

MQTT is a Publish/Subscribe protocol, there is no concept of a by directional connection between a publisher and a subscriber, because this could be a 1 to 1, 1 to many or many to many relationship for a given topic.

There is nothing to stop a publisher also being a subscriber to receive commands, many IoT frameworks work this way (for example IBM IoT Foundation).

Your thermostat can publish it temp on thermostat/{id}/temp and listen for incoming set values on thermostat/{id}/set

There is no need for multiple connections publishes and subscriptions can both happen via one connection to a broker

Upvotes: 2

Related Questions