Difference: SerialPorts (1 vs. 2)

Revision 22020-10-12 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Using a second Serial Port

On the ESP32 UART0 is normally reserved for interactive use with REPL. Sometimes we need a UART to communicate with external devices. Typical examples are:

  • fingerprint readers using a serial communication protocol
  • GPS modules
Changed:
<
<
The ESP32 has 3 UARTs of which however UART1 is reserved for use with flash memory. However UART2 is free.
>
>
The ESP32 has 3 UARTs of which however UART1 is reserved for use with flash memory. However, UART2 is free.
Normally Rx is connected to GPIO 16 and Tx to GPIO 17 but these are forbidden on the CPU card we use (see The hardware). It is possible however to remap these signals to different GPIO pins, in our case to GPIO 21 and 22.
  Connect the USB to Serial adapter to the ESP32 as shown in the table below

USB to Serial Adapter ESP32 pins
Changed:
<
<
Rx GPIO 17
Tx GPIO 16
>
>
Rx GPIO 21
Tx GPIO 22
 
Gnd Gnd
Changed:
<
<
As a first quick test we can try to write "Hello World to UART2 to which we connect a minicom virtual terminal.
>
>
As a first quick test, we can try to write "Hello World to UART2 to which we connect a minicom virtual terminal.
  thonny is connected to UART0 on /dev/ttvUSB0 (connect this first). minicom is connected to UART2 on /dev/ttyUSB1. Start minicom with:
Line: 21 to 21
  Here is the screen dump of the REPL session
Changed:
<
<
uart2.png
>
>
uart2-v2.png
  And this is what we see on minicom:
Line: 36 to 36
 
<--/commentPlugin-->
Changed:
<
<
META FILEATTACHMENT attachment="uart2.png" attr="" comment="" date="1589054224" name="uart2.png" path="uart2.png" size="24122" user="UliRaich" version="1"
>
>
META FILEATTACHMENT attachment="uart2.png" attr="" comment="" date="1602517258" name="uart2.png" path="uart2.png" size="27555" user="UliRaich" version="2"
 
META FILEATTACHMENT attachment="uart2-minicom.png" attr="" comment="" date="1589054224" name="uart2-minicom.png" path="uart2-minicom.png" size="24288" user="UliRaich" version="1"
META FILEATTACHMENT attachment="uart.py.txt" attr="" comment="" date="1589054504" name="uart.py.txt" path="uart.py.txt" size="237" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="uart2-v2.png" attr="" comment="" date="1602517346" name="uart2-v2.png" path="uart2-v2.png" size="27555" user="UliRaich" version="1"

Revision 12020-05-09 - UliRaich

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

Using a second Serial Port

On the ESP32 UART0 is normally reserved for interactive use with REPL. Sometimes we need a UART to communicate with external devices. Typical examples are:

  • fingerprint readers using a serial communication protocol
  • GPS modules
The ESP32 has 3 UARTs of which however UART1 is reserved for use with flash memory. However UART2 is free.

Connect the USB to Serial adapter to the ESP32 as shown in the table below

USB to Serial Adapter ESP32 pins
Rx GPIO 17
Tx GPIO 16
Gnd Gnd
As a first quick test we can try to write "Hello World to UART2 to which we connect a minicom virtual terminal.

thonny is connected to UART0 on /dev/ttvUSB0 (connect this first). minicom is connected to UART2 on /dev/ttyUSB1. Start minicom with:

minicom -D /dev/ttyUSB1

Here is the screen dump of the REPL session

uart2.png

And this is what we see on minicom:

uart2-minicom.png

... if you are too lazy to type, here is the corresponding script:

https://iotworkshop.africa/pub/IoT_Course_English/SerialPorts/uart.py.txt

-- Uli Raich - 2020-05-09

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="uart2.png" attr="" comment="" date="1589054224" name="uart2.png" path="uart2.png" size="24122" user="UliRaich" version="1"
META FILEATTACHMENT attachment="uart2-minicom.png" attr="" comment="" date="1589054224" name="uart2-minicom.png" path="uart2-minicom.png" size="24288" user="UliRaich" version="1"
META FILEATTACHMENT attachment="uart.py.txt" attr="" comment="" date="1589054504" name="uart.py.txt" path="uart.py.txt" size="237" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback