Tunnel – Alarms sent by SMS and MQTT message before detection of 220V power loss and before the return of power. Modem with supercap of 1 minute of autonomy

Scenario details:

  • A modem is required to make a transparent IP-RS232 gateway to read a meter. It is also necessary that the modem can inform in case of a power failure, therefore the modem must have enough autonomy to send an alarm when the event occurs
  • For this, a modem with supercap will be used, which will give it an autonomy of approximately 1 minute. This modem must send an SMS alert to a phone number when a 220V power failure is detected. It must do the same when it detects that the power has recovered
  • In addition, the modem will send an alert message via MQTT to a control platform

Solution: MTX-Tunnel firmware + MTX-Java-IoT/MTX-Java-T/MTX-Java-T2 EXAMPLE of configuration (config.txt file) for the indicated scenario. Solution for quick communication via Socket TCP:

Configuration Observations

COMM_baudrate: 9600
COMM_bitsperchar: 8
COMM_autorts: off
COMM_autocts: off
COMM_stopbits: 1
COMM_parity: none
GPRS_apn: movistar.es
GPRS_timeout: 0
MTX_pin: 0000
MTX_mode: server
MTX_model: 199801464
SMS_allPhones: off
SMS_sendIP: off
SMS_ATEnabled: on
SMS_ATResponse: on
LOGGER_enabled: on
LOGGER_mode: mqtt
LOGGER_mqttTopic: [IMEI]/logger
MQTT_enabled: on
MQTT_server: tcp://test.mosquitto.org:1883
MQTT_attopic1: [IMEI]/AT
MQTT_atrtopic: [IMEI]/ATR
MQTT_qos: 1
MQTT_keepalive: 300
MQTT_persistent: off
ALARM_powerEnabled: on
ALARM_powerMessageOn: Alimentacion on
ALARM_smsNumber1: +34666123456

Serial port baud rate
8 bit data
No flow control
No flow control
1 stop bit
No parity
APN GPRS provided by the GSM operator
GPRS Login
GPRS Password
Permanent 3G session
The SIM card PIN (if there is any)
RS232 IP gateway in server mode
MTX modem model being used
Send SMS with commands from any phone
Modem won’t respond IP to a missed call/SMS
Commands can be sent to the MTX by SMS
MTX responds with an SMS to a command SMS
Saves the alarm to be sent by MQTT
Logger will send alarm by MQTT
MQTT topic where the alarm will be sent
MQTT service enabled in the modem
Broker IP/DNS, including port
Topic to which subscribes to receive commands
Topic where it sends the responses to commands
Service quality
300 seconds
Not necessary
Power failure alarm enabled
Refresh feed alarm text
Text alarm SMS for power failure
Alarm sending telephone


  • The model of modem used has an internal supercap that allows it to have an autonomy of approximately 1 minute once it loses power
  • When you try to reset the modem (removing the power supply) remember to wait 1 minute for the reset to occur. Remember that you can also reset the modem by sending the command AT + CFUN = 1,1
  • The MQTT message the modem will send when an alarm occurs due to lack of power will have this format:
{“IMEI”: 357299070187619, “TS”: “03/30/04 12:55:50”, “TYPE”: “POWER”, “APOW”: 1}
  • The MQTT message the modem will send when the power is restored will have this format:
{“IMEI”: 357299070187619, “TS”: “03/30/04 12:58:32”, “TYPE”: “POWER”, “APOW”: 0}

Where: IMEI: is the unique identifier of the modem TS: it is the time stamp of when the event occurred TYPE: indicates the type of data frame. POWER indicates power alarm APOW: 1 = active power alarm. 0 = power alarm deactivates