Serial input not working

I am trying to take serial input from a device and read it on the arduino, however, despite the signal very clearly reaching the pin, it does not recognize anything. The serial format is 2400-N-8-1 and I am using an arduino mega.

void setup(){
  Serial2.begin(2400);
  delay(1000);
  Serial.begin(1000000);
  delay(1000);
  Serial.println(“begin”);
}

void loop(){
  if(Serial2.available()){
    Serial.println(Serial2.read());
  }
}

Also attached is a picture of an oscilloscope reading coming directly from the Serial2 Rx pin(17).

The program prints the “begin” and then does nothing. Other experiments show that the loop is running, it just for whatever reason is not processing the serial input.

Any help would be greatly appreciated. Thanks.

silly question - you do have serial Monitor set to 1000000, correct? I'd try a more traditional baud rate to start with, maybe 115200.

If I'm reading that correctly, the signal coming into the Rx pin is well below 3V.

When Vcc is 5V, the minimum Vih for the 2560 is 3V.

1 Like

Hi, @omnia_et_nihil

On the scope what scale is the vertical axis set for V/Div?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

It’s not a 2V minimum?

2V, as shown in the picture.

Why exactly? The serial communication with the computer is not the problem here.

No, with Vcc at 5V, it's a 3V minimum for Vih, as shown in the datasheet.

The do have the data grounds connected, don't you?

Your loop clearly attempts to print what comes in on Serial1 over to Serial Monitor. You'll not see anything there if it's rate doesn't match Serial.begin(XXXX)

Not sure I follow. Assuming you meant serial 2 and not 1, my code should read it, output an int, which then gets printed to the monitor with serial. That serial and serial 2 have different baud rates is completely irrelevant.

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