Tunnel – Advanced example for modbus devices reading and broadcasting to a web platform via a JSON object

¿Buscas alguna otra cosa?

Scenario details:

  • We have 3 modbus RTU devices. It is recommended that the MTX-Tunnel polls them periodically sending the records to a web platform via a JSON object. The web platform requires login and password authentication
  • The MTX-Tunnel must periodically poll, every 2 minutes and via its serial port RS485, the 3 ModBus devices. The records to read are different for each device:
    • Device 1: records 20 to 21 and records 100 to 105
    • Device 2: records 30 to 35
    • Device 3: records 40 to 60
    • Devices 1 and 2 will use the modbus read command 0x03 (the most common). Device 3 will use the modbus read command 0x04.
  • Records 20 to 21 of Device 1 must be read and sent to the web platform every 2 minutes. Records 100 to 105 will also be read every 2 minutes but we only want to send them to the web platform every 10 minutes
  • Records 30 to 35 of Device 2 will be read every 2 minutes, but they will only be sent to the web platform when the value of one of the records differs by “10” or more from the last record sent
  • Records 40 to 60 of Device 3 will be read every 2 minutes. They will be sent to the web platform every 60 minutes but a reading will also be sent if any record differs by “25” or more from the last record sent

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_TPProtocol: ntp
MTX_TPServer: ntp.roa.es
MTX_TPServer2: es.pool.ntp.org
MTX_ping: 35
MTX_pingIP: 8.8.8.8
SMS_allPhones: on
SMS_sendIP: on
SMS_ATEnabled: on
SMS_ATResponse: on
FIREWALL_enabled: off
TELNET_enabled: on
TELNET_login: user
TELNET_password: 1234
TELNET_port: 20023
LOGGER_enabled: on
LOGGER_password: ID00001
LOGGER_server: www.miservidorWeb.com/json.asp?data=
LOGGER_registerSize: 300
LOGGER_numRegistersFlash: 1500
LOGGER_serverLogin: miLogin
LOGGER_serverPassword: 12345678
LOGGER_httpMode: getjson
MODBUS_address: 1;1;2;3
MODBUS_start: 20;100;30;40
MODBUS_numwords: 2;6;6;21
MODBUS_period: 120
MODBUS_readCommand: 3;3;3;4
MODBUS_logFrequency: 1;5;1;30
MODBUS_changeDiff: 0;0;10;25
MODBUS_logType: 0;0;1;2
Serial port baud rate
Number of bits
No flow control
No flow control
1 stop bit
No parity
APN GPRS from your network operator
GPRS Login
GPRS Password
Modem is always GPRS connected
SIM Card PIN
MTX-Tunnel mode
MTX modem model
AUXILIAR COM port used as master modbus
Time synch. protocol
Time server
Backup time server
Ping every 35 minutes without comms
IP address to ping
All phone numbers are authorized
IP sent to phone which called or “on” SM
Remote AT commands by SMS enabled
Modem response to AT command with SMS
Any IP will be able to connect to the modem
Telnet is activated
Telnet login
Telnet password
Telnet port is 20023
We enable the MTX Logger, to store the records
Password field can be used as ID device
Server URL, will receive JSON data
Register size
Maximum number of records in MTX
Web platform login
The password of the web platform
HTTP GET (JSON) mode
ModBus addresses of devices to be read
Initial addresses of each device
Number of records read from each device
Frequency of readings in seconds
First 2 devices use 0x03 and the other 2 0x04
Device 1 sends variables every 1 and 5 records. Device 3 every 30 records
Device 2 controls if record variation is >=10. Device 2 controls if record variation is >=25
Device 1 sends with regards to time. Device 2 sends change in value. Device 3 sends time and/or change in value

Details: