Translations:MQTT/3/en

Материал из Wiren Board

1 Examples of work via the MQTT queue

Getting the value from the temperature sensor and displaying it in the web interface

Sensor readings and its unique identifier on the Devices page of the web interface

Assume that a 1-Wire/en bus temperature sensor is connected to the Wiren Board. Let's see how the sensor data comes into the web interface via the message queue:

  1. The driver that is responsible for this hardware function (wb-homa-w1) polls the 1-Wire sensors connected to the controller.
  2. When a value is received, the driver queues a message that resembles the following:
    /devices/wb-w1/controls/28-0115a48fcfff 23.25
    It means that the 1-Wire device (ID 28-0115a48fcfff)registers a value of 23.25°C.
  3. The web interface that receives all messages from the queue (it is subscribed to all messages) receives this message and displays the sensor value to the page.

Pressing a button in the web interface and switching the relay on the external module

Web interface after pressing relay 1 on the relay module MRM2 CONNECTED via RS-485

Suppose that the relay module WB-MRM2 is connected to the controller via the RS-485 bus. The user presses the relay button in the web interface and switches it on. Let's see how the command from the web interface gets to the external module:

  1. After clicking the button, the web interface places the following message in the queue:
    /devices/wb-mrm2_130/controls/Relay 1/on 1
    It means that the device WB-MRM2 with the address 130 must transfer Relay 1 to the state of the logical 1 - "on".
  2. The wb-mqtt-serial driver responsible for this hardware function receives this message (it is subscribed to all messages related to RS-485 devices) and sends a command to turn on the first relay via the RS-485 bus to the relay module.
  3. The WB-MRM2 relay module receives a command from the controller, switches the relay and sends back a notification ("Relay 1 is on").
  4. The wb-mqtt-serial driver receives this notification over RS-485 and sends the message to the queue:
    /devices/wb-mrm2_130/controls/Relay 1 1
    It means that the first relay on the WB-MRM2 device with address 130 is in the logical 1 state (is "on").