1

I got a strange issue with my Arduino Leonardo (clone). It seems to be laggy or buggy, I don't know what the issue is.

I get issues when I use "long" delays.

Below sketch is working fine.

void setup() {
 Serial.begin(9600);
}

void loop() {
  delay(1000);
  Serial.println("Hello World 1000"); // added delay to line for debugging 
}

When I use delay(2000) it still is fine. But when I try delay(3000) the serial monitor doesn't output anything (or just 1 line). When I lower the delay to like 2500, it gets better. But not without issues. Sometime it will just skip one iteration, see log below.

11:33:06.328 -> Hello World 2500
11:33:11.331 -> Hello World 2500
11:33:13.909 -> Hello World 2500
11:33:18.815 -> Hello World 2500
11:33:21.395 -> Hello World 2500
11:33:23.815 -> Hello World 2500
11:33:26.392 -> Hello World 2500

What might the issue be?

EDIT:

  • when I do 3x delay(1000) I get same (weird) results. With 2 times, it does work ok.

  • The logs are from the serial monitor from the Arduino IDE

  • I added below line in the setup, it does print the line just once.

    while (!Serial) {} Serial.println("setup()");

Important note: I think it might have to do more with the serial communication than with the Arduino itself. I tested the same things on another computer (Windows 10), and then I just get the expected results. I am using Manajaro Linux as the main machine.

When the output to the serial port is "lagging" so the printing of the line is missed/skipped, I see the RX and TX led on the Arduino light up for a while. Then when they go out, the serial monitor sometimes outputs 2 lines at once.

18
  • What happens if you do multiple delay(1000); in sequence between println()? Aug 28, 2022 at 11:42
  • Is the log directly from the Serial Monitor? Or do you use any other communication channel? Aug 28, 2022 at 11:43
  • 1
    Re “how would I do that?”: stty -F /dev/ttyACM0 raw 9600 && cat /dev/ttyACM0 Aug 29, 2022 at 19:16
  • 2
    "I am using Manajaro Linux as the main machine" Had your problem with Manjaro here to my surprise. Tested different AVR cores, different terminals, same problem. Observed that RX was blinking for no reason. Problem disappeared while trying to inspect USB traffic with wireshark. Have not been able to replicate problem since. Noticed an external 3.0 hub wasn't working. System out of date. Updated, rebooted, still can't recreate the problem. Also observed that sending traffic would prompt inbound data (even with no code to read on Arduino). Add counter to code. Counts were skipped.
    – timemage
    Aug 30, 2022 at 19:20
  • 1
    @thebusybee: ModemManager seems to be a common offender. Aug 31, 2022 at 10:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.