Data logger with integrated MQTT serial communication bridge


Although our data loggers can capture measurements from various serial devices or smart sensors by standard serial communication protocols (e.g MODBUS, NMEA-0183 or SDI-12), the data logger itself has no knowledge about how to apply changes to these often proprietary devices. The integrated MQTT serial communication bridge, which we call “MQTT-Com-tunnel”, enables to send/receive1) data to/from serial devices connected to the data logger remotely(e.g. to reset something in a device or to occasionally give a sensor a command to do some cleaning or internal house keeping).

Setting up your commands

Commands can be send to the serial sensor (RS232/RS485/SDI-12) or accessory (RS232) port on the main PCB as well as on option boards. The (binary) data contained in the MQTT payload will be passed transparently 1 to 1 to the concerned serial device and the response will be replied as (binary) payload 1 to 1 as well, it’s up to the MQTT-client to format and interpret the data to/from the serial device (which could be MODBUS/RTU, SDI-12, NMEA-0183 or any other protocol).

Commands can be initiated from an automated task on some server, but they can also be initiated manual from an MQTT smart phone app (e.g. the Android app: MQTT Terminal)

When a COM-tunnel message is received destined for a device connected at a serial sensor port and the device requires power from the 12V sensor power switch, the data logger will switch on the 12V power and wait a certain warm-up time before sending the command to the device. The warm-up time will not be applied in case of sequential commands in the same MQTT-session.

Connection with the MQTT-broker

When a COM-tunnel message is received destined for a device connected at an accessory port and the device requires power from the 5V accessory power switch, the data logger will switch on the 5V power and wait a certain warm-up time before sending the command to the device. The warm-up time will not be applied in case of sequential commands in the same MQTT-session.

After sending data to the serial device, the data logger will wait max 3 seconds for reply from the connected device. In case of no response, the data logger will publish an MQTT message with empty payload. If the serial device replies, the reply is considered complete after a character silence time of 0.25s. The data logger will publish an MQTT message with the full 1 to 1 (binary) reply as the payload.

Note: Be aware that communication is not instant as the data logger is not continuously connected with the MQTT-broker. It connects frequently, according to your schedule, to publish measurements.

Various topics for a MQTT-client

An MQTT-client should format a command publishing topic as follows:

“YDOC/<device serial number>/comtx/<port>[/<client defined sup-topics]” (QoS=1)

Where <port> can be (if installed and configured in the data logger):

  • “sp1”, the serial sensor port on the main PCB
  • “ap1”, the accessory port on the main PCB
  • “sp2”, the serial sensor port on an option board
  • “ap2”, the accessory port on an option board

The MQTT-client can specify optional sub-topics for its own internal management, the used sub-topics are also included in the MQTT reply messages. Such sub-topics could be used for grouping or matching commands with replies (e.g. by using some sequence# as sub-topic).

Example:

“YDOC/99091660/comtx/sp1” or “YDOC/99091660/comtx/sp1/S123/METEO/”

The data logger will publish the reply with the same topic as the command, but will replace the text “comtx” with “comrx”

Example:

“YDOC/99091660/comrx/sp1/S123/METEO/”)

An MQTT-client can use wild-cards to subscribe to any COM-tunnel message from any data logger within the scope of the MQTT-account, by subscribing to: “YDOC/+/comrx/#” (QoS=1)

Limits to the MQTT topics

  • Topic size: 128 characters
  • Payload size: 256 bytes for commands, 512 bytes for replies
  • Device reply timeout: 3s (The device should answer within 3 sec)
  • Silence time: 0.25s (A reply is considered complete after a communication silence time of 0.25s)