sending very long string to software serial

I have a wifi module that i have to configure with a long lua command .
If i take that command and write in the Arduino terminal and send it to the chip ( the hardware serial) it works great and the chip react right to command.

Then if i try to send it to him from the software serial , i can see that the chip is getting the message, but he is not reacting to it, that means there is some syntax problem with the printing, and i think i am not doing it right .

So, the line that works in a serial from the arduino IDE is :

sv=net.createServer(net.TCP)  sv:listen(80,function(c)       c:on("receive", function(c, pl) print(pl) end)       c:send("HTTP/1.1 200 OK\r\n") c:send("Content-Type: application/json\n\n") c:send("ok")     end)

then i am trying to send it from code with software serial, this is the code :

SoftwareSerial wifiSerial(5,6);

void setup()


        while (!Serial) 

        while (!wifiSerial) 

wifiSerial.println("sv=net.createServer(net.TCP)  sv:listen(80,function(c)       c:on(\"receive\", function(c, pl) print(pl) end)       c:send(\"HTTP/1.1 200 OK\r\n\") c:send(\"Content-Type: application/json\n\n\") c:send(\"ok\")       end)   ");  
}         //

The module gets that row, and react to it, but is not reacting well, because something in the way is wrong.
The pins 5/6 are connected to it directly .

Why that same line is working in the IDE serial and not in code ?

Why that same line is working in the IDE serial and not in code ?

Because you don't have enough memory? Wrap the whole string literal in the F() macro to keep it out of SRAM.

I have exactly the same problem that you do, trying to send data to Thingspeaks sending the LUA commands from arduino, and it works "ok" in a random way, I debug with a serial monitor as well with a USB/serial adapter and in most of the cases I get an answer that says" unfinished string near '"Clos... .... " I used delay like these and see some diferences but its almost the same, I assume its a timming thing here its the code in case it helps

 Serial.println("conn=net.createConnection(net.TCP, 0)");
  Serial.println("conn:on(\"receive\", function(conn, payload) print(payload) end)");

  Serial.println("conn:send(\"" + GET + String(t) + " HTTP/1.1\\r\\n\") ");
  Serial.println("conn:send(\"Host:\\r\\n\") ");
  Serial.println("conn:send(\"Accept: */*\\r\\n\")");
  Serial.println("conn:send(\"User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\\r\\n\")");
  Serial.println("conn:on(\"sent\",function(conn) print(\"Closing connection\") conn:close() end)");
  Serial.println("conn:on(\"disconnection\",function(conn) print(\"Got disconnection...\") end)");

I am using an arduino Mega, and no using voltage adapter either for comm lines.