Suchen Sie etwas anderes?
Scenario details:
- We have a Modbus RTU PLC. This PLC has in its internal memory a series of variables / registers (for example, a temperature and 3 counters, …) which must be read and periodically sent to an MQTT broker
- Therefore, the MTX-Tunnel must periodically interrogate the PLC through a serial port every 15 minutes to read these registers. The registers to be read are: for the temperature register nº20, and the counters are in registers 21, 22 and 23 respectively
- The MTX-Tunnel must send the value of the registers after each reading to an MQTT broker using a JSON object, but it must be able, in case of 2g / 3g / 4g communications failure, to store in flash memory up to 1500 readings that it will send when communications are restored
- For more security in communications, the modem must have DUAL SIM. In other words, the modem must have 2 SIM cards from 2 different telephone operators. The modem will need to change SIMs as long as it cannot get an IP address for more than 120 seconds
Solution: MTX-Tunnel firmware + MTX-IOT-S [4-N]
Config.txt configuration file:
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_apn2: airtelnet.es GPRS_login2: vodafone GPRS_password2: vodafone GPRS_timeout: 0 MTX_PIN: 0000 MTX_mode: none MTX_model: 199802407 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 MTX_rssiLevel: 10 SMS_allPhones: on SMS_sendIP: on SMS_ATEnabled: on SMS_ATResponse: on FIREWALL_enabled: off LOGGER_enabled: on LOGGER_mode: mqtt LOGGER_mqttTopic: /LOGGER LOGGER_registerSize: 300 LOGGER_numRegistersFlash: 1500 MODBUS_address: 1 MODBUS_start: 20 MODBUS_numwords: 4 MODBUS_period: 900 MODBUS_readCommand: 3 DUALSIM_select: dual DUALSIM_mode: ip DUALSIM_timeout: 120 MQTT_enabled: on MQTT_server: tcp://test.mosquitto.org:1883 MQTT_id: [IMEI] MQTT_login: MQTT_password: MQTT_attopic1: [IMEI]/AT MQTT_atrtopic: [IMEI]/ATR MQTT_qos: 1 MQTT_keepalive: 60 |
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 GSM operator GPRS APN. Secondary SIM GSM operator GPRS login. Secondary SIM GSM operator GPRS password. Secondary SIM 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 We activate the coverage LED 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 We enable the MTX Logger, to store the records Shipping mode by MQTT Sending topic to MQTT broker to send counter data Register size Maximum number of records in MTX ModBus addresses of devices to be read Initial addresses of each device Number of records read from each device Frequency of readings in seconds Read command DUAL SIM mode activated with external initial SIM SIM change mode Timeout for SIM change in case of problems MQTT service enabled Broker IP/DNS specified, including identifying port Identifier Username Password MQTT topic to send AT commands Topic to send replies to commands to QoS established Connection keep alive (60 seconds) |
Details:
- In this example a modem is used using the RS485 port, but the RS232 port could be used without problems (to use the RS232 port the parameter MTX_invertedCom: on should be entered)
- The summary of this example is as follows: the modem periodically reads, every 15 minutes, a series of ModBus registers from the PLC and sends them via a JSON object to an MQTT broker (to the topic specified in the LOGGER_mqttTopic parameter). In case of not being able to send the record (because there is no coverage at that time or the server is down) it stores the data in memory to send them later. Using MQTT commands it is also possible to connect to the equipment directly and consult / change the PLC registers in real time (to do this, search in this manual for the commands AT ^ MTXTunnel = getmodbus and AT ^ MTXTUNNEL = setmodbus)
- The JSON object sent to the MQTT broker is encoded as follows, as an example:
{“IMEI”:353234028103206,”P”:”ID00001”,”TYPE”:”MODB”,”A”:1,”TS”:”20/08/12 08:31:44”,”ST”:20,”V1”:23,”V2”:275,”V3”:274,”V4”:32765} - The modem has DUAL SIM (DUALSIM_mode: dual) configured. This will cause the modem to boot using the primary SIM card, which in the case of the MTX-IOT-S [4-N] modem is the external SIM card. In case coverage is lost and it is not possible to register on the operator network for 60 seconds (DUALSIM_timeout), the modem will switch to the secondary SIM card