Skip to content

Commit 633ff24

Browse files
authored
Merge pull request #480 from per1234/update-serial-ports
Correct/update information about available serial ports for each board
2 parents 25d8358 + 0c614ed commit 633ff24

22 files changed

+71
-110
lines changed

Language/Functions/Communication/Serial.adoc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,28 @@ subCategories: [ "Communication" ]
1616

1717
[float]
1818
=== Description
19-
Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output. +
19+
Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART), and some have several.
20+
[options="header"]
21+
|================================================================================================================================================
22+
| Board | USB CDC name | Serial pins | Serial1 pins | Serial2 pins | Serial3 pins
23+
| Uno, Nano, Mini | | 0(RX), 1(TX) | | |
24+
| Mega | | 0(RX), 1(TX) | 19(RX), 18(TX) | 16(RX), 17(TX) | 15(RX), 14(TX)
25+
| Leonardo, Micro, Yún | Serial | 0(RX), 1(TX) | | |
26+
| Uno WiFi Rev.2 | | Connected to USB | 0(RX), 1(TX) | Connected to NINA |
27+
| MKR boards | Serial | | 13(RX), 14(TX) | |
28+
| Zero | SerialUSB (Native USB Port only) | Connected to Programming Port | 0(RX), 1(TX) | |
29+
| Due | SerialUSB (Native USB Port only) | 0(RX), 1(TX) | 19(RX), 18(TX) | 16(RX), 17(TX) | 15(RX), 14(TX)
30+
| 101 | Serial | | 0(RX), 1(TX) | |
31+
|================================================================================================================================================
32+
33+
On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board.
34+
[%hardbreaks]
2035
You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to `begin()`.
2136
[%hardbreaks]
2237
Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board). Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.
2338
[%hardbreaks]
24-
The *Arduino Mega* has three additional 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). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground.
25-
[%hardbreaks]
26-
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'.
39+
To use these extra serial ports to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground.
2740
[%hardbreaks]
28-
The *Arduino Leonardo* board uses `Serial1` to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX). `Serial` is reserved for USB CDC communication. For more information, refer to the Leonardo getting started page and hardware page.
2941

3042
--
3143
// OVERVIEW SECTION ENDS

Language/Functions/Communication/Serial/available.adoc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@ Get the number of bytes (characters) available for reading from the serial port.
1717

1818
[float]
1919
=== Syntax
20-
`Serial.available()`
21-
22-
_Arduino Mega only:_
23-
24-
`Serial1.available()` +
25-
`Serial2.available()` +
26-
`Serial3.available()`
27-
20+
`_Serial_.available()`
2821

2922
[float]
3023
=== Parameters
31-
None
24+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3225

3326
[float]
3427
=== Returns

Language/Functions/Communication/Serial/availableForWrite.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@ Get the number of bytes (characters) available for writing in the serial buffer
2020

2121
[float]
2222
=== Syntax
23-
`Serial.availableForWrite()`
24-
25-
_Arduino Mega only:_
26-
27-
`Serial1.availableForWrite()` +
28-
`Serial2.availableForWrite()` +
29-
`Serial3.availableForWrite()`
23+
`_Serial_.availableForWrite()`
3024

3125

3226
[float]
3327
=== Parameters
34-
Nothing
28+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3529

3630
[float]
3731
=== Returns

Language/Functions/Communication/Serial/begin.adoc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,15 @@ An optional second argument configures the data, parity, and stop bits. The defa
2222

2323
[float]
2424
=== Syntax
25-
`Serial.begin(speed)`
26-
`Serial.begin(speed, config)`
27-
28-
_Arduino Mega only:_
29-
30-
`Serial1.begin(speed)` +
31-
`Serial2.begin(speed)` +
32-
`Serial3.begin(speed)` +
33-
`Serial1.begin(speed, config)` +
34-
`Serial2.begin(speed, config)` +
35-
`Serial3.begin(speed, config)`
25+
`_Serial_.begin(speed)` +
26+
`_Serial_.begin(speed, config)`
3627

3728

3829

3930
[float]
4031
=== Parameters
32+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
33+
4134
`speed`: in bits per second (baud) - `long`
4235

4336
`config`: sets data, parity, and stop bits. Valid values are

Language/Functions/Communication/Serial/end.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@ Disables serial communication, allowing the RX and TX pins to be used for genera
2020

