RS485 Modbus RTU relay board with PowerShell

Serial comunication with a 4 Channel RS485 Modbus RTU relay board via a universal USB – RS485 dongle using PowerShell.

Relevant links:

Write-Host "Available ports:" ([System.IO.Ports.SerialPort]::getportnames());

$COM = "COM4";
$SLAVE_ID = 0x03;

# Append 2 byte MODBUS-16 CRC to binary data array
function CRC([byte[]] $data) 

function RelayChannel([int] $ch) 

# Switch to channel 3
RelayChannel 3

 Last update 2019-03-13 17:06