user41561: I use an Arduino Nano with some sensors and send data to a PC using the serial port. I just got a new Arduino Nano 33 BLE and tried the same code but its not working. So for testing I just wrote some simple test code on the Arduino Nano 33 BLE side:
void setup()
{
  Serial.begin(57600);
}

void loop()
{
  if (Serial.available())
  {
    char c = Serial.read();
    Serial.write(c);
  }
}

This just sends back whatever arrives through the COM port. Using the Arduino IDE Serial Monitor this works very well with the Arduino Nano 33 BLE.
I also made this very simple C# test code (Windows Forms app):
SerialPort serialPort = new SerialPort("COM17", 57600);
serialPort.ReadTimeout = 4000;
serialPort.WriteTimeout = 4000;
serialPort.Encoding = Encoding.ASCII;
serialPort.DataReceived += SerialPort_DataReceived;
serialPort.Open();
if (serialPort.IsOpen)
{
    Debug.Print("COM port open");
}

This C# code works perfect with my good old Arduino Nano but it doesn't work with the Arduino Nano 33 BLE. I have the COM port open message so the port exists and it is open, but then nothing else, no timeout, nothing.
I already lost one day trying out all sorts of combinations but it just doesn't work, my C# app can't communicate with the Arduino Nano 33 BLE. It looks like a serial port issue so I think I'll put it on hold for now...
EDIT:
The rest of my test code, for reference:
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    try
    {
        Debug.Print(serialPort.ReadExisting());
    }
    catch (Exception exception)
    {
        Debug.Print(exception.Message);
    }
}

private void buttonSend_Click(object sender, EventArgs e)
{
    try
    {
        serialPort.WriteLine("HELLO");
    }
    catch (Exception exception)
    {
        Debug.Print(exception.Message);
    }
}


user70020: I noticed that a lot of line discipline and flow control settings were not made explicit in your C# code, so it made me wonder what they were by default.
In particular DtrEnable appears to be false by default and Handshake is None by default (which seems to be irrelevant). The other default amount to 8N1. The first part I found interesting because it seems more typical in serial APIs for DTR to be automatically asserted when a port is opened when you're not explicitly asking it to.  If I'm reading the .NET documentation correctly, it isn't for your application. The original Nano doesn't much care about DTR apart from a falling edge triggering reset. The board is happy to communicate with it solidly either asserted or not. The original Nano's DTR is only capacitively coupled to reset; there's not a way for the code running on the AVR to respond to DTR (unless you count resetting). That lead to a question about to what extent a Nano 33 BLE would care about DTR.
As it turns out the Nano BLE does care. If I deassert DTR in test with pyserial the board stops sending traffic back. I can write while it's deasserted and after asserting again some queued data arrives. A test environment with pyserial is just more immediately available to me; if needed and I get a chance I'll set up a .net/C# test and confirm with that, but I suspect that won't be necessary. Seeing that result, I searched and found this Arduino Forum post with a somewhat similar problem description. The OP replies in answer to their own post saying:

Problem sorted out. Arduino nano BLE requires DTR and RTS signals to
be On. Then it works like FDTI.

Disabling RTS had no effect during my tests with pyserial. I'm not sure why it would. Perhaps they just asserted it preemptively. Being entirely a virtual port RTS doesn't really make sense for flow control. DTR might arguably still makes more sense in this context; at the level of serial signals it normally tells you something is paying attention on the other side of the connection. I'm not really surprised, either way, that the BLE sense would react to DTR being disabled by not sending data to the host; there's a lot of latitude in how these signals can be handled. That it's not automatically used when the port is opened (or until specifically requested) seems mostly a C# thing. But it looks like the different handling of DTR between the two boards that is making your code work with one but not the other.
So it would seem necessary and sufficient to add
serialPort.DtrEnable = true;

amongst your other settings following the opening of the port.
If there's truth to what the Arduino Forum poster said about RTS, then you would also need
serialPort.RtsEnable = true;

but this is not indicated by the tests I've done (though again with pyserial).

41561: <p>I use an Arduino Nano with some sensors and send data to a PC using the serial port. I just got a new Arduino Nano 33 BLE and tried the same code but its not working. So for testing I just wrote some simple test code on the Arduino Nano 33 BLE side:</p>
<pre><code>void setup()
{
  Serial.begin(57600);
}

