Multiple Serial Ports through 1 Arduino and 1 USB

edited December 2013 in Arduino

So, let's say my Arduino board has more than 1 serial port (RX/TX). Is it possible to send info from these serial ports to Processing, separately?

In my case, my board has 2 pairs of RX/TX pins (RX/TX as well as RX1/TX1). I have two sensors, connected to A0 and A1 respectively. Is it possible for me to send info from A0 serially to Processing, while sending info from A1 serially to Processing as well, BOTH through a 1 USB port?

(My understanding is that the USB is connected to RX/TX and not to RX1/TX1, so I can only send 1 set of data. Is there a way around this?)

Thank you.



  • of course, but this needs to be done in Arduino IDE, not just firmata. You can send data from any number of sensors down your RX/TX which in turn sends it via USB to processing. You'll need to find a way to know which value you are looking at though. There are two basic approaches to that. Simpler one is use timings, ie. make a 100ms delay, then send data in series (data1, data2), than make a delay. This is to allow detection of the frame start, Processing need to be able to re-sync to your stream if one byte is lost (it can happen, even if it doesn't happen much with usb). Alternatively you can create a protocol, like starting with an unlikely value (FF00FF00 or something) followed by your data1 followed by your data2. This way you don't need delays but you need to look for your preamble, and you should make sure that this combination doesn't actually appear in your data. If you just start sending data1, data2, data1, data2, it may work if lucky, but there might be some reliability issues - i.e. if anything gets lost your data might get switched around.

Sign In or Register to comment.