Simplify Weighing Scale Integration in .NET Applications
WeighingMachineConnector.NET is a C# class library that simplifies communication between your .NET applications and RS232-based weighing machines. If you are building manufacturing systems, warehouse management, or retail POS software that needs to read from serial-enabled scales, this library handles the connection and data extraction.
What is it?
This library provides a clean and extensible abstraction for reading weights from electronic weighing scales that communicate over RS232 serial ports. It handles the connection, data reading, and parsing logic so that you can focus on business logic instead of low-level serial communication.
Purpose
Most digital weighing machines send weight data in raw or formatted byte streams through serial ports. Manually handling this requires byte-level parsing, port configuration, and handling different protocols per device brand — which is repetitive and error-prone.
WeighingMachineConnector.NET was built to standardize and simplify this process for developers.
Key advantages
- Plug-and-Play: Just specify COM port and baud rate to start receiving weight data.
- Asynchronous Operation: Event-driven architecture using .NET events and delegates.
- Custom Parsers: Built-in support for common weighing scale formats + easy extensibility.
- Cross-Version Compatibility: Works with both .NET Framework and .NET Core/.NET 6+.
- Device-Agnostic: Design supports different machines with minimal customization.
Supported devices
The library supports most weighing machines that:
- Use RS232 Serial communication
- Transmit ASCII or byte-encoded data for weight output
- Support configurable baud rate and parity settings
Examples include industrial/commercial weighing machines from brands like:
- A&D Weighing
- Mettler Toledo
- Citizen
- Radwag
- KERN
- And many more RS232-compatible models
How to use it
Here's a step-by-step example to connect and receive weight data using the library:
// Import the library
using WeighingMachineConnector;
class Program
{
static void Main(string[] args)
{
// Initialize the weighing machine connection
var machine = new WeighingMachine("COM3", 9600);
// Subscribe to the WeightReceived event
machine.WeightReceived += (sender, weight) =>
{
Console.WriteLine(quot;Weight received: {weight} kg");
};
// Start listening for data
machine.Start();
Console.WriteLine("Listening for weight data... Press Enter to exit.");
Console.ReadLine();
// Stop the connection when done
machine.Stop();
}
}
Note: Ensure that the COM port and baud rate match the settings of your weighing machine.
Want to add a new device?
If your machine sends weight data in a custom format, you can easily support it by:
- Creating a custom parser class that implements
IWeightDataParser
- Registering it in your application when initializing
WeighingMachine
Example:
public class MyDeviceParser : IWeightDataParser
{
public double? Parse(byte[] buffer)
{
// Custom logic to convert raw bytes to a readable weight
}
}
Usage:
var machine = new WeighingMachine("COM3", 9600, new MyDeviceParser());
machine.WeightReceived += (s, weight) => Console.WriteLine(quot;Weight: {weight}");
machine.Start();
Installation
- Clone the GitHub repository:
git clone https://github.com/encryptedtouhid/WeighingMachineConnector.NET
- Add the project or compiled DLL to your solution.
- Connect your weighing scale to the computer's COM port.
- Initialize and start the machine listener as shown above.
Use cases
- Factory Automation Systems
- Retail POS Terminals with integrated weight support
- Logistics, packaging, and inventory control
- Laboratory measurement systems
Contributions and support
The project is open source and available on GitHub. Pull requests, issue reports, and custom parser contributions are welcome!
Visit: https://github.com/encryptedtouhid/WeighingMachineConnector.NET