Skip to content

MQTT Client

The MQTT protocol is intended primarily for the exchange of data between Internet of Things devices and servers and client devices, eg smartphones.

Its main advantage is maintaining a connection in both directions, thanks to which it is possible to easily control the Lan Controller in the local network from the telephone in the operator's local network.

MQTT Client

Elements of page

  1. Connection status with the MQTT server.
  2. A part of MAC address of the device that the client uses as a clientID when connecting to the server.
  3. Connection configuration form.
    • Enabling the MQTT client.
    • Enable user/password authentication.
    • Use TLS.
    • Use LWT (to publish connection state on [Topic prefix]/connected topic, 1 - connected, 0 - disconnected).
    • Send by GSM modem (instead of Ethernet connection).
    • The server address can be given as the IP address or the host name.
    • The communication port, used by default for connections without encryption, is 1883.
    • Login/username used for authentication.
    • Password used for authentication.
    • Prefix is ​​a base part of the topics used by LK. All sending topics and subscription topic begin with the prefix.
    • Sending period, that is period of time between consequent send of selected data.
    • The keep-alive parameter.
    • Selection of readings to be sent cyclically (mark desired).
    • Selection of readings that will be sent upon change.
  4. Buttons for saving settings and a link to mqtt.ats.pl, which allows you to use the MQTT client on LK.

mqtt.ats.pl service

The service mqtt.ats.pl is free and allows you to connect up to 5 devices.

Data from connected devices are archived and available for viewing on charts.

It is also possible to define events similar to those in Events tab, with conditions that can include multiple devices - an event on one can be used to control others.

Using the MQTT WebSocket client available on the website, you can remotely control your devices. There is also a mobile application that allows you to view readings and control devices.

Instructions for connecting LK3 with the server can be found in the mqtt.ats.pl documentation.

MQTT commands

You can send commands to Lan Controller via the MQTT protocol. They have to be send on the topic <Topic prefix> /cmd, and confirmations/replies from LK can be recieved on the topic <Topic prefix>/cmdr.

The following commands are available (as of version SW 1.44):

  • outX=1 - turn on the output, where X is the output number (0 - 5)
  • outX=0 - turn off the output, where X is the output number (0 - 5)
  • pwmX=1 - turn on the PWM output, where X is the PWM output number (0 - 3)
  • pwmX=0 - turn off the output PWM, where X is the PWM output number (0 - 3)
  • pwmfX=Y - set the PWM frequency, where X specifies the group of PWM outputs (0 for PWM0, 1 for PWM1-PWM3), and Y is the frequency in Hz (50-100000)
  • pwmdX=Y - set the fill factor for the output, where X is the PWM output number (0 - 3), and Y is the value in percent (0-100)
  • eventX=Y - set the value of the virtual variable EVENT, where X specifies the variable number (1-8) and Y specifies the value (0 or 1)
  • read - send all readings selected for periodic sending via MQTT (action does not affect periodic sending)

Notes

Note about saving the form

Login and password fields are required even if you do not use authentication due to certain assumptions on the device side. Therefore, you should enter anything in the fields mentioned above, eg a space.

Note about LK 3.0

LK 3.0 does not support TLS, LWT function and sending readings on change of their state.