From c3b30c9c0ebe607d8dc7b0ace1011fad39109438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:48:04 +0100 Subject: [PATCH 1/5] Update cheat-sheet.md --- .../tutorials/cheat-sheet/cheat-sheet.md | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md index eeb5e773b5..610e1680ad 100644 --- a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md @@ -412,10 +412,12 @@ void setup() { ## USB Serial & UART -The Nano ESP32 board features 2 separate hardware serial ports. +The Nano ESP32 board features 3 hardware serial ports, as well as a port exposed via the USB port. -One port is exposed via USB-C®, and -One is exposed via RX/TX pins. +- `Serial` refers to the USB port. +- `Serial0` refers to the hardware serial port (UART), accessible via the board's RX/TX pins (D0, D1) +- `Serial1` is the second UART port, which can be assigned to any free GPIO. +- `Serial2` is the third UART port, which can also be assigned to any free GPIO. ### Native USB @@ -430,7 +432,7 @@ To send and receive data through UART, we will first need to set the baud rate i ### UART -The pins used for UART on the Nano ESP32 are the following: +The default pins for UART communication on the Nano ESP32 are the following: | Pin | Function | Description | | --- | -------- | -------------------- | @@ -461,6 +463,30 @@ And to write something, we can use the following command: Serial0.write("Hello world!"); ``` +### Serial1 & Serial2 + +The Nano ESP32 features additional hardware serial ports, but these needs to be manually assigned. + +To use `Serial1` and `Serial2`, you need to initialize them in your program's `setup()` function: + +```arduino +//initialization +Serial1.begin(9600, SERIAL_8N1, RX1PIN, TX1PIN); +Serial2.begin(9600, SERIAL_8N1, RX2PIN, TX2PIN); + +//usage +Serial1.write("Hello world!"); +Serial2.write("Hello world!"); +``` + +- Replace `RXPIN` and `TXPIN` with the GPIOs you want to assign. +- You can then use commands such as `Serial1.write()` and `Serial1.read()`. + +The `SERIAL_8N1` parameter is the configuration for serial communication. +- `8` = data word length (8-bit). Can be changed to 5,6,7-bits. +- `N` = parity, in this case "none". Can be changed to "even" (E) or "odd" (O). +- `1` = stop bit, other option available is 2. + ## I2S 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). From 178b7a475c6368137ebefcc228e1357829f4c546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:50:05 +0100 Subject: [PATCH 2/5] Update cheat-sheet.md --- .../boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md index 610e1680ad..99ce528d84 100644 --- a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md @@ -412,7 +412,7 @@ void setup() { ## USB Serial & UART -The Nano ESP32 board features 3 hardware serial ports, as well as a port exposed via the USB port. +The Nano ESP32 board features 3 hardware serial ports, as well as a port exposed via USB. - `Serial` refers to the USB port. - `Serial0` refers to the hardware serial port (UART), accessible via the board's RX/TX pins (D0, D1) @@ -479,7 +479,7 @@ Serial1.write("Hello world!"); Serial2.write("Hello world!"); ``` -- Replace `RXPIN` and `TXPIN` with the GPIOs you want to assign. +- Replace `RXPIN` and `TXPIN` with the GPIOs you want to assign (e.g. `D4`, `D5`). - You can then use commands such as `Serial1.write()` and `Serial1.read()`. The `SERIAL_8N1` parameter is the configuration for serial communication. From 73c9889448e98e5863978bfb0f88aec072ea502e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:06:35 +0100 Subject: [PATCH 3/5] Update content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md Co-authored-by: Luca Burelli --- .../boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md index 99ce528d84..15f67864c8 100644 --- a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md @@ -415,9 +415,9 @@ void setup() { The Nano ESP32 board features 3 hardware serial ports, as well as a port exposed via USB. - `Serial` refers to the USB port. -- `Serial0` refers to the hardware serial port (UART), accessible via the board's RX/TX pins (D0, D1) -- `Serial1` is the second UART port, which can be assigned to any free GPIO. -- `Serial2` is the third UART port, which can also be assigned to any free GPIO. +- `Serial0` refers to the first hardware serial port (UART), accessible via the board's RX/TX pins (D0, D1). +- `Serial1` is the second UART port, which can be assigned to any free GPIOs. +- `Serial2` is the third UART port, which can also be assigned to any free GPIOs. ### Native USB From 0c458e7e14ee71aea98a65e5fd95f28a6435724c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:06:57 +0100 Subject: [PATCH 4/5] Update content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md Co-authored-by: Luca Burelli --- .../boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md index 15f67864c8..7dc5dacffb 100644 --- a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md @@ -465,7 +465,7 @@ Serial0.write("Hello world!"); ### Serial1 & Serial2 -The Nano ESP32 features additional hardware serial ports, but these needs to be manually assigned. +The Nano ESP32 features 2 additional hardware serial ports that have no pre-defined pins, and can be connected to any free GPIO. Therefore, to use them, their TX and RX pins need to be manually assigned. To use `Serial1` and `Serial2`, you need to initialize them in your program's `setup()` function: From 543c7fe6bd4c3b069bbe34150b2865d65c60b865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:24:49 +0100 Subject: [PATCH 5/5] Update cheat-sheet.md --- .../nano-esp32/tutorials/cheat-sheet/cheat-sheet.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md index 7dc5dacffb..8de5d8165d 100644 --- a/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md @@ -419,7 +419,7 @@ The Nano ESP32 board features 3 hardware serial ports, as well as a port exposed - `Serial1` is the second UART port, which can be assigned to any free GPIOs. - `Serial2` is the third UART port, which can also be assigned to any free GPIOs. -### Native USB +### Serial (Native USB) Sending serial data to your computer is done using the standard `Serial` object. @@ -430,7 +430,9 @@ Serial.print("hello world"); To send and receive data through UART, we will first need to set the baud rate inside `void setup()`. -### UART +### Serial0 (UART) + +***Please note: `Serial0` is shared with the bootloader/kernel, which prints a few messages at boot/reset, and in the event of a crash, the crash dumps is printed via FreeRTOS on this serial port. For these reasons, you may want to use the `Serial1` or `Serial2` ports to avoid any interference ([read more](#serial1--serial2-uart)).*** The default pins for UART communication on the Nano ESP32 are the following: @@ -463,7 +465,7 @@ And to write something, we can use the following command: Serial0.write("Hello world!"); ``` -### Serial1 & Serial2 +### Serial1 & Serial2 (UART) The Nano ESP32 features 2 additional hardware serial ports that have no pre-defined pins, and can be connected to any free GPIO. Therefore, to use them, their TX and RX pins need to be manually assigned.