thebecwar is right
you need to read the HTTP standard and figure out how to send a valid HTTP GET command.
Then the server will send the page.
If you only make a TCP connection, how is the server going to know what to do?
If you install wireshark, start her up, create a filter with
www.google.com, look at the transactions that take place between your computer and
www.google.com
You will see that a TCP connection is only the first step.
I'm using post because thats my application, and my code is quite dynamic, but if your always sending the same GET command, its doesn't need all the variables in there. It could be a fixed packet.
Be careful if you are connecting to an IP, that the 'host' value is actually the web address and not the IP. If you use the IP the server wont know what to do with it. This is because there might be more than one web server on that IP.... likely not the case for google.com, but to be sure.
Read the standard, and get used to reading, because reading is king in development... you need to do it... alot.
Code: Select all //"AT+SDATASEND=1, "..."
Serial1.print("AT+SDATATSEND=1, ");
Serial1.print(packetSize);
Serial1.print(CR);
delay(100);
/*--------------------Sart TCP Packet--------------------------*/
/*--------------------Sart HTTP Header-------------------------*/
Serial1.print("POST "); //5
Serial1.print(webExt); //var
Serial1.print(" http/1.1"); //9
Serial1.print(CR); //1
Serial1.print(LF); //1
Serial1.print("Host: "); //6
Serial1.print(webAdd); //var
Serial1.print(CR); //1
Serial1.print(LF); //1
Serial1.print("User-Agent: "); //12
Serial1.print(userAgent); //var
Serial1.print(CR); //1
Serial1.print(LF); //1
Serial1.print("Content-Type: application/x-www-form-urlencoded"); //47
Serial1.print(CR); //1
Serial1.print(LF); //1
Serial1.print("Content-Length: "); //16
Serial1.print(contentSize); //var
Serial1.print(CR); //1
Serial1.print(LF); //1
Serial1.print(CR); //1
Serial1.print(LF); //1
/*--------------------End HTTP Header-------------------------*/
/*-------------------Start of Content-------------------------*/
Serial1.print("s=");
for (int k=0; k<12; k++){
Serial1.print(payload[k]);
}
if (howmanyInt>0){
Serial1.print("&f=");
for (int i=0; i<howmanyInt; i++){
for (int k=0; k<12; k++){
Serial1.print(payload[(i*12)+k]);
}
if (i<(howmanyInt-1)){
Serial1.print(",");
}
}
}
if (reboot == true){
Serial1.print("&e=");
Serial1.print(Err_Reset);
reboot = false;
}
Serial1.print(CR); // Carridge return //1
/*--------------------End of Content--------------------------*/
/*--------------------End TCP Packet--------------------------*/
Serial1.print(UC); // Up caret