8000 Update cheat-sheet.md · Avntkj/docs-content-arduino@c3b30c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3b30c9

Browse files
committed
Update cheat-sheet.md
1 parent 1836bec commit c3b30c9

File tree

1 file changed

+30
-4
lines changed
  • content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet

1 file changed

+30
-4
lines changed

content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,12 @@ void setup() {
412412

413413
## USB Serial & UART
414414

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.
416416

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.
419421

420422
### Native USB
421423

@@ -430,7 +432,7 @@ To send and receive data through UART, we will first need to set the baud rate i
430432

431433
### UART
432434

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:
434436

435437
| Pin | Function | Description |
436438
| --- | -------- | -------------------- |
@@ -461,6 +463,30 @@ And to write something, we can use the following command:
461463
Serial0.write("Hello world!");
462464
```
463465

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+
464490
## I2S
465491

466492
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

Comments
 (0)
0