Tunnel – Using API to switch a relay from a third-party or end user webpage

¿Buscas alguna otra cosa?

Scenario details:

  • We want to program a web page and switch 1 relay, to switch a lamp on/off. For that we will use MTX-4G-JAVA-IOT-STD-RL with internal relay
  • An end user will open the web page and will switch the external lamps on/off with the click of a mouse. MTX-Tunnel has to communicate the webpage data with modem’s GPIOs

Solution: MTX-Tunnel firmware + MTX-Java-IoT

Config.txt configuration file:

Configuration Observations
GPRS_apn: movistar.es
GPRS_login: MOVISTAR
GPRS_password: MOVISTAR
GPRS_timeout: 0
MTX_model: MTX-4G-JAVA-IOT-STD-RL
MTX_ping: 30
MTX_pingIP: 8.8.8.8
WEBSERVER_firewall: off
WEBSERVER_enabled: on
WEBSERVER_login:user
WEBSERVER_password: 1234
WEBSERVER_skin: http://www.mtxtunnel.com/webserverimg/
WEBSERVER_gsmScript: http://www.blogelectronica.com/gps/gsm.php
GPRS APN from your network operator
GPRS Login
GPRS Password
Modem is permanently connected to GPRS
MTX-Terminal modem model used
Minutes for connectivity supervision ping
Connectivity supervision IP address
Firewall disabled
Internal webserver enabled
Webserver login
Webserver password
Webserver skin
Script GSM positioning

HTML web page example code:

We will switch the relay. We will not show the initial relay state to simplify the example.

The web page aspect is shown in the following picture. Only this simple HTML code translates the link in an AT command to be sent remotely. The AT command changes GPIO output level.

Source code:

Details:

  • The address 176.80.120.20 shown in the example is the MTX SIM IP. If you don’t have a SIM with a fixed IP you can check the parameters and examples DYNDNS_ on this guide
  • To switch the MTX-4G-JAVA-IOT-STD-RL relay is necessary to act on GPIO6, like in the E/S tables of the different models, that can be found on this guide