I have a MEGA running DCC++ for controlling my model railroad trains and turnouts, it receives string commands via Serial and a (relatively long) USB cable connected to a PC running Processing.
I want to make a handheld throttle with an Arduino board, it can be a Nano (plus LCD display, encoder, etc.) Sometimes I need to walk along the layout for some close-up ops.
Now, is it possible to wire TX and RX pins from the Nano to the USB cable (using a female adapter, of course) in order to send the string commands to the MEGA? Will it work?
The MEGA board is not easily accessible as it is located under the layout and I don't want to add wires connected to its TX and RX pins, I want to use the existing USB cable that comes from it.
Just in case someone suggests to use a wireless controller...I have JMRI installed in the PC and of course I can use my cell phone running an engine driver app after starting the throttle webserver but the wifi signal is very poor in my workshop, I've tried in the past with poor results.
You cannot connect the Tx and Rx pins to a USB cable - they are totally incompatible. On a Mega or Uno there is a separate microprocessor that converts between Rx and Tx and the USB signal.
You should be able to connect Rx and Tx of the nano to (say) Tx1 and Rx1 of the Mega (and also GND to GND) and send serial messages that way. You may need to experiment to see what is the longest cable that will work but I reckon 2 metres (and maybe 3) should be feasible.
If you have your PC with JMRI in the same room as your model railway then a simpler solution might be to install a local WiFi hotspot with a cheap WiFi router which would not need to be connected to your main home WiFi system.
My Android phone has a WiFi hotspot facility and if yours has that capability it may be sufficient.