Weatherstation MySQL upload

Hello guys, my first arduino project is a weatherstation with esp8266 and upload to the website wunderground.com. Now I want to modifie the code that i copied from the project.
I want to upload the sensor data to a MySQL-Server and to Wunderground.com . For that i made a php-site. When I enter this in my browser
http://www.mysite.com/write_data.php?tempf=11&dewptf=12&humidity=13&baromin=14&solarradiation=15&uv=16&rainin=17&dailyrainin=17

The Values 11,12,13... added in the DB. So this works fine.
The upload to the website Wunderground.com works also over php. The used code for the upload looks like this:

void wunderground(void)

{

String cmd1 = "AT+CIPSTART=\"TCP\",\"";

cmd1 += "rtupdate.wunderground.com"; // wunderground

cmd1 += "\",80";

esp8266Module.println(cmd1);

if(esp8266Module.find("Error")){

Serial.println("AT+CIPSTART error");

return;

}

String cmd = "GET /weatherstation/updateweatherstation.php?ID=";

cmd += ID;

cmd += "&PASSWORD=";

cmd += PASSWORD;

cmd += "&dateutc=now";

cmd += "&tempf=";

cmd += tempf;

cmd += "&dewptf=";

cmd += dewptf;

cmd += "&humidity=";

cmd += humidity;

cmd += "&baromin=";

cmd += baromin;

cmd += "&solarradiation=";

cmd += solar;

cmd += "&UV=";

cmd += uvIntensity;

cmd += "&rainin=";

cmd += rain1h;

cmd += "&dailyrainin=";

cmd += rain24h;

cmd += "&soiltempf=";

cmd += temp2f;

cmd += "&action=updateraw"; // &softwaretype=Arduino%20UNO%20version1&action=updateraw

cmd += "/ HTTP/1.1\r\nHost: host:port\r\nConnection: close\r\n\r\n";

cmd1 = "AT+CIPSEND=";

cmd1 += String(cmd.length());

esp8266Module.println(cmd1);

if(esp8266Module.find(">")){

esp8266Module.print(cmd);

digitalWrite(GREEN_LED,HIGH); // Green led is turn on then sending data to Wunderground

Serial.println("Data send OK");

delay(1000);

digitalWrite(GREEN_LED,LOW);

}

else{

esp8266Module.println("AT+CIPCLOSE");

Serial.println("Connection closed");

Serial.println(" ");

}

delay(2500);

I tried this direct under the first code but it didnt worked:

void mysql(void)

{

String cmd1 = "AT+CIPSTART=\"TCP\",\"";

cmd1 += "mysite.com"; // php-site to upload

cmd1 += "\",80";

esp8266Module.println(cmd1);

if(esp8266Module.find("Error")){

Serial.println("AT+CIPSTART error");

return;

}

String cmd = "GET /write_data.php?";

cmd += "tempf=";

cmd += tempf;

cmd += "&dewptf=";

cmd += dewptf;

cmd += "&humidity=";

cmd += humidity;

cmd += "&baromin=";

cmd += baromin;

cmd += "&solarradiation=";

cmd += solar;

cmd += "&UV=";

cmd += uvIntensity;

cmd += "&rainin=";

cmd += rain1h;

cmd += "&dailyrainin=";

cmd += rain24h;

cmd1 = "AT+CIPSEND=";

cmd1 += String(cmd.length());

esp8266Module.println(cmd1);

if(esp8266Module.find(">")){

esp8266Module.print(cmd);

digitalWrite(GREEN_LED,HIGH); // Green led is turn on then sending data to Wunderground

Serial.println("Data send OK");

delay(1000);

digitalWrite(GREEN_LED,LOW);

}

else{

esp8266Module.println("AT+CIPCLOSE");

Serial.println("Connection closed");

Serial.println(" ");

}

delay(2500);

}

I dont have any experience in programming and i want to learn but i dont know how to let this work.

When somebody can pleas help me.
Thanks
Moritz

Look at the two different GET requests. Print cmd, in both cases, if you need help seeing the differences. The data missing from the second (the MySQL command) IS crucial.

I will read the code agian. Sorry english is not my native language and my english is not very well so i have some problems with your hints. :frowning:

Working code, with the useless blank lines removed:

String cmd = "GET /weatherstation/updateweatherstation.php?ID=";
cmd += ID;
cmd += "&PASSWORD=";
cmd += PASSWORD;
cmd += "&dateutc=now";
cmd += "&tempf=";
cmd += tempf;
cmd += "&dewptf=";
cmd += dewptf;
cmd += "&humidity=";
cmd += humidity;
cmd += "&baromin=";
cmd += baromin;
cmd += "&solarradiation=";
cmd += solar;
cmd += "&UV=";
cmd += uvIntensity;
cmd += "&rainin=";
cmd += rain1h;
cmd += "&dailyrainin=";
cmd += rain24h;
cmd += "&soiltempf=";
cmd += temp2f;
cmd += "&action=updateraw";
cmd += "/ HTTP/1.1\r\nHost: host:port\r\nConnection: close\r\n\r\n";

Non-working snippet, with the useless blank lines removed:

String cmd = "GET /write_data.php?";
cmd += "tempf=";
cmd += tempf;
cmd += "&dewptf=";
cmd += dewptf;
cmd += "&humidity=";
cmd += humidity;
cmd += "&baromin=";
cmd += baromin;
cmd += "&solarradiation=";
cmd += solar;
cmd += "&UV=";
cmd += uvIntensity;
cmd += "&rainin=";
cmd += rain1h;
cmd += "&dailyrainin=";
cmd += rain24h;

The last line from the working code is missing from the non-working code. A coincidence? NO!

Ohh thank you! Didn't noticed this :slight_smile: