I'm not exactly sure what's happening here or if this is an issue with the rp2040 (I have some ESP modules I can test on?)
Code: Select all
from machine import Pin, UART
import uasyncio
uart = UART(0, 9600, parity=None, stop=1, bits=8, rx=Pin(13), tx=Pin(12))
async def sender():
swriter = uasyncio.StreamWriter(uart, {})
while True:
await swriter.awrite('Hello uart\n')
await uasyncio.sleep(2)
async def receiver():
sreader = uasyncio.StreamReader(uart)
while True:
res = await sreader.readline()
print('Recieved', res)
loop = uasyncio.get_event_loop()
loop.create_task(sender())
loop.create_task(receiver())
loop.run_forever()