Strings are not received by my mobile from ESP8266 module

Hello everybody,
I sketched this simple code to send strings from an android telnet client application to arduino mega through ESP8266 wireless module.
The strings sent are converted to integers and correspond to leds pins, it works great lighting the leds from the mobile but when i use the Serial3.println command it doesn't show the print message on mobile and instead it shows it on the serial monitor !

Here is the code,

int r[3], f = -2;
String y = "";
 void setup(){
   
   Serial.begin(9600);
    
 Serial3.begin(9600);
 Serial3.setTimeout(100);
 pinMode(23,OUTPUT);
  pinMode(24,OUTPUT);
   pinMode(25,OUTPUT);
 }
 void loop() {

                String IncomingString = "";
                
                while (Serial3.available()) 
 {
   
 
  IncomingString=Serial3.readString();

 

 Serial.println("Received String: " + IncomingString); 
 f++;

          y = IncomingString.substring(11,12);
           r[f] = y.toInt();
 }
 
  if (r[f] == 1){
digitalWrite(23,HIGH);
Serial3.println("led #1 on");
  }
         if (r[f] == 2){
         digitalWrite(24,HIGH);
Serial3.println("led #2 on");
         }

         if (r[f] == 3){

digitalWrite(25,HIGH);
 Serial3.println("led #3 on");
         }
 }

Here is the code

That is SOME of the code. So, here is some of the answer.

You need to change line num....

PaulS:
That is SOME of the code. So, here is some of the answer.

You need to change line num....

you need to scroll down the code textbox to see the rest of the code.

Seif, you cannot just Serial3.println to send a response, you have to use the esp8266 AT command to send a response back.

Doughboy, what kind of AT commands should be used to send a string like "led#1 is on" to android application through serial3 ? I've scanned the AT commands of esp8266 and i'm not sure which one can do the job and how to use it!
Another question is why the string in the command Serial3.println("led#1 is on") for example is displayed in the serial monitor ?!

ok, I think you are not using arduino hardware and using esp8266 module and arduino ide only.
I think you will get better help in esp8266 forums or contact the person who developed the library directly.

Ok thanks anyway :slight_smile: