How to directly connect to RS232 comport?

Dear Expert,

I know the serial data can be transmitted to PC using the USB.
But I want to read the microbit data using RS232 (this is an experimental project).
this is because the transmission line will be quite long and the user intrface will have RS232 comport only.
Can someone help me please?

You can use a dedicated chip like the MAX3232 or a breakout board like the SparkFun RS232 Shifter - SMD to shift to TTL logic for your micro:but. (These are just the first things I saw when searching up “RS232” on Sparkfun, I do not have experience working with it)

Is it straight forward plug and play or some coding needed?

Unfortunately, I just checked the pinout of the micro:bit, and it doesn’t appear to break out the serial pins. (I wrongly assumed that the micro:bit would break them out like other development boards) I would have then suggested that you use a micro USB to RS232 adapter, but searching on Amazon, there doesn’t seem to be any. (without being “suspicious”)

@randangminang

It looks like it is possible to “redirect” the serial/UART ports to other pins (will no longer be sent over USB). It would just be the 0-3V logic of the micro:bit. If you want true RS-232, you’ll need an RS232 level shifter. I think there are a variety of modules you could utilize. You may want to check SparkFun or AdaFruit for examples.

As for redirecting the UART pins:

MakeCode

Use the “serial redirect to” block in the serial > ... more menu. Here’s an example project that shows the blocks: https://makecode.microbit.org/S87562-22548-22554-32824 .

MicroPython

Redirect in the uart.init()

from microbit import *

uart.init(115200, tx=pin0, rx=pin1)

# Code in a 'while True:' loop repeats forever
while True:
    uart.write('Hello, Serial')

Bill

1 Like