Suchen Sie etwas anderes?
Table of Contents
Scene details
MTX-Titan-Router has all the typical features of a 2G/3G/4G router and also has 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 make up to 5 simultaneous IP gateways-RS232/RS485/USB. That is, with the Titan router you can implement up to 5 gateways of the type:
Ethernet <> RS232/RS485/USB
WiFi <> RS232/RS485/USB
3G/4G <> RS232/RS485/USB
This means that if you have one or more remote devices with an RS232, RS485 or USB* port, you will access them remotely as if they were on the premises (USB* = compatible with FDTI or ACM). There are several ways to implement IP-Serial gateways in the Titan family of routers: TCP server mode, TCP client mode or MQTT. This application note will detail how to implement 4 MQTT-serial gateways simultaneously to control, from an MQTT broker, one USB device, two RS232 devices and the devices connected to an RS485 bus (up to 64).
We have a SAI power supply generating several alarms (via SNMP traps), and there is a power failure or malfunction. We need the router Titan to gather said traps and send SMS to the maintenance team when those traps are received. Also, we need those traps to be sent to a platform via MQTT to manage the history.
Description of the Example
As indicated above, the purpose of this application note is to detail how to connect a large number of serial devices (RS232, RS485 and USB) via 2G/3G/4G to an MQTT broker, with the transparent data fl ow. That is, the data received by a serial port of the TITAN router (RS232, RS485, USB) must be sent transparently to an MQTT broker and vice versa, from an MQTT broker it must be possible to send information transparently to any of the serial ports of the TITAN router (RS232, RS485, USB) and therefore to the devices connected to them.
Configuration of the Associated RS232, RS485 and USB Ports
The confi guration to be implemented in each of the serial ports is simple. To configure the COM1 (RS232) port, access “Serial Settings” > “Serial Port1-232” and configure the properties of the serial port (baudrate, parity, etc.) depending on the external device to be connected to it.
Then, in the lower area of the same confi guration screen, we complete the “TX Mqtt Topic” and “RX Mqtt Topic” confi guration parameters, which are the key parameters for this work scenario. After that, press the Save Config button.
What does it mean to enter COM1TX and COM1RX values in the confi guration in this example? Well, this means that any data stream received by the RS232 COM1 serial port of the TITAN router is retransmitted (transparently) to the MQTT broker under the “COM1TX” TOPIC. That is, the MQTT broker will receive in that topic the INPUT data fl ow of the RS232 COM1 port of the TITAN router. On the other hand, if from the MQTT broker (or another device connected to the MQTT broker) it is necessary to send an OUTPUT data fl ow through the COM1 RS232 port of the TITAN router, this data fl ow must be sent to the COM1RX topic, as it is the topic to which the TITAN router will subscribe for such action.
Schematically it could be represented like this:
The same confi guration process must be carried out on the other serial ports through their respective confi guration menus. In each of them, the properties of the serial port must be properly confi gured and the topics for reception (RX) and transmission (TX) must be configured.
For example, the confi guration of the topics of all serial ports could be:
COM1 (RS232): COM1TX | COM1RX
COM2 (RS232): COM2TX | COM2RX
COM3 (RS485): COM3TX | COM3RX
COM5 (USB): COM5TX | COM5RX
MQTT Client Confi guration
In addition to the previous confi guration, the MQTT client section must be confi gured, that is, the confi guration that will cause the TITAN router to connect to the desired MQTT broker. This must be done from the “Other > MQTT” configuration menu:
Check with your MQTT broker for the appropriate parameters in this section. Once confi gured press the Save Config button.
WAN Section Configuration
In order for the Titan router to connect to the Internet and therefore access the MQTT broker via 2G/3G/4G, the “WAN > Basic Settings” section must also be confi gured. Enter in this section the SIM card PIN (if available), the APN, username and password of the operator used, etc. Once this is done, press the Save Confi g button. Finally, restart the router to start with the new configuration.
Final Considerations
- Only FTDI or ACM compatible devices can be connected to the USB port of the Titan router
- You can make exotic confi gurations with the serial ports. For example, if the COM2TX and COM1TX topics are confi gured on the COM2 port, all data fl ow received on the COM2 port of the TITAN router would be relayed to the MQTT broker to the COM2TX topic, but all data flow received on the COM1 port of the router Titan, in addition to being retransmitted to the MQTT broker to the COM1TX topic, would be retransmitted by the COM2 port of the Titan router, since the reception topic of this is also COM1TX (the same as the transmission of the COM1 port)