Tunnel – Remote management of up to 9 digital outputs and relays through Telnet and/or MQTT/S.

¿Buscas alguna otra cosa?

Senario details:

  • You need to be able to change the status of 9 remote relays to enable / disable a number of devices connected to them. Such remote activation needs to be done through telnet and / or an MQTT / S platform.
  • For telnet access, only TCP connections must be allowed from authorized IPs 1.2.3.4 and 1.2.3.5
  • In the event of a Telnet change in the status of an exit, said change must be transmitted immediately to the MQTT platform so that the new status is reflected in the MQTT platform dashboard so that an operator can consult the current status

Solution: MTX-Tunnel firmware + MTX-IOT-S [4-N]

Configuration example (config.txt file) for the indicated scenario:

Configuration Observations
GPRS_apn: movistar.es
GPRS_login: MOVISTAR
GPRS_password: MOVISTAR
GPRS_timeout: 0
MTX_pin: 0000
MTX_model: 199802407
MTX_mode: none
MTX_ping: 30
MTX_pingIP: 8.8.8.8
MTX_numGSMErrors: 180
MTX_TPProtocol: ntp
MTX_TPServer: ntp.roa.es
MTX_TPServer2: es.pool.ntp.org
MTX_TPFormat: unix
FIREWALL_enabled: off
TELNET_enabled: on
TELNET_login: user
TELNET_password: 1234
TELNET_port: 20023
MQTT_enabled: on
MQTT_server: tcp://broker.mqttdashboard.com:1883
MQTT_id: [IMEI]
MQTT_login:
MQTT_password:
MQTT_attopic1: [IMEI]/AT
MQTT_atrtopic: [IMEI]/ATR
MQTT_persistent: off
MQTT_qos: 1
MQTT_keepalive: 60
MQTT_defaultOTopic: /IOCHANGE MQTT_defaultIOQos: 1
GPIO_mode0: output
GPIO_config0: normal
GPIO_mode1: output
GPIO_config1: normal
GPIO_mode2: output
GPIO_config2: normal
GPIO_mode3: output
GPIO_config3: normal
GPIO_mode4: output
GPIO_config4: normal
GPIO_mode5: output
GPIO_config5: normal
GPIO_mode6: output
GPIO_config6: normal
GPIO_mode7: output
GPIO_config7: normal
GPIO_mode8: output
GPIO_config8: normal
GPRS APN provided by GSM operator
GPRS Login
GPRS Password
Modem is permanently connected to GPRS
PIN if it has one
Device model
Gateways used
Every 30 minutes PING check
Google IP (f.e.) to ping
Reset if no registry on
GSM network in 1800 secs.
Time synch protocol
Time server
Time server backup
Unix time format
Authorized IPs
Telnet service
Telnet username
Telnet password
Telnet TCP port
MQTT service
MQTT broker, format protocol://url:port
Device ID in broker
Username
Password
MTX topic to recieve AT commands
Topic where MTX sends responses to AT commands
Persistence
QoS established
Keepalive
MQTT topic to inform of output changes in real time
MQoS to inform of output changes in real time
GPIO0 configured as an output
GPIO0 configured as a normal output
GPIO1 configured as an output
GPIO1 MQTT configuration
GPIO2 configured as an output
GPIO2 MQTT configuration
GPIO3 configured as an output
GPIO3 MQTT configuration
GPIO4 configured as an output
GPIO4 MQTT configuration
GPIO5 configured as an output
GPIO5 MQTT configuration
GPIO6 configured as an output
GPIO6 MQTT configuration
GPIO7 configured as an output
GPIO7 MQTT configuration
GPIO8 configured as an output
GPIO8 MQTT configuration

Details:

  • The MTX-IOT-S family modems have up to 8 digital outputs (from GPIO0 to GPIO7) and 1 integrated relay (GPIO8). The 8 digital outputs are open collector type with enough current to switch an external relay. In this example all GPIOs have been configured as OUTPUT

  • If for your application you only need to manage a low power relay (up to 1Amp), the use of GPIO8 is recommended, since it is connected to an internal relay of the MTX-IOT-S

  • To remotely change the status of an output it must be done using an AT command sent remotely via Telnet and/or MQTT. The command to send is AT ^ MTXTUNNEL = SETIO, X, Y where X indicates the GPIO to act on (0… 8) and Y indicates the value of the output (0 = not activated/1 = activated)

  • To send the AT command to the modem via MQTT you must do it on the topic configured in MQTT_attopic1. Remember that if you configure something like [IMEI] / AT the modem will replace that text [IMEI] with its real IMEI, that is, for example for something like 354033091487838/AT. The modem will send the response to the command to the TOPIC specified in the MQTT_atropic parameter, which in the case of this example is [IMEI] / ATR

  • 5 When configuring the MQTT_defaultIOTopic parameter, the modem will report in that topic MQTT in real time of any change in the output GPIOs. For this reason, every time an output is changed from Telnet, the modem will send a JSON to said MQTT topic informing of the new status
    The sending format of these messages follows the JSON structure, shown in the following example:
    {
    “IMEI”:”354033091487838”,
    “TYPE”:”GPIO”,
    “TS”:” 2020-02-08T19:55:11Z”
    “ID”:0,
    “VALUE”:1
    “DIR”:”OUTPUT”
    }

    Where:
    – IMEI: indicates the IMEI of the MTX modem
    – TYPE: indicates the type of frame. GPIO = Digital input / output
    – TS: Timestamp (unix format specified in MTX_TPFormat)
    – ID: indicates the index of the GPIO (0 = GPIO0, 1 = GPIO1 …, 7 = GPIO7)
    – VALUE: indicates the value of the input (0,1)
    – DIR: indicates the type of pin (INPUT / OUTPUT)

  • Example of sending AT commands to remotely switch GPIO8 output from an MQTT broker and receiving the AT command response


     
  • Example of sending AT commands to switch GPIO8 output remotely from Telnet