@@ -412,10 +412,12 @@ void setup() {
412
412
413
413
## USB Serial & UART
414
414
415
- The Nano ESP32 board features 2 separate hardware serial ports.
415
+ The Nano ESP32 board features 3 hardware serial ports, as well as a port exposed via the USB port .
416
416
417
- One port is exposed via USB-C®, and
418
- One is exposed via RX/TX pins.
417
+ - ` Serial ` refers to the USB port.
418
+ - ` Serial0 ` refers to the hardware serial port (UART), accessible via the board's RX/TX pins (D0, D1)
419
+ - ` Serial1 ` is the second UART port, which can be assigned to any free GPIO.
420
+ - ` Serial2 ` is the third UART port, which can also be assigned to any free GPIO.
419
421
420
422
### Native USB
421
423
@@ -430,7 +432,7 @@ To send and receive data through UART, we will first need to set the baud rate i
430
432
431
433
### UART
432
434
433
- The pins used for UART on the Nano ESP32 are the following:
435
+ The default pins for UART communication on the Nano ESP32 are the following:
434
436
435
437
| Pin | Function | Description |
436
438
| --- | -------- | -------------------- |
@@ -461,6 +463,30 @@ And to write something, we can use the following command:
461
463
Serial0.write("Hello world!");
462
464
```
463
465
466
+ ### Serial1 & Serial2
467
+
468
+ The Nano ESP32 features additional hardware serial ports, but these needs to be manually assigned.
469
+
470
+ To use ` Serial1 ` and ` Serial2 ` , you need to initialize them in your program's ` setup() ` function:
471
+
472
+ ``` arduino
473
+ //initialization
474
+ Serial1.begin(9600, SERIAL_8N1, RX1PIN, TX1PIN);
475
+ Serial2.begin(9600, SERIAL_8N1, RX2PIN, TX2PIN);
476
+
477
+ //usage
478
+ Serial1.write("Hello world!");
479
+ Serial2.write("Hello world!");
480
+ ```
481
+
482
+ - Replace ` RXPIN ` and ` TXPIN ` with the GPIOs you want to assign.
483
+ - You can then use commands such as ` Serial1.write() ` and ` Serial1.read() ` .
484
+
485
+ The ` SERIAL_8N1 ` parameter is the configuration for serial communication.
486
+ - ` 8 ` = data word length (8-bit). Can be changed to 5,6,7-bits.
487
+ - ` N ` = parity, in this case "none". Can be changed to "even" (E) or "odd" (O).
488
+ - ` 1 ` = stop bit, other option available is 2.
489
+
464
490
## I2S
465
491
466
492
The Inter-IC Sound (I2S or IIS) protocol is used for connecting digital audio devices with a variety of configurations (Philips mode, PDM, ADC/DAC).
0 commit comments