SOLVED - No serial1 output without connected serial USB?!?

Hi folks,

I have here a strange behavior with serial1 output... :o

The serial1 output works only with a connected USB cable (with serial connection, with power only USB the behavior is still the same)... :sob:

Any idea?!?

THX

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:

  • Do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code. This will make it easier for you to spot bugs and make it easier for us to read.
  • In the Arduino IDE or Arduino Web Editor, click on the window that contains your sketch code.
  • Press "Ctrl + A". This will select all the text.
  • Press "Ctrl + C". This will copy the selected text to the clipboard.
  • In a forum reply here, click the "Reply" button.
  • click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the sketch between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Repeat the above process if your sketch has multiple tabs.

This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.

If the sketch is longer than the 9000 characters maximum allowed by the forum, then it's OK to add it as an attachment. After clicking the "Reply" button, you will see an "Attachments and other settings" link.

When your code requires a library that's not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.


Without the sketch, I can only speculate that you have a line something like this in your sketch:

while (!Serial);

that causes the sketch to hand in an endless loop until a serial connection is opened over the USB cable.

That is useful when you have output to Serial because without it any output that happened after your program started and before you got Serial Monitor open would be lost. But if you have a program that you want to run without Serial Monitor open, you need to remove that line.

Hi Pert,

you are right, it's a stupid thing do not post a source code... sorry...

Here some test code:

void setup() {
    Serial1.begin(9600);
    delay(1000);
    Serial1.println("Hello serial1");
}

void loop() {
    while (1) {
        Serial1.println("Hello serial1");
        delay(2000);
  }
}

The serial1 printing output is only available when a USB cable (with serial connection) is plugged in. Plug the USB cable off... serial1 stops transmission, plug USB cable in... serial1 output is printing again...

The MKR WAN 1310 runs on a LiPo battery, the USB cable has a disconnected VCC wire.

Any idea to this strange behavior?

THX

So much for my guess!

How are you reading the output from Serial1?

With a FTDI Adapter FT232RL.
THX

Do you have the ground of the FTDI adapter connected to the ground of your MKR WAN 1310?

I can reproduce the issue by disconnecting the ground wire. The reason why it still works with no ground connection between the FTDI adapter and the MKR WAN 1310, but with a USB connection between the computer and the MKR WAN 1310 is because that provides the ground path, since the FTDI adapter is also connected to the same computer.

With a ground connection between the FTDI adapter and the MKR WAN 1310, it works for me even with a power supply to the MKR WAN 1310 separate from the computer.

Hi Pert, :smiley:

Oh man, how did I forgotten the thing with the common grounding... electronic basics... :wink:

Thank you very, very much again! Meanwhile it looks like you are essential for me. Because what would I do without your perfect hints?! :smiley:

Greetings,
André

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

Thanks for taking the time to close the GitHub issue and mark this solved. Many people don't bother to do things like that because they're anxious to get back to their project, but it really is helpful.