Tunnel – Reading and writing Modbus registers via SMS

¿Buscas alguna otra cosa?

Scenario details:

  • We have a PLC with Modbus protocol and address 1
  • It is necessary to read different Modbus registers via SMS. Register 10 (current temperature), register 12 (pressure) and register 14 (current humidity)
  • It is also necessary to be able to write “1” via SMS in Modus16 register. This way the PLC will activate a relay during a pre-configured time period
  • SMS should be send only from the authorized mobile phones: 666123456 and 666123457
  • SMS commands sent should be simple with the following texts: TEMP, PRES, HUM (to read registers 10,12 and 14 respectively). An SMS with the text RELE will write “1” in register 16 to activate the relay
  • It also should be possible to carry out configuration changes remotely via TELNET

Solution: MTX-Tunnel firmware + MTX-Java-IoT/MTX-Java-T/MTX-Java-T2

EXAMPLE of settings (file config.txt) for such scenario:

Configuration Observations
COMM2_baudrate: 9600
COMM2_bitsperchar: 8
COMM2_autorts: off
COMM2_autocts: off
COMM2_stopbits: 1
COMM2_parity: none
GPRS_apn: movistar.es
GPRS_login: MOVISTAR
GPRS_password: MOVISTAR
GPRS_timeout: 0
MTX_PIN: 0000
MTX_mode: none
MTX_model: MTX-4G-JAVA-IOT-STD-N
MTX_portAux: modbusmaster
MTX_ping: 35
MTX_pingIP: 8.8.8.8
MTX_radioBand: europe
SMS_allPhones: off
SMS_validPhone1: +34666123456
SMS_validPhone2: +34666123457
SMS_sendIP: on
SMS_ATEnabled: on
SMS_ATResponse: on
SMS_alias1: TEMP>AT^MTXTUNNEL=GETMODBUS,1;10;1;3
SMS_alias2: PRES>AT^MTXTUNNEL=GETMODBUS,1;12;1;3
SMS_alias3: HUM>AT^MTXTUNNEL=GETMODBUS,1;14;1;3
SMS_alias4: RELE>AT^MTXTUNNEL=SETMODBUS,1;16;1
SMS_aliasResponse: result
SMS_aliasError: Error
FIREWALL_enabled: off
TELNET_enabled: on
TELNET_login: user
TELNET_password: 1234
TELNET_port: 20023
TELNET_firewall: off
Serial port baud rate
Number of bits
No flow control
No flow control
1 stop bit
No parity
APN of SIM card
GPRS Login
GPRS Password
Modem is always GPRS connected
SIM Card PIN
Working mode set as none as we do not use them
MTX modem model
AUXILIAR COM port used as master modbus
Ping every 35 minutes without comms
IP address to ping
If modem is installed in Europe
SMS with commands sent from authorized phone
Authorized mobile phone 1
Authorized mobile phone 2
Modem replies with its IP to a missed call or SMS
Remote AT commands by SMS enabled
Modem response to AT command with SMS
Alias for temperature reading
Alias for pressure reading
Alias for humidity reading
Alias for relay activation
Modem returns the result only, no AT command
Modem returns text “Error” when executing alias
Any IP will be able to connect to the modem
Telnet is activated
Telnet login
Telnet password
Telnet port
Any IP will be able to connect to the MTX

Details:

  • When the value “result” is set in the parameter SMS_aliasResponse, the response SMS to ALIAS will not contain executed AT command
  • For example, if SMS_aliasResponse parameter has the value “full”, the following will occur:
    • SMS sent: TEMP
    • SMS received: AT^MTXTUNNEL=GETMODBUS,1;10;1;3
    • 25
    • OK
  • If SMS_aliasResponse parameter has the value “result”, the following will occur:
    • SMS sent: TEMP
    • SMS received: TEMP > 25
  • If SMS_aliasError parameter configuration contains the text “Error”, the response SMS to ALIAS, in case of error, will have the following response:
    • SMS sent: TEMP
    • SMS received: TEMP > Error
  • Remember that the modem model used in this example disposes of 2 serial ports. In the given example the main port (RS232) and the secondary port (RS232 or RS485) are used. To configure the secondary port as RS485 you should set “ON” in microswitch 2, as it is explained in Annex A of the this manual