2121
[float]
2222
=== Syntax
23-
`Serial.end()`
24-
25-
_Arduino Mega only:_
26-
27-
`Serial1.end()` +
28-
`Serial2.end()` +
29-
`Serial3.end()` +
23+
`_Serial_.end()`
3024

3125

3226
[float]
3327
=== Parameters
34-
Nothing
28+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3529

3630
[float]
3731
=== Returns

Language/Functions/Communication/Serial/find.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ Serial.find() inherits from the link:../../stream[stream] utility class.
2222

2323
[float]
2424
=== Syntax
25-
`Serial.find(target)` +
26-
`Serial.find(target, length)`
25+
`_Serial_.find(target)` +
26+
`_Serial_.find(target, length)`
2727

2828
[float]
2929
=== Parameters
30+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
31+
3032
`target` : the string to search for (char)
3133

3234
`length` : length of the target (size_t)

Language/Functions/Communication/Serial/findUntil.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ The function returns true if the target string is found, false if it times out.
2424

2525
[float]
2626
=== Syntax
27-
`Serial.findUntil(target, terminal)`
27+
`_Serial_.findUntil(target, terminal)`
2828

2929

3030
[float]
3131
=== Parameters
32-
`target` : the string to search for (char)
32+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +
33+
`target` : the string to search for (char) +
3334
`terminal` : the terminal string in the search (char)
3435

3536
[float]

