Looking for something else?
Tunnel – Using API to switch a relay from a third-party or end user webpage
- 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:
|GPRS APN from your network operator
Modem is permanently connected to GPRS
MTX-Terminal modem model used
Minutes for connectivity supervision ping
Connectivity supervision IP address
Internal webserver enabled
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.
- The address 126.96.36.199 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