title: ESP8266: How to send TCP messages using AT+CIPSEND command
body: <p>I am experimenting with Arduino and ESP8266 module, and now I am trying to send some sensor data to a TCP server. For this purposes I am using  AT+CIPSTART command (to establish a TCP connection) and AT+CIPSEND to send the data. </p>
  
  <p>If I am testing it using Serial Monitor, it works fine. After entering CIPSEND command I can write some text in a terminal and this message/text will be sent to the TCP server.</p>
  
  <p>When I am trying to make it inside Arduino sketch, then it sends an empty message. The connection works, but I do not see any data.</p>
  
  <p>How can I send a message text (msg) with my TCP packet?</p>
  
  <p>Here is a code snippet</p>
  
  <pre><code>  // ESP8266 Client
  String cmd = "AT+CIPSTART=\"TCP\",\"";// Setup TCP connection
    cmd += IP;
    cmd += "\",3103";
    sendDebug(cmd);
    delay(2000);
    if( Serial.find( "Error" ) )
    {
      debug.print( "RECEIVED: Error\nExit1" );
      return;
    }
  
    String msg = "test";
    Serial.print( "AT+CIPSEND=" );
    Serial.println( msg.length() );
    if(Serial.find( "&gt;" ) )
    {
      debug.print("&gt;");
      debug.print(msg);
      Serial.print(msg);
    }
    else
    {
      sendDebug( "AT+CIPCLOSE" );//close TCP connection
    }
    if( Serial.find("OK") )
    {
      debug.println( "RECEIVED: OK" );
    }
    else
    {
      debug.println( "RECEIVED: Error\nExit2" );
    }
  }
  </code></pre>