Hi everybody,

In this post I'm gonna share with you my new application that simple embedded server to control and measure somethings over the internet.

Nowadays as you know IoT is popular topic and may become more popular. Even there is a motto that "by 2020 50 billion devices will be connected to the internet" recently I saw it is changed as 37 billion. Why changed or who counts these devices I don't know. Actually I don't believe that. :) Because IoT is a just name, alias, motto etc. These applications, sytems, techniques already were have. Today with IoT these are highlighted. Anyway, it is good for us, because by IoT trend so many tools, kits and hardwares which releated IoT became cheaper and available.

Of course IoT pushed technology companies to develop products, kits, modules, hardwares for IoT applications, cheap as well. One of them is Tiva Connected launchpad. It is really has a wonderful price/performance rate. It is just $19.99, it has a so many features and also has an ethernet hardware. So by just using launchpad you can make internet applications over the ethernet. Anyway I'm not a saller for TI I just had it and I used it. Lets talk about application.

Step 1: Web Server Application

Picture of Web Server Application

As you know servers are big and expensive systems. These are serve us web sites, audios, videos, files etc. Comparing to web servers launchpad is really simple. With launchpad we can't serve so complex and functional web sites or files. We don't care that because we just want control electrical devices and measure some quantities over the internet.

In this context I made simple web site. You can see the screenshot of the site above.

As you see site is a very simple. It just has a few texts, buttons and geometric draws. Launchpad has a four LEDs and two push buttons for general purposes usage. On the web site I used buttons to control LEDs and filled circles to see LEDs and buttons situations. Also text elements are used to give information. You can see HTML and JavaScript codes of the site below.

<!DOCTYPE html>
<html>
<head>
<title>Erhan Web Page</title>
<script>
var led1, x1, led2, x2, led3, x3, led4, x4;
function GetSwitchState()
{
	nocache = led1 + led2 + led3 + led4 + "&nocache="+ Math.random() * 1000000;
	var request = new XMLHttpRequest();
	request.onreadystatechange = function() 
	{
		if (this.readyState == 4) 
		{
			if (this.status == 200) 
			{
				if (this.responseText != null)
				{
					if (this.responseText.indexOf("LED1ON") > -1)
					{
						document.getElementById("LED1").style.fill = "yellow";
					}
					else 
					{
						document.getElementById("LED1").style.fill = "black";
					}
				
					if (this.responseText.indexOf("LED2ON") > -1)
					{
						document.getElementById("LED2").style.fill = "yellow";
					}
					else 
					{
						document.getElementById("LED2").style.fill = "black";
					}
	
					if (this.responseText.indexOf("LED3ON") > -1)
					{
						document.getElementById("LED3").style.fill = "yellow";
					}
					else
					{
						document.getElementById("LED3").style.fill = "black";
					}
	
					if (this.responseText.indexOf("LED4ON") > -1)
					{
						document.getElementById("LED4").style.fill = "yellow";
					}
					else 
					{
						document.getElementById("LED4").style.fill = "black";
					}
	
					if (this.responseText.indexOf("S1:ON") > -1)
					{
						document.getElementById("SW1").style.fill = "red";
						document.getElementById("text1").innerHTML ="SW1:ON";
					}
					else
					{
						document.getElementById("SW1").style.fill = "white";
						document.getElementById("text1").innerHTML ="SW1:OFF";
					}
	
					if (this.responseText.indexOf("S2:ON") > -1)
					{
						document.getElementById("SW2").style.fill = "red";
						document.getElementById("text2").innerHTML ="SW2:ON";
					}
					else
					{
						document.getElementById("SW2").style.fill = "white";
						document.getElementById("text2").innerHTML ="SW2:OFF";
					}
				}
			}
		}
	}
	request.open("GET", "ajax_switch" + nocache, true);
...
Read more »