Simple serial port example using Python.

Published: 23 November 2019
on channel: guru brahmayya
7,188
39

Simple serial port hardware loop back programming using Python.
I have used COM4 (USB-Serial converter) and shorted TX(pin-2) and RX(pin-3).

Code:
import serial
from time import sleep

ser = serial.Serial(port='COM4',baudrate=9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=0)
print("connected to: " + ser.portstr)
ser.write("Hello World")
sleep(1)
a=ser.readline()
print(a)
ser.close()


On this page of the site you can watch the video online Simple serial port example using Python. with a duration of hours minute second in good quality, which was uploaded by the user guru brahmayya 23 November 2019, share the link with friends and acquaintances, this video has already been watched 7,188 times on youtube and it was liked by 39 viewers. Enjoy your viewing!