I have done this on Challenger LTE board link, which is RP2040 based.
You need to enable data serial at boot (boot.py
), this is disabled by default. When the board boots you need to run file serial_passthrough.py
the program.
Your computer will report new COM/Serial port. Use that to talk with the device connected to uart
of the CircuitPython board.
file: boot.py
import usb_cdc
usb_cdc.enable(console=True, data=True)
Next creat serial_passthrough.py
file.
file: serial_passthrough.py
import board
import usb_cdc
uart = board.UART()
usb = usb_cdc.data
while True:
if uart.in_waiting:
data = uart.read(uart.in_waiting)
usb.write(data)
if usb.in_waiting:
data = usb.read(usb.in_waiting)
uart.write(data)
If you want to talk with Ublox Sara-R410M module as I would like to.
serial_passthrough_sara.py
would be like this:
file: serial_passthrough_sara.py
import board
import busio
import digitalio
import usb_cdc
import time
uart = busio.UART(tx=board.SARA_TX, rx=board.SARA_RX, rts=board.SARA_RTS, cts=board.SARA_CTS, baudrate=115200, timeout=0.25)
usb = usb_cdc.data
# SARA LDO enable control signal
sara_pwr = digitalio.DigitalInOut(board.SARA_PWR)
sara_pwr.direction = digitalio.Direction.OUTPUT
# Make sure the modem is fully restarted
sara_pwr.value = 0
time.sleep(1)
sara_pwr.value = 1
# Power on button
sara_btn = digitalio.DigitalInOut(board.SARA_BTN)
sara_btn.direction = digitalio.Direction.INPUT
sara_btn.pull = digitalio.Pull.UP
# Reset pin
sara_rst = digitalio.DigitalInOut(board.SARA_RST)
sara_rst.direction = digitalio.Direction.INPUT
sara_rst.pull = digitalio.Pull.UP
# Perform a SARA power on sequence
print ("Powering the SARA modem on.")
sara_btn.direction = digitalio.Direction.OUTPUT
sara_btn.value = 0
time.sleep(0.15)
sara_btn.direction = digitalio.Direction.INPUT
sara_btn.pull = digitalio.Pull.UP
# A short delay is required here to allow the modem to startup
time.sleep(1)
print ("Reset done, waiting for modem to start.")
while True:
if uart.in_waiting:
data = uart.read(uart.in_waiting)
usb.write(data)
if usb.in_waiting:
data = usb.read(usb.in_waiting)
uart.write(data)