MEGA2560 Hardware Serial Crosstalk

Hi good day/

I'm trying to talk to the SIM800L modem thru Serial3 on my ATMEGA2560 board. The problem is that the commands sent to the modem are also sent to the Serial monitor. How is that possible? I've checked every bit of the code and wiring. These maybe is not really a big problem, but it's unwanted messages on the serial monitor.

thanks....

Here's the code:

unsigned long tout;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial3.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

  //Serial.println("from serial");
  Serial3.print("from serial3\r\n");
  delay(1000);
  Serial.print("from serial\r\n");
  delay (1000);


  sendCommand("AT",3000, true);

}


String sendCommand(String command , unsigned long timeout, bool debug){
  String resp = "";

  Serial3.println(command);

  unsigned long time = millis();

  while( (time + timeout) > millis()){
    while( Serial3.available()){
      char c= Serial3.read();
      resp += c;
    }
    
  }
  if(debug){
    Serial.print(resp);
  }
  return resp;
}

Here the output from serial monitor:

You have the debug boolean set = true.

String sendCommand(String command , unsigned long timeout, bool debug){

sendCommand("AT",3000, true);

if(debug){
    Serial.print(resp);
  }

To eliminate the Serial debug print use
sendCommand("AT",3000, false);

thanks for the reply.

but i need the resp from the modem.

in code "Serial3.print("from serial3\r\n");" why is it printed on the serial monitor?

I think you are going to have to provide a detailed wiring diagram, and and documentation on any shields or modules used. Cross talk between Serial3 and Serial is not expected.

If you put the modem on Serial2 or Serial 1, do you still see the cross talk?

Yes even on Serial1 and Serial2. I notice that if I remove the RX TX pin for the GSM modem the crosstalk is gone. The wiring is simple just the GSM modem connected to V5V TX RX GND.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.