import serial import time ser = serial.Serial('COM5', 115200, timeout=0) s = 0 count = 0 while count < 100: if ser.in_waiting: s = ser.readline() print(s) time.sleep(0.1) count += 1