Can not send data to thingspeak

But if you are connecting to the serial monitor via the USB connector on your UNO that also uses Arduino TX& RX pins so there is potential conflict there. Do you have any way to power your Uno without plugging it in to the USB port?

Alternatively you could replace this bit

if(Serial.find(">")){
    Serial.print(cmd);
  }
  else{
    Serial.println("AT+CIPCLOSE");
    //Resend...
    error=1;
  }

with

delay(1000);
Serial.print(cmd);
delay(1000);
Serial.println("AT+CIPCLOSE");

Just to see if it makes a difference