Suchen Sie etwas anderes?
Table of Contents
Scenario Details
Titan routers have all the typical features of a 2G/3G/4G router but also have a series of additional features that make it one of the routers with the most features on the market. One of the additional features is the ability to store data from a serial device connected to an RS485 or RS232 port, interrogating them with custom serial frames, useful for proprietary protocols.
As always, this capability will be illustrated with a simple example scenario.
Description of the Example
- There is a device (PLC) with RS232 serial port (115200,8, N, 1). A series of internal registers of that device needs to be read every 10 minutes. and send them to an MQTT platform
- In order to read the device registers, the use of a proprietary protocol is required, that is, certain frames of bytes (proprietary protocol) must be sent through the serial port of the device so that it responds with the values of certain internal registers
- Therefore, the modem must send preconfigured byte frames periodically through its RS232 serial port to the serial device, collect the responses from it and, attaching the data collection time, send said data to an MQTT broker encapsulated in a JSON object
- The serial frames to be sent via RS232 to read the registers will be two and will be sent through the serial port of the Titan router every 10 minutes: 313233F435 and 41A12D42421F4343
Associated Serial Port Configuration
The first thing to decide is to which serial port of the Titan router the serial device to be interrogated is to be connected.
Suppose the PLC is to be connected to the COM1 (RS232) port of the Titan router. The configuration of the serial port of the PLC is 115200,8, n, 1 so we will have to click on the menu Serial Settings> Serial Port1-232 and configure the screen as follows:
Serial Datalogger Configuration
The next step is to configure the serial datalogger, that is, we have to configure the Titan router to choose the serial port that will be used with the datalogger as well as the frames (in hexadecimal format) that the Titan router must send through its serial port. to interrogate the PLC and also the period for sending them.
To do this, click on the link: External Devices> Generic Serial Device and configure the screen as shown below:
Namely:
- Check the enable serial datalogger box (Enabled box)
- Choose the serial port Port 1 to use
- Choose an Interval “0”, since all response frames must be collected
- Do not select the “Only Changes” frame, as it does not make sense for the current application
- Mode: Raw
- Check the box to enable the storage of serial frames received in the internal datalogger (Logger box)
- TX Period: the period of the sending frames must be indicated. 600 seconds means sending serial frames every 10 minutes
- TX FrameX: the serial frames to send each time period (in this example 600 seconds) must be indicated. Serial frames must be entered in hexadecimal format
- Press the SAVE CONFIG button at the end of the configuration
Logger Configuration (communication with MQTT server)
The next step is to configure the Logger, that is, the data storage and sending system carried out by the Titan router itself. In this example, the Titan router will be configured to send the collected serial data to an MQTT broker.
As can be seen in the following figure, the External Devices> Logger Configuration menu must be accessed and this section must be configured as shown below:
By performing this action, you are activating the data submission mode by MQTT to the topic “/ LOGGER” of the MQTT broker.
Next, the Other> Mqtt section must be configured to activate the MQTT client properly, configuring parameters such as the MQTT broker to use, the MQTT ID, etc.
Final Considerations
- After configuring the Titan router, it is necessary to perform a reset for the new configuration to be used.
The JSON objects sent to the MQTT broker with the serial reads of the responses received from the PLC will have a content similar to:
{TYPE:SERIAL,TS:11/04/2021 17:19:44,IMEI:358709050113764,P:,DATA:3c646174613e72656c6179733a372c74656d70657261747572653a33322c68756d69646974793a38302c636f756e7465723a313232353c2f646174613e0d0a}
where the data in hexadecimal is located in the DATA field in hexadecimal format.
Any more doubts? Write your questions to us at iotsupport@mtxm2m.com.