Skip to content

Instantly share code, notes, and snippets.

@rdandy
Last active February 16, 2022 03:50
Show Gist options
  • Save rdandy/569532629e4d8477e4f9387b985e95a4 to your computer and use it in GitHub Desktop.
Save rdandy/569532629e4d8477e4f9387b985e95a4 to your computer and use it in GitHub Desktop.
# serial_read.py
import serial, time
SERIALPORT = "/dev/ttyS0"
ser = serial.Serial(SERIALPORT, baudrate=115200, bytesize=8, parity="N", stopbits=1, rtscts=False, xonxoff=False)
def read_data():
while True:
if ser.in_waiting:
print (ser.read())
else:
pass
time.sleep(0.3)
if __name__ == '__main__':
print(ser)
print("read data")
read_data()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment