Developing a simple energy control Demo with an M2M Development Kit, where a switch can be turned on and off via the internet.
For this demo the Cinterion EGS5 Development Kit and a simple switch, which can be switched via a RS232-port are used.
You don’t need this switch. If you just want to test, you can simply connect a resistor and an LED to the port, like in the picture below.
This demo consists of two parts. One part is the Java™ application on the module and the other part is the Website and a simple text file on a server.
A Java™ Application is running inside the Module. If the program is started, some static variables (e.g. destination host and connection profile) will be initialized. Then, every ten seconds, a loop is executed. In this loop, the Http connection to the server is set up and as input stream it receives the bytes of a text file. These bytes will be converted to characters and combined to a string. If this string is “on”, the COM-port is opened and if this string is “off”, the port will be closed. Any other string will close the port if it is opened and then the application will be terminated.
The Website is simple. It loads the text file and look up the word, which is in this file. Then the labeling of a button and a picture of a light are automatically adapted. When the button is clicked, it changes the word in the text file to the opposite (from “on” to “off” or vice versa). At the same time the button and the picture are updated again.