   String cmd = "AT+CIPSTART=\"TCP\",\"";
   cmd += DST_IP;
   cmd += "\",80";
+  ESPComm.println(cmd);
   Serial.println(cmd);
-  dbgSerial.println(cmd);
-  if (Serial.find("Error")) return;
+  if (ESPComm.find("Error")) return;
   cmd = "GET / HTTP/1.0\r\n\r\n";
-  Serial.print("AT+CIPSEND=");
-  Serial.println(cmd.length());
-  if (Serial.find(">"))
-  {
-    dbgSerial.print(">");
+  ESPComm.print("AT+CIPSEND=");
+  ESPComm.println(cmd.length());
+  if (ESPComm.find(">"))
+  {
+    Serial.print(">");
   } else
   {
-    Serial.println("AT+CIPCLOSE");
-    dbgSerial.println("connect timeout");
+    ESPComm.println("AT+CIPCLOSE");
+    Serial.println("connect timeout");
     delay(1000);
     return;
   }
-  Serial.print(cmd);
+  ESPComm.print(cmd);
   delay(2000);
-  //Serial.find("+IPD");
-  while (Serial.available())
-  {
-    char c = Serial.read();
-    dbgSerial.write(c);
-    if (c == '\r') dbgSerial.print('\n');
-  }
-  dbgSerial.println("====");
+  //ESPComm.find("+IPD");
+  while (ESPComm.available())
+  {
+    char c = ESPComm.read();
+    Serial.write(c);
+    if (c == '\r') Serial.print('\n');
+  }
+  Serial.println("====");
   delay(1000);
 */	
   
 	
 	/*
-	dbgSerial.println("[Prompting for available networks]");
-	Serial.print("AT+CWLAP\015\012");
+	Serial.println("[Prompting for available networks]");
+	ESPComm.print("AT+CWLAP\015\012");
 	*/
 	
 	//Command prompt to send commands to ESP module
 	/*
 	while(1){
+		if(ESPComm.available()){
+			Serial.print((char) ESPComm.read());
+		}
+		
 		if(Serial.available()){
-			dbgSerial.print((char) Serial.read());
-		}
-		
-		if(dbgSerial.available()){
-			Serial.print((char)dbgSerial.read());
+			ESPComm.print((char)Serial.read());
 		}
 	}
 	*/


#define LED 13

SoftwareSerial dbgSerial(11, 10); //Rx, Tx

void setup(){
	//Open serial communication
	Serial.begin(9600);
	Serial.setTimeout(5000);
	
	dbgSerial.begin(9600);
	dbgSerial.println("\n\r[ESP8266 Interface Test]");
	
	pinMode(LED, OUTPUT);
	digitalWrite(LED, LOW);
	
	//Test if the module is ready
	Serial.print("AT\015\012");
	delay(2000);
	if(Serial.available())
	{
		dbgSerial.println("Module is ready");
	}
	else
	{
		dbgSerial.println("The module has not responded.");
		while(1);
	}
	
	if(Serial.find("OK")){
		dbgSerial.println("[Module Responded OK]");
	}
	/* else {
		testFailed();

		}
	}
	if(!connected){
		Serial.println("[### Failed to connect to WiFi ###]");
		testFailed();
	}
	
	digitalWrite(LED, HIGH);
	delay(1000);	
	
	Serial.println("[Set single connection mode]");
	ESPComm.print("AT+CIPMUX=0\015\012");
	
	if(ESPComm.find("OK")){
		Serial.println("[Module Responded OK]");
	}
	
	Serial.println("[Requesting IP]");
	ESPComm.print("AT+CIFSR\015\012");
	for(int i = 0; i < 500; ++i){
		if(ESPComm.available()){
			Serial.print((char) ESPComm.read());
		}
		delay(1);
	}
