¿Buscas alguna otra cosa?

Tunnel – Reading of analog and digital inputs and switching of relays from an Android app via Bluetooth and GPRS/3G

Scenario details:

  • An app for Android telephones that allows for the automatic control of a loft is designed. We need to know the status of three windows (open/closed) as well as the status of the entrance door (open/closed). In a similar way, we wish to monitor the temperature at any time. Via 4 relays, we want to be able to: 1.- activate/deactivate the heating; 2.- activate/deactivate the main light; 3.- open/close the mechanical shutters
  • The app must show the information previously mentioned. It must also have buttons to be able to switch the different relays
  • The reading of analog and digital inputs, temperature and the switching of relays must be available via Bluetooth and GPRS/3G
  • In order to read temperature, an MTX-Temp-RS485 (modbus) sounding line will be connected to the terminal

Solution: MTX-3G-Java-BAT (with Bluetooth) modem + MTX-Tunnel software

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

COMM_baudrate: 9600
COMM_bitsperchar: 8
COMM_autocts: off
COMM_autorts: off
COMM_stopbits: 1
COMM_parity: none

COMM2_baudrate: 115200
COMM2_bitsperchar: 8
COMM2_autorts: on
COMM2_autocts: on
COMM2_stopbits: 1
COMM2_parity: none

GPRS_apn: internetestatico.movistar.es
GPRS_timeout: 0

MTX_PIN: 0000
MTX_model: MTX-IND-3G-Java
MTX_mode: server
MTX_portAux: gateway
MTX_ping: 30
MTX_urc: off

TCP_port: 20010
BLUETOOTH_enabled: on
BLUETOOTH_pin: 123499
BLUETOOTH_mode: server

FIREWALL_enabled: off
TELNET_enabled: on
TELNET_login: user
TELNET_password: 1234
Serial port baud rate
8 bit data
No flow control
No flow control
1 stop bit
No parity
Velocity of the Bluetooth serial port
Number of data bits
No flow control for Bluetooth
No flow control for Bluetooth
1 stop bit configured
No parity bit
APN GPRS provided by the GSM operator
GPRS Login
GPRS Password
Modem is always GPRS connected
If SIM card doesn’t have PIN, leave as 0000
Modem model
We do not want GPRS gateways
Serial-Serial gateway necessary for Bluetooth
Ping to ensure 3G/GPRS connectivity
IP to execute the ping
We do not need URC information messages
TCP port waiting for connections
Bluetooth activated
Bluetooth friendly name
PIN for the Bluetooth module (for security)
Operative mode of the Bluetooth module
Firewall disabled
Telnet is activated
Login for Telnet
Password for Telnet


  • The application is only available for Android and Windows telephones, and those devices that support Bluetooth communications using SPP protocol (Apple products do not support this for example)
  • As can be seen by analyzing the configuration file, the app must be programmed for communications with MTX-IND-3G-Java and to carry out readings of the digital inputs, switching of relays and measuring the temperature via AT commands send from a mobile phone to the MTX terminal.
  • In this manual, you will find the necessary AT commands for this. To read the digital inputs, we have the “AT^MTXTUNNEL=GETIOS” command. To switch relays, we have the “AT^MTXTUNNEL=SETRELAYS” command. To read modbus devices, we have the “AT^MTXTUNNEL=GETMODBUS” command.
  • The AT commands can be sent via 3G or via Bluetooth. To be able to send AT commands via 3G, first we must establish a Telnet connection on the MTX device. To be able to sent AT commands via Bluetooth, first we need to create an SPP (Serial Port Profile) Bluetooth connection from the mobile phone to MTX