Example scenario details:

  • We have a PLC Modbus RTU. This PLC has various variables/registers in its internal memory (for example, 1 temperature and 3 meters…) which need to be periodically read and sent to a Web server.
  • Therefore, MTXTunnel must periodically get information (every 15 minutes) through a serial port and the PLC to read the data.  The data that needs to be read are: record nº20 for temperature and the meters are records 21,22 and 23 respectively.
  • MTXTunnel must send the value of the registers after reading them to a web server via HTTP GET using a JSON object. It must be able to save up to 1500 readings in its flash memory in case of communication failure, this is  so that it can send them when communication is restored.
  • You must be able to access MTXTunnel at any time so that you can read the PLC registers in real time as well as being able to write in them and modify PLC configuration registers.

Proposed solution with MTX-65i + MTXTunnel

MTXTunnel configuration file for the proposed solution above:

You have to enter this into the modem’s configuration file to be able to run the application as described in the scenario:

 COMM2_baudrate: 9600 Speed of communication between serial port and PLC
 COMM2_bitsperchar: 8 Number of data bits
 COMM2_autorts: off No flow control
 COMM2_autocts: off No flow control
 COMM2_stopbits: 1 1 stop bit
 COMM2_parity: none No parity
 GPRS_apn: movistar.es GPRS APN provided by GSM operator
 GPRS_login: MOVISTAR GPRS Login provided by GSM operator
 GPRS_password: MOVISTAR GPRS Password provided by GSM operator
 GPRS_timeout: 0 The modem will be permanently connected
 MTX_PIN: 0000 SIM card’s PIN number
 MTX_mode: none GPRS-Serial gateway mode. Set to none as we don’t use it
 MTX_model: MTX65i MTX65i model used with MTXTunnel
 MTX_portAux: modbusmaster The aux port used as master modbus
 MTX_TPServer: time-a.timefreq.bldrdoc.gov Time server (MTX must synchronize the time)
 MTX_TPServer2: ptbtime1.ptb.de Back-up time server
 MTX_ping: 35 Every 35 minutes with communication, we do a ping
 MTX_pingIP: Address where we run the ping
 MTX_radioBand: europe Not necessary. It says Europe if the MTX is installed in Europe
 MTX_rssiLevel: 10 This activates the MTX65i’s coverage led
 SMS_allPhones: on You can send commands via SMS from any mobile
 SMS_sendIP: on The modem responds with its IP to a missed call or SMS
 SMS_ATEnabled: on You can send commands to MTX via SMS
 SMS_ATResponse: on MTX will respond with an SMS to an SMS that it receives with a command
 FIREWALL_enabled: off You can connect to the modem from any IP (for Telnet)
 TELNET_enabled: on Telnet is enabled
 TELNET_login: user Telnet Login
 TELNET_password: 1234 Telnet Password
 TELNET_firewall: off You can connect to MTX via Telnet from any IP 
 LOGGER_enabled: on MTX logger enabled to store data
 LOGGER_password: ID00001 This field allows us to identify where frames come from
 LOGGER_server: www.miservidorWeb.com/json.asp?data= The JSON and data will be sent to this URL
 LOGGER_registerSize: 300 The MTX’s internal register size 
  LOGGER_numRegistersFlash: 1500 The maximum number of registers inside MTX
 MODBUS_address: 1 Modbus device’s address (to read)
 MODBUS_start: 20 Initial modbus registers address (to read)
 MODBUS_numwords: 4 Number of registers to read apart from the initial one
 MODBUS_period: 900 MODBUS_period: 900



  • The MTX65i is used in this example with RS232 communication for MODBUS communication with a PLC, but it could be a RS485 without any problems. To do this you could use an MTX-65iRS485 model (with incorporated RS485 communication).
  • The following is a summary of this example: the modem periodically reads (every 15 mins) a series of Modbus registers from the PLC and sends them to web server via JSON object. It sends them to the URL specified in the LOGGER_server parameter. If the register cannot be sent (if there is not GPRS coverage or the server has failed), it saves the data to memory so that it can send them later. With Telnet, you can connect directly to the device and consult/change PLC registers in real time (for this search for the following commands in the manual AT^MTXTunnel=getmodbus and AT^MTXTUNNEL=setmodbus).
  • The JSON object sent to the URL specified in LOGGER_server is encoded like the following example:{“IMEI”:353234028103206,”P”:”ID00001″,”A”:1,”TS”:”20/08/12 08:31:44″,”V1″:23,”V2″:275,”V3″:274,”V4″:32765}
    This means that the web server receives a JSON object with the modem’s IMEI (IMEI), a password field (P) that can also be used to identify the device (if you don’t want to use the IMEI), the device’s modbus address (A), the time stamp (TS) of when the modbus data was read, and V1,V2, … with every one of the read variables.