UART Connection problem

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Alexdd50
Posts: 6
Joined: Thu Jan 30, 2020 1:23 pm

UART Connection problem

Post by Alexdd50 » Thu Jan 30, 2020 1:33 pm

Hello,

I am currently trying to establish a serial connection between a e-paper and a ESP32-WROOM-32U on a ESP32_Devkitc_V4.
I connected cables to TX and RX pins on the ESP32 and created the following code :

Code: Select all

soc = UART(1)
soc.init(rate, timeout=5000, tx=1, rx=3)
...
soc.write(cmd) #cmd is a string
I put these pins (rx=3 and tx=1) because they are the only where I have an output.
Unfortunately, i get this in green in the console (i think it's a system output):

Code: Select all

I (8647) uart▒A500090ACC33C33Ca6
where "A500090ACC33C33Ca6" is the data I sent named 'cmd' in the python program.
After this, the program totally freezes and I have to reboot with the reset button ...
Anybody have an idea ?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART Connection problem

Post by Roberthh » Thu Jan 30, 2020 2:55 pm

Pin 1 and 3 are used by UART0 for the host connection. if you want to keep REPL, you cannot use them for another purpose.

Strik3r
Posts: 15
Joined: Thu Nov 28, 2019 7:36 pm
Location: Saratov, Russia

Re: UART Connection problem

Post by Strik3r » Thu Jan 30, 2020 5:14 pm

Alexdd50 wrote:
Thu Jan 30, 2020 1:33 pm
Anybody have an idea ?
uos.dupterm to disable repl on uart0.

Alexdd50
Posts: 6
Joined: Thu Jan 30, 2020 1:23 pm

Re: UART Connection problem

Post by Alexdd50 » Wed Feb 05, 2020 5:30 pm

Can I use any other pin than 1 and 3 to connect in UART ?
For example what is the difference between UART0, UART1 and UART2 that seems to use different ports.
I tried to use UART1 but the pins I found on the web are GPIO9 and GPIO10 but in the datasheet they are used by the system ..

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART Connection problem

Post by Roberthh » Thu Feb 06, 2020 6:52 am

You can use any Pin for UART rx and cts and any output-capable pin for UART tx and rts, as long as this pin is not use for other purposes. UART0, UART1 and UART2 are three different independent devices. UART0 is used by default for the REPL and is assigned to pins 1 and 3. But for connecting the E-Paper display you can use UART1 or UART2. The default pins of UART1 are 9 and 10, the default pins for UART2 are 16 and 17, which all are unlucky choice and must definitely by changed, as these pins are used for the flash or SPIRAM.

Alexdd50
Posts: 6
Joined: Thu Jan 30, 2020 1:23 pm

Re: UART Connection problem

Post by Alexdd50 » Thu Feb 06, 2020 12:51 pm

According to what you said, I tried to change connection pins, here's what my code looks like :

Code: Select all

uart = UART(1)
uart.init(115200, timeout=5000, tx=25, rx=26)
uart.write(cmd)
The cmd I sent is the update command of the E-Paper display, and the code works (no errors) but nothing happens and don't know where come from the problem .. The E-Paper is connected to pins 25 and 26 and for the power supply the pins 5V and GND, I checked on the datasheet of ESP32-WROOM-32U they are not used internally.
In addition, I tried uart.readline() to read if there was a response but the output was 'None'.
Do you have an idea what can I do to find where is the problem ?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART Connection problem

Post by Roberthh » Thu Feb 06, 2020 12:54 pm

Try to swap rx and tx. The labeling is sometimes not consistent.
You can test the ESP32 side by disconnecting the display and connecting rx and tx. Then you should be able to read back what you have written.

Alexdd50
Posts: 6
Joined: Thu Jan 30, 2020 1:23 pm

Re: UART Connection problem

Post by Alexdd50 » Thu Feb 06, 2020 1:26 pm

Ok I tried to connect rx to tx and the data is transmitted I can read what I sent, It's a good thing.

But when I put the cables of E-Paper in the same pins (I tried to swap them), the same problem is still here.
It's strange because when I plug the E-Paper in USB to my pc with a USB to TTL, I am able to communcate with the display

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART Connection problem

Post by Roberthh » Thu Feb 06, 2020 1:32 pm

If the display is using 5V logic, then the level may be too low. But maybe the message format is wrong. Does the display need a termination character in its commands, like newline or return?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART Connection problem

Post by Roberthh » Thu Feb 06, 2020 2:27 pm

But just to ask the obvious: did you connect GND too?

Post Reply