Connect USB device over uart

Hello. I try to connect my USB device to Arduino and send some data to them. I did it like:

void setup() {
  Serial2.begin(57600, SERIAL_8N1, 2, 3);

  Serial2.print("4D00");
 
}

I test it between two Arduino and communication is fine.

USB device must make beep when I send "4D00" - on Windows over Termite worked correctly.
But over Arduino nothing happened.

When I connect USB device to my PC, I get 2 COM ports:
2_port_one_device
and I use COM18. As I understand - it's themain problem

Is any one know how to set "COM port" in sketch? Thanks

Please post a link to the USB device.

how to set "COM port" in sketch

A COM port is a Windows device handle.

Sorry, but I have not link for this device

I know, that COM is a Windows device handle in Linux - ttyACM (in Linux it's too 2 device ttyACM0 and ttyACM1)

May by it's possible to set hardware ID?

Try "4D00\n"

Please clarify what do you try to achieve? You have an Arduino connected to one USB port, and the other USB device to another USB port of PC, yes?
Now you want to connect them one to another via UART?
If so - you need a program in your Pc, which will interconnect two USB ports

no... I have one USB device which has 2 programming port inside it.
When I connect USB device to PC system identity COM17 and COM18
if I send "4D00" to COM17 - nothing happens
if I send "4D00" to COM18 I get beep.

Then I connect this USB device to Arduino

3 - USB D-
2 - USB D+

send "4D00" and nothing happens. I tried send it byte:

  byte test[] = { 0x4D, 0x00};
  Serial2.write(test, sizeof(test));

but not any result

see post 5

USB and UART are different protocols. You can't connect USB data lines directly to Arduino Rx TX pins, you will need a USB-UART converter for it

thanks, but it's not help.

you mean something like CP2102?

something like

but for this converter need drivers. Will it work if I connect it to Arduino and USB-device?...

This is what you need:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.