serial data reading with pico
-
- Posts: 9
- Joined: Tue Jul 19, 2022 4:33 pm
serial data reading with pico
.
Last edited by filip12241224 on Thu Sep 01, 2022 5:47 pm, edited 1 time in total.
Re: serial data reading with pico
Reading and writing serial data is done by the machine.UART class. See the documentation at https://docs.micropython.org/en/latest/ ... serial-bus.
To tell, whether the set-up is correct, you can do a loopback test.
You should read back the message you have written.
To tell, whether the set-up is correct, you can do a loopback test.
- Connect the max3232 level converter at the TTL side to the Pico, e.g. GPIO0 for TX (Pico out) and GPIO1 for RX (Pico in). Do not forget to connect the max232 GND with the PICO GND pin.
- Connect RX and TX at the rs232 side, e.g. with a jumper cable,
- Run in REPL:
Code: Select all
from machine import UART, Pin
uart = UART(0, tx=Pin(0), rx=Pin(1))
uart.write("test message")
print(uart.read())
-
- Posts: 9
- Joined: Tue Jul 19, 2022 4:33 pm
Re: serial data reading with pico
.
Last edited by filip12241224 on Thu Sep 01, 2022 5:47 pm, edited 1 time in total.
Re: serial data reading with pico
Try to swap the RX/TX at the PICO. The Pico TX must be connected with the Data in Pin of the max3232 TTL side, and PICO RX with max3232 out.
-
- Posts: 9
- Joined: Tue Jul 19, 2022 4:33 pm
Re: serial data reading with pico
.
Last edited by filip12241224 on Thu Sep 01, 2022 5:47 pm, edited 1 time in total.
Re: serial data reading with pico
Is the max3232 converter powered?
-
- Posts: 9
- Joined: Tue Jul 19, 2022 4:33 pm
Re: serial data reading with pico
.
Last edited by filip12241224 on Thu Sep 01, 2022 5:47 pm, edited 1 time in total.
Re: serial data reading with pico
Just to confirm: for the loopback test, you have to connect at the rs232 side rx and tx and no other connection to rx and tx at the rs232 side. RS232 GND does not matter.
Re: serial data reading with pico
The default baud rate for UART is 115200. If that is too high, you can set the baud rate as the second parameter, e.g.:
uart=UART(0, 9600, tx=Pin(0), rx=Pin(1))
uart=UART(0, 9600, tx=Pin(0), rx=Pin(1))
Re: serial data reading with pico
Yes. It is hard to tell from a distance what could be wrong.