This example shows how to configure MTXTunnel so that you can control 4 relays via SMSs. Relays can be used to activate/deactivate lights, boilers etc. Let’s take a look at the details of this example scenario.

Example Scenario Details:

• You need to control 4 relays via SMS to activate or deactivate some lights in a remote location.

• We want to send an SMS with the text ONx or OFFx (x is 1,2,3 or 4) to activate or deactivate the respective relays, to do this you need to create some ALIAS in the modem.

• Only the company’s 100 authorized numbers should be able to send an SMS, only the numbers that begin with 6662746XX.

• You only need access to relays via SMS, however you should be able to activate MTXTunnel’s WEBSERVER (by sending an SMS with the text “mtxtunnel on” or a missed call) in 10 minute sessions to do maintenance tasks like reconfiguring MTXTunnel as well as accessing relays from a PC browser.

Proposed solution with MTX-IND + MTXTunnel

MTX-IND + 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:

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: 10 GPRS maintenance sessions will last 10 minutes 
MTX_PIN: 0000 If the SIM card doesn’t have a pin, leave it as 0000
MTX_model: MTX65IND MTX65IND model is chosen due to relays
MTX_mode: none We don’t need GPRS-serial tunnels
MTX_urc: off We don’t need URC information messages
WEBSERVER_enabled: on WebServer service enabled
WEBSERVER_login: user Webserver Login
WEBSERVER_password: 1234 Webserver Password
WEBSERVER_skin: http://www.mtxtunnel.com/webserverimg/ WebServer Skin
WEBSERVER_gsmScript: http://www.blogelectronica.com/gps/gsm.php Script localiz. GSM
FIREWALL_enabled: off Firewall deactivated so connections from any IP are accepted.
SMS_allPhones: off We just want the 100 authorized phone numbers
SMS_validPhone1: 6662746 We indicate the common part of the 100 telephone numbers
SMS_ATEnabled: on AT commands accepted via SMS
SMS_ATResponse: on AT command response is returned by SMS
SMS_alias1: ON1>AT^SSIO=0,0 We have activated Relay1 when you receive an SMS with ON1
SMS_alias2: OFF1>AT^SSIO=0,1 We have deactivated Relay1 when you receive an SMS with OFF1
SMS_alias3: ON2>AT^SSIO=1,0 We have activated Relay2 when you receive an SMS with ON2
SMS_alias4: OFF2>AT^SSIO=1,1 We have deactivated Relay2 when you receive an SMS with OFF2
SMS_alias5: ON3>AT^SSIO=2,0 We have activated Relay3 when you receive an SMS with ON3
SMS_alias6: OFF3>AT^SSIO=2,1 We have deactivated Relay3 when you receive an SMS with OFF3
SMS_alias7: ON4>AT^SSIO=6,0 We have activated Relay7 when you receive an SMS with ON4
SMS_alias8: OFF4>AT^SSIO=6,1 We have deactivated Relay7 when you receive an SMS with OFF4
SMS_aliasOk: Command Ok This SMS is sent if the SMS command has worked 
SMS_aliasError: Command Error This SMS is sent if the SMS command hasn’t worked

With this configuration, some ALIAS are configured. You can find the complete explanation on ALIAS in the MTXTunnel manual, but they are basically used for the following:  MTXTunnel can run AT commands via SMS. To switch a relay all you have to do is send an AT command for example ”AT^SSIO=0,0″ if you want to switch Relay1. Obviously it’s complicated to remember and type out on a mobile phone. MTXTunnel allows the use of ALIAS i.e. you can set a password so that when the MTXTunnel receives this password via SMS, this password runs the AT command that it is associated with. In the ALIAS example shown ”ON1″ runs the AT command “AT^SSIO=0,0″, so all you would have to do is send an SMS with the word “ON1″ to switch a relay.

 

Comments




The example that I am going to show below is similar to the one before but instead of controlling relays via SMS, we are going to do it via GPRS. Let’s imagine that we want to make an application for a PC that connects to various geographically distributed GPRS devices to switch relays and to read the states of 6 digital inputs and 2 analog inputs, one 0-2.4V and the other 4-20mA. We are going to use MTXTunnel-IND with the 4 relays, 6 digital inputs and 2 analog inputs.

How do we do it? Well we’ll do it the easiest way, with Telnet. MTXTunnel supports Telnet, for example we can open an Ms-Dos console and write “Telnet xxx.xxx.xxx.xxx”, the xxx.xxx.xxx.xxx is the MTXTunnel’s current IP address. Our PC would connect remotely (with Internet connectivity) with the MTXTunnel that has GPRS connectivity. Once they are connected via Telnet, we can send AT commands to the modem. Let’s look at an example:

In this example we see that we have connected to MTXTunnel via Telnet and we send the command AT+CSQ. That command is used to find out the GSM coverage (remotely!). As well as using an AT command to read GSM coverage, we can use another AT command to switch relays. Specifically we use these AT commands:

AT^SSIO=0,0 and AT^SSIO=0,1   to enable and disable Relay 1 from the device called RL1
AT^SSIO=1,0 and AT^SSIO=1,1    to enable and disable Relay 2 from the device called RL2
AT^SSIO=2,0 and AT^SSIO=2,1    to enable and disable Relay 3 from the device called RL3
AT^SSIO=6,0 and AT^SSIO=6,1   to enable and disable Relay 4 from the device called RL7

And to read the 6 digital inputs we use:

AT^SGIO=3
AT^SGIO=4
AT^SGIO=5
AT^SGIO=7
AT^SGIO=8
AT^SGIO=9

And finally for analog inputs we use:

AT^SRADC=0    to read the A/D converter configured as 0-2.4V
AT^SRADC=1    to read the A/D converter configured as 4-20mA

So we can easily send these AT commands through an MS-Dos console via Telnet, but it’s also very easy to program an application (in Visual Basic, .Net, C#, java …) that connects to the TCP23 port from MTXTunnel (or the configured TCP port) and sends these AT commands to switch relays or read digital/analog inputs.

Finally we will enable DynDNS service in this example. Therefore you won’t have to pay for a SIM card with a fixed IP address.

MTX-IND + 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:

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 to GPRS
MTX_model: MTX65IND MTX65IND is the chosen MTX model
MTX_mode: none GPRS-Serial tunnel not needed
FIREWALL_enabled: off Firewall deactivated 
TELNET_enabled: on Telnet activated
TELNET_port: on TCP port for Telnet
TELNET_login: user Login for Telnet
TELNET_password: 1234 Password for Telnet
DYNDNS_enabled: on DynDNS service activated
DYNDNS_server: members.dyndns.org DynDNS server account created
DYNDNS_hostname: mtxtunnel.dyndns.org MTXTunnel’s DNS name created in DynDNS
DYNDNS_login: usuario DynDNS username
DYNDNS_password: miPassword DynDNS password

Comments