Page 1 of 1
Not able to read the serial port using serial module of PC's python
Posted: Mon Mar 02, 2020 4:22 pm
by cvikash
Hello all,
I'm new to micropython and don't really understand a lot of things about micropython. I'm trying to write a string using UART(1,9600).write('abc') on serial port COM4 and read it at the PC's python using serial.read(). But when I try to read the data and print it, nothing happens, not even any error message pops up.
Here is the code from micropython and PC's python.

- fig1.PNG (6.15 KiB) Viewed 2840 times

- fig2.PNG (4.99 KiB) Viewed 2840 times
Re: Not able to read the serial port using serial module of PC's python
Posted: Mon Mar 02, 2020 10:16 pm
by jimmo
How is UART1 on the Pyboard connected to your PC? Do you have an additional FTDI cable or something? Or is COM4 the USB/UART that the REPL runs on?
What type of board are you using? Looks like STM32, but is it a pyboard or a ST dev kit or something else?
Re: Not able to read the serial port using serial module of PC's python
Posted: Tue Mar 03, 2020 8:40 am
by cvikash
Thank you for your reply! No, I don't have any additional cable. COM4 is the USB/UART that the REPL runs on.
Yes the board that I'm using is pyboard v1.1.
Re: Not able to read the serial port using serial module of PC's python
Posted: Tue Mar 03, 2020 9:45 am
by jimmo
UART (1) is a regular UART, i.e. not connected to the USB in any way. It's on pins X9 and X9.
If you want to write to the "virtual" UART that's made available by USB, then you need to use pyb.USB_VCP --
https://docs.micropython.org/en/latest/ ... B_VCP.html
Re: Not able to read the serial port using serial module of PC's python
Posted: Tue Mar 03, 2020 11:49 am
by cvikash
Thanks a lot Jimmo!

Virtual UART provided by USB is working fine.