Suchen Sie etwas anderes?
Scenario details:
- We have a PLC with RS485 Modbus RTU communications that, acting as master, performs periodic readings of 3 slave devices also with Modbus RTU RS485 communications
- We want to replicate the same scenario with the same devices, but with IP communications, since it is not possible to make a wiring to find the different elements located far away
- We will use affordable SIM cards with dynamic and private IP, so the devices can’t communicate with each other. An MQTT broker will be used as an intermediary. The master will send the modbus requests to the MQTT broker, which will forward the slaves via MQTT. The responses of the slave modems are forwarded to the MQTT broker, which in turn are forwarded to the master modem
Solution: MTX-Tunnel firmware + MTX-Java-IoT/MTX-Java-T/MTX-Java-T2
Config.txt configuration file (master):
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_login: MOVISTAR GPRS_password: MOVISTAR GPRS_timeout: 0 MTX_PIN: 0000 MTX_mode: mqtt MTX_model: 199801445 MTX_ping: 35 MTX_pingIP: 8.8.8.8 MTX_invertedCom: on MTX_msToSend: 250 SMS_allPhones: on SMS_sendIP: on SMS_ATEnabled: on SMS_ATResponse: on FIREWALL_enabled: off MQTT_enabled: on MQTT_server: tcp://test.mosquitto.org:1883 MQTT_id: [IMEI] MQTT_attopic1: [IMEI]/AT MQTT_atrtopic: [IMEI]/ATR MQTT_keepalive: 300 MQTT_commrxtopic: rxmaster MQTT_commrxtopic: txmaster |
Serial port baud rate 8 bit data No flow control No flow control 1 stop bit No parity GPRS APN from your network operator GPRS Login GPRS Password MTX-Tunnel is always GPRS connected If SIM card has no PIN security, use 0000 value MQTT serial gateways will be used MTX-Terminal modem model used One ping every 35 min. without communications Ping address Gateway port RS485 No fragmented networks Send SMS with commands from any phone Modem responds with its IP to a missed call/SMS Commands can be sent to the MTX by SMS MTX responds with an SMS to a command SMS Any incoming connection form any IP is allowed MQTT service enabled Broker IP/DNS specified, including identifying port Identifier MQTT topic to send AT commands Topic to send replies to commands to Connection keep alive (300 seconds) Data received will be retransmitted via serial Data received v/serial, retransmitted to this topic |
Config.txt configuration file (slave):
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_login: MOVISTAR GPRS_password: MOVISTAR GPRS_timeout: 0 MTX_PIN: 0000 MTX_mode: mqtt MTX_model: 199801445 MTX_ping: 35 MTX_pingIP: 8.8.8.8 MTX_invertedCom: on MTX_msToSend: 250 SMS_allPhones: on SMS_sendIP: on SMS_ATEnabled: on SMS_ATResponse: on FIREWALL_enabled: off MQTT_enabled: on MQTT_server: tcp://test.mosquitto.org:1883 MQTT_id: [IMEI] MQTT_attopic1: [IMEI]/AT MQTT_atrtopic: [IMEI]/ATR MQTT_keepalive: 300 MQTT_commrxtopic: txmaster MQTT_commrxtopic: rxmaster |
Serial port baud rate 8 bit data No flow control No flow control 1 stop bit No parity GPRS APN from your network operator GPRS Login GPRS Password MTX-Tunnel is always GPRS connected If SIM card has no PIN security, use 0000 value MQTT serial gateways will be used MTX-Terminal modem model used One ping every 35 min. without communications Ping address Gateway port RS485 No fragmented networks Send SMS with commands from any phone Modem responds with its IP to a missed call/SMS Commands can be sent to the MTX by SMS MTX responds with an SMS to a command SMS Any incoming connection form any IP is allowed MQTT service enabled Broker IP/DNS specified, including identifying port Identifier MQTT topic to send AT commands Topic to send replies to commands to Connection keep alive (300 seconds) Data received will be retransmitted via serial Data received v/serial, retransmitted to this topic |
Details:
- The master modem forwards all the modbus requests it receives in its RS485 serial port to the MQTT broker, specifically to the “txmaster” topic. The slave modems, as they are subscribed to the topic “txmaster” of the MQTT broker, automatically receive said requests from the master, which in turn are forwarded by their RS485 serial port.
And the other way around, the slave modems forward all the data they receive through their RS485 serial port (the modbus responses) to the mqtt broker, to the “rxmaster” topic. As the master modem is subscribed to the topic “rxmaster”, the MQTT broker immediately sends us those responses, which are forwarded through its RS485 serial port - Keep in mind that communications latencies may be somewhat greater than direct communication latencies since there is an intermediary (the mqtt broker) and the speed of communications will depend on the power of the latter. Set the timeout if necessary.