how to use 2 usb serial port at the same time on computer

I am wondering, is it possible to use 2 usb port at the same time?

Example i am using 1 UART usb serial port to send data to computer. Then, arduino receive the data through USB and the shows the data on serial monitor.

How do i write the code and what library should be using??please give any help. Any replied is highly appreciate. thanks

I am wondering, is it possible to use 2 usb port at the same time?

On the PC? Yes.

On the Arduino? How? Most only have one. If yours has more than one, please post a link to it.

I think the OP is refering to can I use two arduinos at one PC by USB connection.
So each arduino will have a comport number occupied and how to send data.

Paco

I think the OP is refering to can I use two arduinos at one PC by USB connection.

That is certainly possible.

So each arduino will have a comport number occupied and how to send data.

Each connection by an Arduino will create a new com port. The communication between the Arduino and the PC is exactly the same if there is one Arduino connected to one com port on the PC as if there are 12 Arduinos connected to 12 com ports on the PC.

backbone:
I think the OP is refering to can I use two arduinos at one PC by USB connection.
So each arduino will have a comport number occupied and how to send data.

Paco

ya that is what i mean.
Example, an UART usb serial port (eg sensor) send the data through USB (com port) to PC. And then these data is needed to transfer to Arduino board (another com port) by USB. Is it possible? and how to write the code? As i am beginner in arduino, I do not know which library should be use. Please guide me. Thanks.

I think you better try to explain what you like to accomplish with your project.
You want to read data with one UNO and sensor to the PC and then work this data in the pc and send it back to an other UNO.
Is there a real need to have 2 UNO's?
One UNO can read and send sensor data that is worked over in the PC.

Paco

backbone:
I think you better try to explain what you like to accomplish with your project.
You want to read data with one UNO and sensor to the PC and then work this data in the pc and send it back to an other UNO.
Is there a real need to have 2 UNO's?
One UNO can read and send sensor data that is worked over in the PC.

Paco

Thanks for your replied. now i own an ADXL345 Eval board with usb port built in.

Then i wish to use it to connect to my pc. and then i will connect arduino Uno to my pc at the same time also. Then i wish that arduino Uno can get the data from adxl eval board. This is the flow that i think:
ADXL345 eval board -> pc (USB serial port eg com port 21). Then pc -> arduino (USB serial port eg com port 22 ). Then how do i write in arduino code to include com port 21 for adxl eval board?

Each Arduino will read and write from it's own Serial port, and you'll need a small program running on the PC to transfer the data between the two.

dxw00d:
Each Arduino will read and write from it's own Serial port, and you'll need a small program running on the PC to transfer the data between the two.

this is the 1 i am looking for. can u guide me how??really appreciate that^^

There's not much to it. When a byte comes in on serial port a, write it to serial port b, and when a byte comes in on port b, write it to port a. The exact implementation would depend on what language you were using on the PC.

dxw00d:
There's not much to it. When a byte comes in on serial port a, write it to serial port b, and when a byte comes in on port b, write it to port a. The exact implementation would depend on what language you were using on the PC.

can i do like that??i have the concept like this also...because it is simplest way to do it. I am using windows, using arduino GUI. It is using C language right. any special library need to included? is it same as normal code to use void setup() and then void loop()?

can i do like that??i have the concept like this also...because it is simplest way to do it. I am using windows, using arduino GUI. It is using C language right. any special library need to included? is it same as normal code to use void setup() and then void loop()?

You can't write a PC application using the Arduino IDE.

PaulS:

can i do like that??i have the concept like this also...because it is simplest way to do it. I am using windows, using arduino GUI. It is using C language right. any special library need to included? is it same as normal code to use void setup() and then void loop()?

You can't write a PC application using the Arduino IDE.

then any others IDE that you can intro to me??

There are many to choose from. Processing is free, and has a very similar IDE. If you are a Windows user, then Visual C# express and Visual Basic express are also free. If you don't need a fancy gui, and it isn't necessary for this application, then the tiny c compiler would probably do.

dxw00d:
There are many to choose from. Processing is free, and has a very similar IDE. If you are a Windows user, then Visual C# express and Visual Basic express are also free. If you don't need a fancy gui, and it isn't necessary for this application, then the tiny c compiler would probably do.

Ok now i have netbean because i did JAVA project previously. So can i use netbean? and any example guide that you can show me so that i can refer to?regarding on how to communicate with multiple com port...i need some guide on the library and the C# code

i need some guide on the library

What library?

and the C# code

What C# code?

PaulS:

i need some guide on the library

What library?

and the C# code

What C# code?

mean if i use others IDE, then how i write the code for communicating between 2 com port?

It depends on what you use. Look at it's documentation for reading and writing serial data.

dxw00d:
It depends on what you use. Look at it's documentation for reading and writing serial data.

ok thanks..i will look on that. if anything, i will post here and ask again. Thanks all of you for kindness replied. Thanks so much^^ :slight_smile:

I fear you're on a far too complicated path!

your link about the Evaluation Board - ADXL345 says
" The UART pins are also broken out allowing a direct TTL interface with the processor. "

You just need two digital pins and GND from the Arduino and connect that directly to the ADXL uart. (Rx to Tx , Tx to Rx, GND to GND)
Then look for the Arduino SoftwareSerial Library, and hopefully you see it's all done, already.

The next task is you probably need to see on the PC what's going on,
so you might like to copy the communication (both sides) to the standard serial.println to log it in the PC Arduino Serial Monitor.