Most weighbridge indicators send ASCII strings with a standard format. A typical output looks like:
ST,GS,001234kg
using System;
using System.IO.Ports;
class Program
{
static void Main()
{
SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
port.NewLine = "\r\n"; // many indicators use CRLF as line end
port.Open();
while (true)
{
try
{
string rawData = port.ReadLine().Trim();
Console.WriteLine("Raw: " + rawData);
// Example: ST,GS,001234kg → extract weight only
string[] parts = rawData.Split(',');
string weight = parts[parts.Length - 1]; // last part
Console.WriteLine("Weight: " + weight);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}
}