void loop()
{
  if (Serial.available())
  {
    char c = Serial.read();
    Serial.write(c);
  }
}
</code></pre>
<p>This just sends back whatever arrives through the COM port. Using the Arduino IDE Serial Monitor this works very well with the Arduino Nano 33 BLE.
I also made this very simple C# test code (Windows Forms app):</p>
<pre><code>SerialPort serialPort = new SerialPort(&quot;COM17&quot;, 57600);
serialPort.ReadTimeout = 4000;
serialPort.WriteTimeout = 4000;
serialPort.Encoding = Encoding.ASCII;
serialPort.DataReceived += SerialPort_DataReceived;
serialPort.Open();
if (serialPort.IsOpen)
{
    Debug.Print(&quot;COM port open&quot;);
}
</code></pre>
<p>This C# code works perfect with my good old Arduino Nano but it doesn't work with the Arduino Nano 33 BLE. I have the <strong>COM port open</strong> message so the port exists and it is open, but then nothing else, no timeout, nothing.
I already lost one day trying out all sorts of combinations but it just doesn't work, my C# app can't communicate with the Arduino Nano 33 BLE. It looks like a serial port issue so I think I'll put it on hold for now...</p>
<p>EDIT:
The rest of my test code, for reference:</p>
<pre><code>private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    try
    {
        Debug.Print(serialPort.ReadExisting());
    }
    catch (Exception exception)
    {
        Debug.Print(exception.Message);
    }
}

private void buttonSend_Click(object sender, EventArgs e)
{
    try
    {
        serialPort.WriteLine(&quot;HELLO&quot;);
    }
    catch (Exception exception)
    {
        Debug.Print(exception.Message);
    }
}
</code></pre>
 70020: <p>I noticed that a lot of line discipline and flow control settings were not made explicit in your C# code, so it made me wonder what they were by default.</p>
<p>In particular <code>DtrEnable</code> appears to be <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.dtrenable?view=dotnet-plat-ext-7.0#system-io-ports-serialport-dtrenable" rel="nofollow noreferrer">false by default</a> and <code>Handshake</code> is None by default (which seems to be irrelevant). The other default amount to 8N1. The first part I found interesting because it seems more typical in serial APIs for DTR to be automatically asserted when a port is opened when you're not explicitly asking it to.  If I'm reading the .NET documentation correctly, it isn't for your application. The original Nano doesn't much care about DTR apart from a falling edge triggering reset. The board is happy to communicate with it solidly either asserted or not. The original Nano's DTR is only capacitively coupled to reset; there's not a way for the code running on the AVR to respond to DTR (unless you count resetting). That lead to a question about to what extent a Nano 33 BLE would care about DTR.</p>
<p>As it turns out the Nano BLE does care. If I deassert DTR in test with pyserial the board stops sending traffic back. I can write while it's deasserted and after asserting again some queued data arrives. <em>A test environment with pyserial is just more immediately available to me; if needed and I get a chance I'll set up a .net/C# test and confirm with that, but I suspect that won't be necessary.</em> Seeing that result, I searched and found <a href="https://forum.arduino.cc/t/cannot-read-write-using-3rd-party-terminal-to-arduino-nano-ble-board/642034" rel="nofollow noreferrer">this Arduino Forum post</a> with a somewhat similar problem description. The OP replies in answer to their own post saying:</p>
<blockquote>
<p>Problem sorted out. Arduino nano BLE requires DTR and RTS signals to
be On. Then it works like FDTI.</p>
</blockquote>
<p>Disabling RTS had no effect during my tests with pyserial. I'm not sure why it would. Perhaps they just asserted it preemptively. Being entirely a virtual port RTS doesn't really make sense for flow control. DTR might arguably still makes more sense in this context; at the level of serial signals it normally tells you something is paying attention on the other side of the connection. I'm not really surprised, either way, that the BLE sense would react to DTR being disabled by not sending data to the host; there's a lot of latitude in how these signals can be handled. That it's not automatically used when the port is opened (or until specifically requested) seems <em>mostly</em> a C# thing. But it looks like the different handling of DTR between the two boards that is making your code work with one but not the other.</p>
<p>So it would seem necessary and sufficient to add</p>
<pre class="lang-cpp prettyprint-override"><code>serialPort.DtrEnable = true;
</code></pre>
<p>amongst your other settings following the opening of the port.</p>
<p>If there's truth to what the Arduino Forum poster said about RTS, then you would also need</p>
<pre class="lang-cpp prettyprint-override"><code>serialPort.RtsEnable = true;
</code></pre>
<p>but this is not indicated by the tests I've done (though again with pyserial).</p>
