Software Serial Example --- not working on MEGA.

hi there,

I have a MEGA 2560, when i run the Software Serial Example,
I see only this in the Serial Monitor:

⸮⸮⸮⸮⸮⸮ ⸮

-- but not regular question marks, mirror image, backward question marks.

I don't see anything else.

It should print out 'goodnight moon'

Serial.println("Goodnight moon!");

And i gather it should exchange some data between Serial and 'mySerial'

void loop() { // run over and over
if (mySerial.available()) {
Serial.println(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}

I have tried tinkering and ensure that both my Serial Monitor Window
and the baud rates specified in the code are the same: 4800.

When i do this, i at least get to see the 'Goodnight Moon' message.

If anyone has any insights into this problem, i would be very grateful
if you could whisper a hint or two.

Thanks to anyone who replies.

Have a nice day :slight_smile:

Baud rate of Serial must match the baud rate you're using on the serial monitor.

You can use a different baud rate for the other serial ports.

Why are you using software serial on a Mega2560? You have three more hardware serial ports that avoid all the problems associated with software serial!

I can't assess why yours may not work as you have not posted all the code.

Also, read the "how to use this forum" thread which explains how to use code tags, please use them.

At line 34 in the SoftwareSerialExample sketch:

 Serial.begin(57600);

That configures Serial (which is connected to the USB jack on the Mega 2560) to run at 57600 baud.

At line 43 in the sketch:

 mySerial.begin(4800);

That configures the software serial port (which is on pins 10 and 11) to run at 4800 baud.

So the device connected to pins 10 and 11 needs to be communicating at 4800 baud but you need to set your Serial Monitor to 57600 baud.

If you need different baud rates you can just change those lines in the example.

Why are you using software serial on a Mega2560?

+1

Just use Serial1, Serial2 or Serial3 on pins 14-19.

1 Like