Serial Port Communication With Powershell

Serial Port Communication With Powershell


In this short post, I’ll show you how to read and write to/from the serial port using Powershell.

Let’s see how to do it in the script example below.

#Returns a list of all the currently available serial ports.

#Creates a new COM port object for COM5 with a baud rate of 9600.
$port = new-Object System.IO.Ports.SerialPort COM5,9600,None,8,one 

#Open the connection.

$port.WriteLine("some string") #Sends string.
$port.ReadLine()               #Receives string.

#Close the connection when done.

Leave a Reply

Your email address will not be published. Required fields are marked *

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger