Page 1 of 1

UART Connection problem

Posted: Thu Jan 30, 2020 1:33 pm
by Alexdd50
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 ?

Re: UART Connection problem

Posted: Thu Jan 30, 2020 2:55 pm
by Roberthh
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.

Re: UART Connection problem

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

Re: UART Connection problem

Posted: Wed Feb 05, 2020 5:30 pm
by Alexdd50
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 ..

Re: UART Connection problem

Posted: Thu Feb 06, 2020 6:52 am
by Roberthh
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.

Re: UART Connection problem

Posted: Thu Feb 06, 2020 12:51 pm
by Alexdd50
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 ?

Re: UART Connection problem

Posted: Thu Feb 06, 2020 12:54 pm
by Roberthh
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.

Re: UART Connection problem

Posted: Thu Feb 06, 2020 1:26 pm
by Alexdd50
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

Re: UART Connection problem

Posted: Thu Feb 06, 2020 1:32 pm
by Roberthh
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?

Re: UART Connection problem

Posted: Thu Feb 06, 2020 2:27 pm
by Roberthh
But just to ask the obvious: did you connect GND too?