Passthrough from RX to usb on Arduino Nano possible

Hello
I would like to passthrough serial Data from RX pin to the USB port. Is this possible? I searched for passthrough but all I could found was from Serial0 to Serial1 on Arduino Mega etc.
My build to understand it better (or having a better solution):
I've build a midi "Fender Rhodes" keyboard which has 3 knobs for volume, bass and treble. These knobs are sending Serial Midi data over usb to the PC with an virtual Instrument installed. On the PC I use Hairless Midi to transform the Serial Midi Data into real Midi.
That already works great and was very easy.

Now I made an external midi effects board with 11 potentiometers and 5 switches. It uses another Arduino Nano and I want to transfer the data via an instrument cable to the Arduino in the keyboard. So its TX and GND on the effects board and RX and GND on the Keyboard ("Hello world" works).

I thought: If its possible to receive serial midi data on the keyboards Nano (from the effects board) I can passthrough that data to the Usb and send it to the PC.

Hope it is understandable what I try to do and that someone can point me in the right direction.

Martin

what do you mean by passthrough ?

The Rx port on your Arduino is (simplistically) connected to the Tx port on the USB side .

does that mean everything I receive on the RX pin is automatically send to usb/TX?

from what you explain, I'd say you could write a small piece of code which listens on Serial (Rx) and transfers whatever it gets on Tx.

void loop() {
  if (Serial.peek() != -1) Serial.write(Serial.read());
  // rest of your code here
}

The wiring would need a bit of work (diode ?) probably as you are connected this way

Tx (PC) ---> Rx (Arduino 1) <---- Tx (Arduino 2)

The problem is, that the Nano uses the serial line as interface to USB/PC. There is no free serial line. It may work if you don't send anything from PC to the Nano. But you alway have to disconnect your interface if you want to upload an updated sketch to the Nano. I would not recommend to do so.
You can use a pro micro board ( with an ATmega32u4 ) instead of the Nano. The serial line is independent of the USB interface at this board, and the pro Micro can act as a true MIDI device at the USB port. You don't need Hairless MIDI in this case.

Tx(PC) is the output of the USB-TTL interface, and there is a 1k resistor between Tx(PC) and Rx(Nano/Arduino1). If you connect Tx(Arduino2) directly to Rx of your Nano it will inhibit receiving anything from PC. That's why you must disconnect to upload a new sketch.

That's why I'm saying

The wiring would need a bit of work

Yes, and that's why I would recommend using a pro Micro instead of the Nano :wink:

definitely a good choice.

Trank you very much!
I dont need to upload anything to the arduino and I can easily unplug the Instrument cable so there is nothing on the tx/rx Ports connected. Do I still need a diode? Or would it work just with the code and the Nano? If a Diode and a micro is better i can order one. It just would be nice if it works without.

If this is a MIDI cable, you need additional HW between cable and Rx pin and simply unplugging will not help. You don't need a diode.
I would always use a micro for MIDI purposes. Not only because the serial line is not occupied by USB but also because the micro can behave as a true USB MIDI device. Hairless MIDI is just a crutch.
But thats only my opinion :wink:

Sorry! I had to work. Its just a normal 2 pin guitar cable which connectsTX->RX and GNG->GND.
I tried the code and it works great! I still might get a Micro (I know Hairless MIDI is not the right way to do MIDI).
Thank you very much.