Get started with MicroPython Exit MicroPython mode
Digi XBee3 Cellular LTE-M/NB-IoT Global Smart Modem User Guide
68
from machine import UART
import sys, time
def uart_init():
u = UART(1)
u.write('Testing from XBee\n')
return u
def uart_relay(u):
while True:
uart_data = u.read(-1)
if uart_data:
sys.stdout.buffer.write(uart_data)
stdin_data = sys.stdin.buffer.read(-1)
if stdin_data:
u.write(stdin_data)
time.sleep_ms(5)
u = uart_init()
uart_relay(u)
You only need to call uart_init() once.
Call uart_relay() to pass data between the UARTs.
Send Ctrl-C to exit relay mode.
When done, call u.close() to close the secondary UART.
Exit MicroPython mode
To exit MicroPython mode:
1.
In the XCTU MicroPython Terminal, click the green Close button .
2. Click Close at the bottom of the terminal to exit the terminal.
3.
In XCTU's Configuration working mode , change AP API Enable to another mode and click
the Write button . We recommend changing to Transparent mode [0], as most of the
examples use this mode.
Other terminal programs
If you do not use the MicroPython Terminal in XCTU, you can use other terminal programs to
communicate with the XBee Smart Modem. If you use Microsoft Windows, follow the instructions for
Tera Term, if you use Linux, follow the instructions for picocom. To download these programs:
n Tera Term for Windows; see https://ttssh2.osdn.jp/index.html.en.
n Picocom for Linux; see https://developer.ridgerun.com/wiki/index.php/Setting_up_Picocom_-_
Ubuntu and for the source code and in-depth information https://github.com/npat-
efault/picocom.