SoftwareSerial Nano Every minimum baud rate

Q: Can anyone tell me what is wrong with this simple code on a Nano Every?
I am receiving two equal bytes on the HW serial (USB) to trigger one byte to be sent/received on the SWserial port. The SWserial port is looped (wire D2-D3).
The number of bytes received on D2 is always zero.

A: Meanwhile I found the answer myself. SoftwareSerial does not support any baudrate lower than 9600 at least on the Nano Every. To let my struggle not be wasted, I am posting this for others who might have the same issue.

#include <SoftwareSerial.h>

SoftwareSerial Ser1(2, 3); //RX=2 TX=3

byte r0 = 0; //byte 0 received from USB
byte r1 = 0; //byte 1 received from USB
byte a0 = 0; //bytes available on SW ser

void setup()
{ 
  // Start the hardware serial port
  Serial.begin(9600);
  while (!Serial) {;}
  // Start software serial port
  Ser1.begin(2400);
  while (!Ser1) {;}
  if (Ser1.isListening()) { Serial.println("listening"); } //Yes, port is listening
}

void loop()
{
  while (Serial.available() < 2) {;}
  r0 = Serial.read();
  r1 = Serial.read();
  if (r0 == r1) {
    int sent=Ser1.write(88); //write any byte to Ser1, Pin D2-D3 looped back
    delay(200);
    a0 = Ser1.available();  //a0 is alway zero
    Serial.println(sent);    // sent=1
    Serial.println(a0);
    if (a0>0) Ser1.read();
  }
  }

SoftwareSerial will take over the entire Arduino board and many libraries will no longer work. Sending and receiving at the same time is a problem.

The Nano Every connects to the computer via Serial over usb [ADDED] (using a SAMD chip).
Then there is also a spare hardware Serial1 port at pin 0 and 1. You could do your test with Serial1, and then it should work.

If you really want a third Serial port, try AltSoftSerial. It functions in a different way, sometimes better, sometimes worse, but mostly better.
I don't know if AltSoftSerial is compatible with the Nano Every.

Using MCUdude's MegaCoreX you should be able to use all four hardware serial ports. You can alternatively modify the arduino core files, but that is a lot more involved.

SoftwareSerial on most arduino's is not capable of receiving its own output.

I am very sure that the Nano Every has only one serial HW port which is shared among USB and RX/TX pins.
I don't know the implications of SoftwareSerial on other libraries but as my application is quite simple I don't need any other one. I just wanted to point out that one should not go below 9600 on the SW serial port. As for the upper limit, I have not tried it.

But not 100% ? :wink:
Check the schematic, datasheet and documentation.
https://www.arduino.cc/en/Guide/NANOEvery#features
There is a dedicated serial port to the SAMD chip which is used for serial-usb.
The Serial1 port a pin 0 and 1 is available.

I understand your point, and thank you for your contribution.
It is good that the SoftwareSerial exists, but it has many more disadvantages.

Thank you, I will study this. But it seems quite complicated. Still it would be the best solution.
My goal is to replace a daughter board on a existing device (with a raspberry Pi as the main MCU) with an Arduino that acts simply as a USB/serial converter. For mechanical compatibility of the daughter board I dont want any FTDI USB/serial converters. In fact, the daughter board with the Arduino is only a USB/serial converter that interacts with another remote Arduino that controls electro-mechanical relays.

Those text labels for the pins on the Nano Every board are so small ! :mag:

I did a test with a Arduino Every.
Connected TX1 to RX0, and run this sketch:

// Test Serial1 Arduino Every
//
// Board: Arduino Every, with TX1 connected to RX0.
// Arduino IDE 1.8.15

void setup()
{
  Serial.begin( 9600);             // to the computer
  Serial1.begin( 9600);            // looped TX1-RX0

  Serial.println( "Type something, and it will echo via Serial1");
}

void loop()
{
  if( Serial.available() > 0)      // something from the computer ?
  {
    int inChar = Serial.read();
    Serial1.write( (byte) inChar); // write it to Serial1
  }

  if( Serial1.available() > 0)     // something from the looped Serial1 ?
  {
    int inChar = Serial1.read();
    Serial.write( (byte) inChar);  // send it to the computer
  }
}

That works.

Your sketch is waiting in a while-loop, has a delay, and it reads reads two bytes, that is impossible to be reliable.
As you can see, my sketch is the cleanest way to echo the data. That works because it is so simple. Don't overthink it, follow the KISS rule.

By the way, the AltSoftSerial is not compatible with the Nano Every.

You are right!
Serial designates the USB UART
Serial1 designates the HW UART on pins PC5 PC4
Unfortunately the documentation gives no clue to that.
Thank you!