Serial.println() sending output to both Serial and Serial3 unexpectedly on Mega

Hi,
I am using Serial and Serial3 ports for output on a Mega2560. When I initialize just the Serial port (connected to USB), anytime I send Serial.print(), it also sends to Serial3 which is connected to a Bluetooth HM-10 module. Serial3 seems to be ignored on initialization and doesn't output anything to either Serial (usb) or Serial3 devices.

My Serial3 device is connected to pins 15 and 14.

void setup(){
  Serial.begin(9600);
  // Serial3.begin(9600); // initing this does not change behavior
}

void loop(){
  Serial.println("To USB - Serial");  // sends to both Serial (USB) and Serial3 (BT device)
  // Serial3.println("To Bluetooth - Serial3"); // message never sends
}

Anybody heard of this?

thanks

How do you know it sends to the Bluetooth device? Where is the output from the Bluetooth device appearing?

Post diagram showing how everything is connected. A photo of a simple pencil drawing is best. Please DO NOT use Fritzing.

...R

Hi -

Attached is a basic diagram of the serial wiring.
I also have sensors connected to A1-A4, A8-A11, plus I2C on D20,D21 (all powered by 3.3V)

I know Bluetooth is receiving these messages because I have HM-10 paired to the Bluetooth Serial app on my iPhone (screenshot attached).

Try changing the baud rate on one of them. :slight_smile:

Try changing the baud rate on one of them

doesn't help. still outputs to both.

digitoxin9:
doesn't help. still outputs to both.

At which rate? :slight_smile: The purpose is to narrow it down, not fix it magically.

Images from Reply #2 so we don't have to download them. See this Image Guide

...R

What happens if you connect the Bluetooth module to Serial1 or Serial2?

Also, add delay(500); into loop()

Also Also, add Serial.println("Test A starting"); into setup() so you can verify that the correct program is actually loaded.

...R

Just asking...
Have you selected the correct (Mega) target in the Arduino IDE ?
You haven't fiddled with any of the Arduino library installation, or edited the .H files - have you?

:-X facepalm.

after following the connections again, i saw that the HM-10 was connected to Serial pins 0,1 instead of Serial3 14,15. now it works as expected.

thanks for your suggestions!

Thanks for the feedback.

And welcome to the club :slight_smile:

...R