Skip to content

Instantly share code, notes, and snippets.

@kost
Created January 28, 2020 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kost/a0c0154524d4b457ba81318f982c38c5 to your computer and use it in GitHub Desktop.
Save kost/a0c0154524d4b457ba81318f982c38c5 to your computer and use it in GitHub Desktop.
Serial Echo in MicroPython
from time import sleep_ms
from machine import UART
def serialecho():
print("serial echo server started")
uart = UART(2) # 16:RX 17:TX
uart.init(baudrate=115200, bits=8, parity=None, stop=1)
while True:
if uart.any():
x=uart.read()
print("Got", x)
uart.write(x)
sleep_ms(100)
serialecho()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment