Serial monitor detect interferes with sketch on ProMicro

The SparkFun ProMicro does not have a pin 13 so we can't use it for a e.g. heart beat. Therefore the RX LED can be used as an indication that a sketch is not hanging as demonstrated in below code.

However, the polling by serial monitor to see if a board is connected will result in odd behaviour of the RX LED. Expected behaviour is a signal with roughly 500 ms on / 500ms off. This is the case with serial monitor closed; with serial monitor open, the behaviour varies with additional pulses caused by the polling.

Note: I had to use an additional pin as directly working on pin 17 with a logic analyser is not possible for me.

// RX led on ProMicro
const uint8_t ledPin = 17;
const uint8_t copyPin = 10;


void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(copyPin, OUTPUT);
}

void loop() {
  bwod();
  digitalWrite(copyPin, digitalRead(ledPin));
}

void bwod() {
  static uint32_t lastUpdateTime;
  if (millis() - lastUpdateTime > 500) {
    lastUpdateTime = millis();
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
}

If one knows the root cause (serial monitor polling), it's not a major issue. But even if the sketch hangs, the blinking of the RX LED can be confusing if one does not notice the different timing.

Note that the behaviour on a Leonardo is identical, but there we have a pin 13 that can be used for the heart beat.

Thanks @sterretje. I agree this is problematic. The bug is being tracked by the Arduino IDE developers here:

I did see that one; it did not quite look like it was the same issue as the data does not show in the Serial monitor.

I think you have quite a collection of boards. Are the three that you mentioned the only ones in your collection that show the behaviour? I did test your sketch on a SparkFun RedBoard (FTDI232) and a clone Nano (CH340) as well and with both there wasn't any activity of the RX LED and nothing in serial monitor.

// Edit
I left a reply in the github link

I observed the same with my ATmega32u4-based boards, and reported it in the issue:

On my Leonardo, the RX LED flashes at 1 Hz while the Serial Monitor is connected, indicating unexpected data is being received, but I don't get any output from the echo sketch.

Those are the only three that produce the Serial Monitor output. All my ATmega32U4 based boards (Leonardo, Micro, Pro Micro) have the unexpected RX LED blink.

I have not done a comprehensive survey , but the following boards do not show any unexpected echo or blinking:

  • Derivative Nano w/ CH340 chip
  • Nano Every
  • Nano 33 BLE
  • Nano 33 IoT
  • Nano RP2040 Connect

I do have another Serial Monitor-related bug which does affect those:

The periodic nature of both made me suspect they might be related.

Apologies for missing that. So my only useful addition is the FTDI (SparkFun RedBoard).

Totally unrelated to this, but are there issues raised on github for the following (native USB related).

  1. What happened with the PORTS lines when uploading to the boards with native USB? They were useful to determine if the board was responding to a reset.
  2. If an upload fails, it now simply states something inthe line of "upload fails"; in 1.8.x there was a little more information like "could not open port", "port not found", "port busy" or "port in use". Again, they were useful at occasion. This might also apply to boards that don't have native USB.

Upload to Arduino Micro while an external terminal program has the port open
1.8.5

...
...
Caused by: jssc.SerialPortException: Port name - COM10; Method name - openPort(); Exception type - Port busy.
	at jssc.SerialPort.openPort(SerialPort.java:164)
	at processing.app.Serial.touchForCDCReset(Serial.java:101)
	... 6 more

2.0

Waiting for upload port...

No upload port found, using address:"COM10"  label:"COM10"  protocol:"serial"  protocol_label:"Serial Port (USB)" as fallback
"C:\Users\sterretje\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\sterretje\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -patmega32u4 -cavr109 "-PCOM10" -b57600 -D "-Uflash:w:C:\Users\sterretje\AppData\Local\Temp\arduino-sketch-01EB9DBF40D9D8E78576219EC346AA06/sketch_jul31a.ino.hex:i"
Failed uploading: uploading error: exit status 1

Upload with no board connected
1.8.5

Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.

2.0 (one has to fake it a bit by disconnecting the board while the compilation is in progress

No upload port found, using address:"COM10"  label:"COM10"  protocol:"serial"  protocol_label:"Serial Port (USB)" as fallback

Failed uploading: uploading error: exit status 1"C:\Users\sterretje\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\sterretje\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -patmega32u4 -cavr109 "-PCOM10" -b57600 -D "-Uflash:w:C:\Users\sterretje\AppData\Local\Temp\arduino-sketch-01EB9DBF40D9D8E78576219EC346AA06/sketch_jul31a.ino.hex:i"

Thanks so much for bringing this to my attention. I did an investigation and determined this was a recent regression in Arduino CLI. I submitted a formal report here:

Pleasure, closing this now as the original questions were answered.

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