Language/Functions/Communication/Serial/flush.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,12 @@ Waits for the transmission of outgoing serial data to complete. (Prior to Arduin
2222

2323
[float]
2424
=== Syntax
25-
`Serial.flush()`
26-
27-
_Arduino Mega only:_
28-
29-
`Serial1.flush()` +
30-
`Serial2.flush()` +
31-
`Serial3.flush()`
25+
`_Serial_.flush()`
3226

3327

3428
[float]
3529
=== Parameters
36-
Nothing
30+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3731

3832
[float]
3933
=== Returns

Language/Functions/Communication/Serial/ifSerial.adoc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,16 @@ title: if(Serial)
1616
=== Description
1717
Indicates if the specified Serial port is ready.
1818

19-
On the Leonardo, `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all other instances, including `if (Serial1)` on the Leonardo, this will always return true.
19+
On the boards with native USB, `if (Serial)` (or `if(SerialUSB)` on the Due) indicates whether or not the USB CDC serial connection is open. For all other boards, and the non-USB CDC ports, this will always return true.
2020

2121
This was introduced in Arduino IDE 1.0.1.
2222
[%hardbreaks]
2323

2424

2525
[float]
2626
=== Syntax
27-
_All boards:_
28-
2927
`if (Serial)`
3028

31-
_Arduino Leonardo specific:_
32-
33-
`if (Serial1)`
34-
35-
_Arduino Mega specific:_
36-
37-
`if (Serial1)` +
38-
`if (Serial2)` +
39-
`if (Serial3)`
40-
4129
[float]
4230
=== Parameters
4331
Nothing

Language/Functions/Communication/Serial/parseFloat.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ title: Serial.parseFloat()
2222

2323
[float]
2424
=== Syntax
25-
`Serial.parseFloat()`
25+
`_Serial_.parseFloat()`
2626

2727

2828
[float]
2929
=== Parameters
30-
Nothing
30+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3131

3232
[float]
3333
=== Returns

Language/Functions/Communication/Serial/parseInt.adoc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,13 @@ In particular:
2727

2828
[float]
2929
=== Syntax
30-
`Serial.parseInt()`
31-
`Serial.parseInt(char skipChar)`
32-
33-
_Arduino Mega only:_
34-
35-
`Serial1.parseInt()` +
36-
`Serial2.parseInt()` +
37-
`Serial3.parseInt()`
30+
`_Serial_.parseInt()` +
31+
`_Serial_.parseInt(char skipChar)`
3832

3933

4034
[float]
4135
=== Parameters
36+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +
4237
`skipChar`: used to skip the indicated char in the search. Used for example to skip thousands divider.
4338

4439
[float]

Language/Functions/Communication/Serial/peek.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@ Returns the next byte (character) of incoming serial data without removing it fr
2020

2121
[float]
2222
=== Syntax
23-
`Serial.peek()`
24-
25-
_Arduino Mega only:_
26-
27-
`Serial1.peek()` +
28-
`Serial2.peek()` +
29-
`Serial3.peek()`
23+
`_Serial_.peek()`
3024

3125

3226
[float]
3327
=== Parameters
34-
Nothing
28+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3529

3630
[float]
3731
=== Returns

Language/Functions/Communication/Serial/print.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ To send data without conversion to its representation as characters, use link:..
4242

4343
[float]
4444
=== Syntax
45-
`Serial.print(val)` +
46-
`Serial.print(val, format)`
45+
`_Serial_.print(val)` +
46+
`_Serial_.print(val, format)`
4747

4848

4949
[float]
5050
=== Parameters
51+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +
5152
`val`: the value to print - any data type
5253

5354
[float]

Language/Functions/Communication/Serial/println.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ Prints data to the serial port as human-readable ASCII text followed by a carria
2020

2121
[float]
2222
=== Syntax
23-
`Serial.println(val)` +
24-
`Serial.println(val, format)`
23+
`_Serial_.println(val)` +
24+
`_Serial_.println(val, format)`
2525

2626

2727
[float]
2828
=== Parameters
29+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
30+
2931
`val`: the value to print - any data type
3032

3133
`format`: specifies the number base (for integral data types) or number of decimal places (for floating point types)

Language/Functions/Communication/Serial/read.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@ Reads incoming serial data. read() inherits from the link:../../stream[Stream] u
2020

2121
[float]
2222
=== Syntax
23-
`Serial.read()`
24-
25-
_Arduino Mega only:_
26-
27-
`Serial1.read()` +
28-
`Serial2.read()` +
29-
`Serial3.read()`
23+
`_Serial_.read()`
3024

3125

3226
[float]
3327
=== Parameters
34-
Nothing
28+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3529

3630
[float]
3731
=== Returns

Language/Functions/Communication/Serial/readBytes.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ title: Serial.readBytes()
2424

2525
[float]
2626
=== Syntax
27-
`Serial.readBytes(buffer, length)`
27+
`_Serial_.readBytes(buffer, length)`
2828

2929

3030
[float]
3131
=== Parameters
32+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
33+
3234
`buffer`: the buffer to store the bytes in (`char[]` or `byte[]`)
3335

3436
`length` : the number of bytes to read (`int`)

Language/Functions/Communication/Serial/readBytesUntil.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ Serial.readBytesUntil() reads characters from the serial buffer into an array. T
2424

2525
[float]
2626
=== Syntax
27-
`Serial.readBytesUntil(character, buffer, length)`
27+
`_Serial_.readBytesUntil(character, buffer, length)`
2828

2929

3030
[float]
3131
=== Parameters
32+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
33+
3234
`character` : the character to search for (`char`)
3335

3436
`buffer`: the buffer to store the bytes in (`char[]` or `byte[]`)

Language/Functions/Communication/Serial/readString.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ This function is part of the Stream class, and is called by any class that inher
2323

2424
[float]
2525
=== Syntax
26-
`Serial.readString()`
26+
`_Serial_.readString()`
2727

2828

2929
[float]
3030
=== Parameters
31-
Nothing
31+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page].
3232

3333
[float]
3434
=== Returns

Language/Functions/Communication/Serial/readStringUntil.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ This function is part of the Stream class, and is called by any class that inher
2323

2424
[float]
2525
=== Syntax
26-
`Serial.readStringUntil(terminator)`
26+
`_Serial_.readStringUntil(terminator)`
2727

2828

2929
[float]
3030
=== Parameters
31+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +
3132
`terminator` : the character to search for (`char`)
3233

3334
[float]

Language/Functions/Communication/Serial/serialEvent.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void serialEvent(){
2929
//statements
3030
}
3131
----
32-
Arduino Mega only:
32+
For boards with additional serial ports (see the list of available serial ports for each board on the link:../../serial[Serial main page]):
3333
[source,arduino]
3434
----
3535
void serialEvent1(){

Language/Functions/Communication/Serial/setTimeout.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ title: Serial.setTimeout()
2222

2323
[float]
2424
=== Syntax
25-
`Serial.setTimeout(time)`
25+
`_Serial_.setTimeout(time)`
2626

2727
[float]
2828
=== Parameters
29+
`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +
2930
`time` : timeout duration in milliseconds (`long`).
3031

3132
[float]

0 commit comments

Comments
 (0)