UARTS1 and 2 appear unusable [SOLVED]
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
UARTS1 and 2 appear unusable [SOLVED]
I have an Espressif ESP32-devkit C board with ESP-WROOM-32. One of the attractions of the ESP32 was the hope that at least one UART aside from that used for USB would be available for general use. This appears not to be the case.
The ESP32 has three UARTs U0, U1 and U2.
U0 is used by the USB interface.
U2 uses pins GPIO17 (txd) and GPIO16 (rxd). The use of these pins is deprecated in the ESP32 datasheet. Section 2.2 Note states "ESP32-D2WD’s pins GPIO16, GPIO17, SD_CMD, SD_CLK, SD_DATA_0 and SD_DATA_1 are used for connecting the embedded flash, and are not recommended for other uses."
U1 uses GPIO9 (rxd) and GPIO10 (txd). Alas GPIO9 has very odd characteristics. If you instantiate it as an input, it reads high. If you connect it to 0V the board reboots. If you instantiate it as an output the board reboots. If you instantiate U1 - you've guessed it - the board reboots. [EDIT] It only reboots if a loopback is installed. But this bodes ill for actually using it.
There is nothing on the board schematic to explain the behaviour of GPIO9 so I'm wondering if the MicroPython firmware is using this pin in some way. If so, it's an unfortunate choice of pin.
Any comments or experience of using the UARTs?
The ESP32 has three UARTs U0, U1 and U2.
U0 is used by the USB interface.
U2 uses pins GPIO17 (txd) and GPIO16 (rxd). The use of these pins is deprecated in the ESP32 datasheet. Section 2.2 Note states "ESP32-D2WD’s pins GPIO16, GPIO17, SD_CMD, SD_CLK, SD_DATA_0 and SD_DATA_1 are used for connecting the embedded flash, and are not recommended for other uses."
U1 uses GPIO9 (rxd) and GPIO10 (txd). Alas GPIO9 has very odd characteristics. If you instantiate it as an input, it reads high. If you connect it to 0V the board reboots. If you instantiate it as an output the board reboots. If you instantiate U1 - you've guessed it - the board reboots. [EDIT] It only reboots if a loopback is installed. But this bodes ill for actually using it.
There is nothing on the board schematic to explain the behaviour of GPIO9 so I'm wondering if the MicroPython firmware is using this pin in some way. If so, it's an unfortunate choice of pin.
Any comments or experience of using the UARTs?
Last edited by pythoncoder on Wed Sep 13, 2017 4:13 pm, edited 2 times in total.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: UARTS1 and 2 appear unusable.
On ESP32 UART signals can be routed to (almost) any pins using gpio matrix.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: UARTS1 and 2 appear unusable.
Ah, I hadn't appreciated that. Thanks. Is this functionality available in MicroPython?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: UARTS1 and 2 appear unusable.
Just set UART tx&rx pins, for testing connect some terminal emulator to the selected lines:
The limitation is that you can't use ESP32 input-only pins (34~39) as TX.
Code: Select all
>>> uart = machine.UART(1,baudrate=115200,tx=25,rx=26)
>>> uart
UART(1, baudrate=115200, bits=8, parity=None, stop=1, tx=25, rx=26, rts=-1, cts=-1, timeout=0, timeout_char=1)
>>> uart.write("MicroPython\n")
12
>>> uart.read()
b'Hi, MicroPython\r'
>>>
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: UARTS1 and 2 appear unusable.
Awesome - that works
A couple of queries to satisfy my curiosity. Does this ability to remap in Python apply to other peripherals such as I2C and SPI? And do you happen to know the reason for the strange behaviour of GPIO9?
A couple of queries to satisfy my curiosity. Does this ability to remap in Python apply to other peripherals such as I2C and SPI? And do you happen to know the reason for the strange behaviour of GPIO9?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: UARTS1 and 2 appear unusable.
Yes, I2C and SPI pins (I'm only using hw i2c&spi) can be selected from (almost) any GPIO.pythoncoder wrote:Awesome - that works
A couple of queries to satisfy my curiosity. Does this ability to remap in Python apply to other peripherals such as I2C and SPI? And do you happen to know the reason for the strange behaviour of GPIO9?
About GPIO9 issues, see this post from ESP32 forum and esp-idf documentation
Re: UARTS1 and 2 appear unusable.
[quote="loboris"][quote="pythoncoder"]Awesome - that works
A couple of queries to satisfy my curiosity. Does this ability to remap in Python apply to other peripherals such as I2C and SPI? And do you happen to know the reason for the strange behaviour of GPIO9?[/quote]
Yes, I2C and SPI pins (I'm only using hw i2c&spi) can be selected from (almost) any GPIO.
About GPIO9 issues, see [url=https://www.esp32.com/viewtopic.php?t=1457#p6602]this post[/url] from ESP32 forum and [url=http://esp-idf.readthedocs.io/en/latest ... /gpio.html]esp-idf documentation[/url][/quote]
hi!can use hardware SPI on esp32 board with micropython?how?
A couple of queries to satisfy my curiosity. Does this ability to remap in Python apply to other peripherals such as I2C and SPI? And do you happen to know the reason for the strange behaviour of GPIO9?[/quote]
Yes, I2C and SPI pins (I'm only using hw i2c&spi) can be selected from (almost) any GPIO.
About GPIO9 issues, see [url=https://www.esp32.com/viewtopic.php?t=1457#p6602]this post[/url] from ESP32 forum and [url=http://esp-idf.readthedocs.io/en/latest ... /gpio.html]esp-idf documentation[/url][/quote]
hi!can use hardware SPI on esp32 board with micropython?how?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: UARTS1 and 2 appear unusable [SOLVED]
It seems the ESP32 chip and the ESP-WROOM-32 module reserve different pins for Flash:
6, 7, 8, 9, 10, 11 : ESP-WROOM-32 http://espressif.com/sites/default/file ... eet_en.pdf
6,7,8,15,16,17 : ESP32 https://www.espressif.com/sites/default ... eet_en.pdf
6, 7, 8, 9, 10, 11 : ESP-WROOM-32 http://espressif.com/sites/default/file ... eet_en.pdf
6,7,8,15,16,17 : ESP32 https://www.espressif.com/sites/default ... eet_en.pdf
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: UARTS1 and 2 appear unusable [SOLVED]
ESP32-D2WD is the chip with embedded 2MB flash and the internal flash is connected to different pins (GPIO16, GPIO17, SD_CMD, SD_CLK, SD_DATA_0 and SD_DATA_1 ).
If SPIRAM (external SPI RAM, usually 4MB) is included in the design (like on ESP32-WROVER module) , GPIO16 & GPIO17 are additionaly used as SPIRAM CS&CLK and are not available to the user.
If SPIRAM (external SPI RAM, usually 4MB) is included in the design (like on ESP32-WROVER module) , GPIO16 & GPIO17 are additionaly used as SPIRAM CS&CLK and are not available to the user.