This code example is from Digi Micropython Programming Quide: Section How To Use The Primary UART.
Question: What is secondary UART?
I do not get this example code to working on Xbee Cellular 3G device properly. I have ATAP=4. If I put line print('READ') the the READ goes to uart, but if I use line u.write('Testing from XBee\n'), nothing happens? Can anyone please give me the working code for this?
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)
Regards
a.u.jentze