ESP8266 Wifi Error

Hi all, this is now my second season running my greenhouse with Arduino and data logging on Thingspeak. But this spring when I went to reconnect my Mega and send data I keep hitting the “Data Not Sent” loop. I haven’t changed anything and I checked the ESP, it pings back wifi is good. Any ideas why I’m not getting a successful send?

void wifiData() {

// collect all sensor data here first to send
hum = dht.readHumidity();
temp= dht.readTemperature();
delay(500);

int windVal = analogRead(windspeedPin);
Serial.println(" Analog Output: “);
Serial.println(windVal);
float windVoltage = (windVal * 0.004882814);
Serial.println(”, Volts: ");
Serial.println(windVoltage);
float windspeed = (windVoltage - 0.40)/1.6 *32.4; //
Serial.println(“Wind Speed M/S”);
Serial.println(windspeed);
float kmh = (windspeed * 3.6);
if(kmh < 0){
kmh = (0);
}else{
Serial.println(“Wind Speed KM/H”);
Serial.println(kmh);
}

int roofState = digitalRead(roofSense);
int windowState = digitalRead(windowSense);
int rainVolt = analogRead(rainSensor);

delay(500);

String cmd = “AT+CIPSTART=“TCP”,”";
cmd += “184.106.153.149”; // api.thingspeak.com
cmd += “”,80";
Serial1.println(cmd);

if(Serial1.find(“Error”)){
Serial.println(“AT+CIPSTART error”);
return;
}
// prepare GET string
String getStr = “GET /update?api_key=”;
getStr += apiKey;
getStr +="&field1=";
getStr += String(temp);
getStr +="&field2=";
getStr += String(hum);
getStr +="&field3=";
getStr += String(kmh);
getStr +="&field4=";
getStr += String(roofState);
getStr +="&field5=";
getStr += String(windowState);
getStr +="&field6=";
getStr += String(rainVolt);
getStr += “\r\n\r\n”;

// send data length
cmd = “AT+CIPSEND=”;
cmd += String(getStr.length());
Serial1.println(cmd);

if(Serial1.find(">")){
Serial1.print(getStr);
Serial.println(“DATA SENT”);
delay(1000);//1 seconds
}
else{
// alert user
Serial.println(“DID NOT SEND DATA, RETRY”);
Serial1.println(“AT+RST”);
}
}
}

It looks to me like you are trying to use Serial to talk to the ESP AND to talk to the PC. That isn't going to work.

Instead of guessing what thingsqueek is sending back, read the serial stream, and find out.

PaulS:
It looks to me like you are trying to use Serial to talk to the ESP AND to talk to the PC. That isn't going to work.

Instead of guessing what thingsqueek is sending back, read the serial stream, and find out.

there is Serial1

thingsspeek doesn't send back anything, because the request was not sent. the sketch didn't find ;>' as prompt from esp8266 to sent the data

@RobH, this sketch is so weak. it works only in ideal conditions
use host name not IP address. maybe it changed. the esp8266 will resolve the hostname to IP address