Tunnel – Instant sending of telemetry via MQTT of up to 8 digital inputs.

¿Buscas alguna otra cosa?

Scenario details:

  • 8 dry contact sensors need to be monitored. In the state of the entries, it must be sent quickly to an MQTT platform (example Cervello) when a change occurs in one of them
  • For the first four inputs, the modem must be configured to send via MQTT any state change that occurs in them (input enabled (to ground) / input disabled (open)). In the last four digital inputs, it should only be sent via MQTT when there is an activation on one input (ground input)
  • To avoid sending a large number of messages (in case of rapid changes in certain inputs), a timeout of 10 seconds should be established for inputs GPIO4 and GPIO5. This implies that no matter how many changes occur in GPIO4 and GPIO5, no more than 1 MQTT message can be sent in a 10 second window

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_TPProtocol: ntp
MTX_TPServer: ntp.roa.es
MTX_TPServer2: es.pool.ntp.org
MTX_TPFormat: unix
SMS_allPhones: on
SMS_sendIP: on
SMS_ATEnabled: on
SMS_ATResponse: on
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_qos: 1
MQTT_keepalive: 60
MQTT_defaultIOQos: 0
MQTT_defaultIOTopic: IOCHANGE
GPIO_mode0: input
GPIO_config0: mqtt;2;0
GPIO_mode1: input
GPIO_config1: mqtt;2;0
GPIO_mode2: input
GPIO_config2: mqtt;2;0
GPIO_mode3: input
GPIO_config3: mqtt;2;0
GPIO_mode4: input
GPIO_config4: mqtt;2;0
GPIO_mode5: input
GPIO_config5: mqtt;2;0
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
Time synchronization protocol
Time server
Time server backup
Unix time format
IP by SMS authorized
IP by SMS authorized
AT by SMS allowed
SMS AT responses activated
MQTT service
MQTT broker. Protocol format://url:port
Device ID in broker
Username
Password
Topic of the MTX to receive AT commands
Topic where MTX sends its answers to AT commands
QoS established
Keepalive
Qos for defaultIOTopic
MQTT topic to send quick telemetries
GPIO0 configured as input
GPIO0 MQTT configuration
GPIO1 configured as input
GPIO1 MQTT configuration
GPIO2 configured as input
GPIO2 MQTT configuration
GPIO3 configured as input
GPIO3 MQTT configuration
GPIO4 configured as input
GPIO4 MQTT configuration
GPIO5 configured as input
GPIO5 MQTT configuration

Details:

  • The configuration of the inputs as “mqtt; 2; 0” indicates the following. Remember that all parameters are separated by semicolons ;
    “mqtt” > The input is configured to send the states of the digital inputs by MQTT
    “2” > The 2 indicates that the digital input is configured to send an MQTT message both for activation of the input (when it closes taking it to ground) and for deactivation of the input (when it opens). If you want to send an MQTT message only when closing the entry (bringing it to ground), you should indicate a value of “1”
    “0” > Indicates the timeout of the digital input. This means that the change of the digital input will be sent whenever it occurs. If, for example, a value of “10” were configured, as is the case with GPIO4 and GPIO5, even if there are multiple activations in the digital input, more than 1 MQTT message will never be sent in those 10 seconds

  • The sending format of these messages follows the JSON structure, shown in the following example:
    {
    “IMEI”:”354033091487838”,
    “TYPE”:”GPIO”,
    “TS”:” 2020-02-08T18:35:15Z”
    “ID”:”0”,
    “VALUE”:1,
    “DIR”:”INPUT”
    }

    Where:
    – IMEI: indicates the IMEI of the MTX modem
    – TYPE: indicates the type of frame. “GPIO” is for digital I / O frames
    – 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)

  • The data of the digital inputs / outputs configured as “mqtt” are sent to the topic configured in the parameter “MQTT_defaultIOTopic”