Serial1 communication with VBA troubleshooting (Mega)

Hello,

I am unsuccessfully trying to transmit simple data thought Serial1 from arduino to VBA. This is very weird and I really don't understand what's happening: - when I open serial port, I can see the data is sent from Arduino - I am able to open the right port from VBA, and actually see a commevent (using NetComm active X Object), but this would always return empty string - the exact same code works if I use main serial instead

Below Arduino sketch

``void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial1.begin(9600);

}

void loop() { // put your main code here, to run repeatedly: Serial.println("in loop 0"); Serial1.println("in loop 1"); delay(2000);

}``

Below VBA sketch

Private Sub NETComm1_OnComm()

 If NETComm1.CommEvent = NETComm_EV_RECEIVE Then
 TextBox2.Text = NETComm1.InputData
End If

End Sub

Private Sub UserForm_Activate()
NETComm1.CommPort = 5
NETComm1.Settings = "9600,n,8,1"
NETComm1.InputLen = 0
NETComm1.RThreshold = 1
NETComm1.InBufferSize = 1024
NETComm1.DTREnable = True


On Error Resume Next

If NETComm1.PortOpen = False Then
    NETComm1.PortOpen = True
End If

If Err Then MsgBox Error$, 48
End Sub


Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
NETComm1.Output = KeyAscii
TextBox1.Text = KeyAscii
End Sub

Private Sub UserForm_Terminate()
    On Error Resume Next    'Error handler
    
    If NETComm1.PortOpen = True Then    'check if the serial port is open
        NETComm1.PortOpen = False       'close the serial port
    End If
    
    If Err Then MsgBox Error$, 48     'Display error in message box
    End


End Sub

Thanks in advance for your helps, I am really strugling here

How do you have Serial1 connected to the PC?

I use a USB to TTL cable (https://hackspark.fr/fr/usb-to-ttl-uart-cable.html), for which I only connect Gnd, Tx & RX to Arduino. (power is already provided by the arduino main usb connection)

The cable works fine, as I can actually see the data sent by Arduino on serial1 if use a monitor such as Realterm

The cable works fine, as I can actually see the data sent by Arduino on serial1 if use a monitor such as Realterm

In that case it isn't an Arduino problem. Must be an issue with the receiving application. Perhaps you would do better asking on a different forum where more people know VBA.

Actually I think this is an Arduino problem, that's why I am posting here. This communication works perfectly if use main Serial from Arduino, but don't work if use Serial1.

I wonder if there are some specificities about Serial1 communication (compared to serial), that could explain this.

I could read on other forum, that some people experienced problems reading Serial1 communications. https://community.particle.io/t/serial-read-behaviour-is-different-from-arduino-when-empty/2533

Nothing special about Serial1 and if you're getting it on a terminal then the Arduino is sending it out alright. So Arduino is doing its job. It is your VBA script that isn't receiving. Definitely the problem is on that end.

Ok thanks for the feedback and hints. By any chance if someone see this post and has clue on root caus with vba, your help will be very much appreciated