Motivation – The Arduino IDE can only be used to monitor a single port. Arduino IDE does not allow multiple serial ports to be monitored simultaneously. Serial library can be used to read, write and print to different serial ports. Therefore, different ports can be monitored simultaneously from the terminal. This will be helpful when multiple microcontrollers are connected to the same laptop

Run the following command to install the serial library –

pip install pyserial 

Code –

Copy the code and store it in a file named ‘’

import serial 
import argparse

def print_serial(name):
        serial_port = serial.Serial(name,115200)
        print(f"The Port name is {}")
        while True:
            lines = serial_port.readline()
        print("check port")

ap = argparse.ArgumentParser()
ap.add_argument("-p","--port",required = True, help = "Enter Port Name")
args = vars(ap.parse_args())

PORT = args['port']


Usage – Run the following command from the terminal.

python -p [PORT NAME] 

Next Post Previous Post