Go Down

Topic: How to program Due serial ports (Read 5793 times) previous topic - next topic


In my own clumsy way, I quote here from the Serial section of the Language reference.

"The Arduino Due has three additional 3.3V TTL serial ports: Serial1 on pins 19 (RX) and 18 (TX); Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip, which is connected to the USB debug port. Additionally, there is a native USB-serial port on the SAM3X chip, SerialUSB'. "
This is all of interest to me but useless if I don't know how to program the several ports. There is no hint that I could see on the associated functions/methods appropriate to these Due ports. There should be some kind of hyperlink here. I also get the feeling that some of these ports have different names in other places.

Are pins 0 and 1 really connected to two different ports?
Where is more documentation of the debug port? Is this the Serial Monitor?
How is the word SerialUSB related to the native port? Is it a software keyword?
From browsing documentation for other boards I gather that, for example, Serial1.begin() would activate pins 18 and 19. Is that correct?

Thank you for any information.


Hi grimdon,

I think all answers are in these 3 links:

But I'm right with you, it's difficult to understand, it's complex schemas.
I've tried some cases and I can confirm that docs are right.

Case of Serial1, Serial2 and Serial3 are simple: The pins 14 to 19 are connected to the AVR and can have other usages.

Case of Serial is more complex: Pins 0 and 1 are connected to the AVR and to the USB programming port. If the USB programming port is in use (when you program the AVR or when you communicate with the AVR), pins 0 and 1 are connected to the programming port and don't be used for any other usages.

Case of SerialUSB is different: No pins are used and you must use the native USB port to communicate with the AVR.

Take care of special RESET/ERASE actions at 1200Bps on the USB programming port and the USB native port.

Take care of NO RESET action at open/close of the USB native port.


Sep 07, 2017, 01:13 am Last Edit: Sep 07, 2017, 01:32 am by KevinA
I have to agree with @grimdon, this is crap;
sketch serialpassthrough does not work on the Due. As configured it has serial and serial1 configured BUT the USB programming port shows up on the PC as COM11 and the USB (AB is the only thing I found) shows up on the PC as COM12 BUT (again) what do you call the USB (AB) in the sketch?

A simple pass through loop that fails out of the box... I am not getting a warm and fuzz with the Due...
More GoogleFu produced: http://copperhilltech.com/blog/how-to-use-the-native-usb-of-the-arduino-due-for-highspeed-communication/
and that resulted in modification of MultiSerial:
  Multple Serial test

 Receives from the main serial port, sends to the others.
 Receives from serial port 1, sends to the main serial (Serial 0).

 This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc

 The circuit:
 * Any serial device attached to Serial port 1
 * Serial monitor open on Serial port 0:

 created 30 Dec. 2008
 modified 20 May 2012
 by Tom Igoe & Jed Roach
 modified 27 Nov 2015
 by Arturo Guadalupi

 This example code is in the public domain.
Modified 9/7/2017 for Due support with SerialUSB

void setup() {
  // initialize both serial ports:
  SerialUSB.begin(9600);    // Initialize Native USB port

void loop() {
  // read from port 1, send to port 0:
  if (SerialUSB.available()) {
    int inByte = SerialUSB.read();

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();


Sep 07, 2017, 06:48 am Last Edit: Sep 07, 2017, 06:56 am by ard_newbie
This sketch works (BTW post your code between code tags).

SerialUSB is the communication function used with the native USB port, Serial with UART (RX/TX) and Serialn(RXn/TXn) with the corresponding USARTp (Serial1 for USART0, Serial2 for USART1, Serial3 for USART3 and Serial4 for USART2 with a few more lines of code for this last one).

In a first Arduino IDE window, select Arduino DUE(Programming Port), Connect the board to your PC, select a Com port accordingly, i.e. for me it's "Port: Com4 (Arduino DUE Programming Port)". Upload this skectch.

Then in another IDE window opened with a right click in your short-cut IDE, select Arduino DUE (Native USB Port), connect the board to your PC with a USB cable, select a Com port accordingly, i.e. for me it's Com 8 (Arduino DUE Native USB Port)".

Sometimes the correct port doesn't show the first time you connect your cable, unconnect and connect again your cable until the correct port shows in Menu > Tools > Port.

Go Up