1.0.4 • Published 8 months ago
@kortoaus/cas-scale v1.0.4
@kortoaus/cas-scale
A lightweight TypeScript library for interfacing with CAS PD-II electronic weighing scales over RS-232 serial communication.
Automatically requests and parses weight data from the scale, using the serialport package under the hood.
✅ Tested and confirmed to work with CAS PD-II in ECR-TYPE 2 (STX/ETX protocol mode) only.
✨ Features
- ✅ Automatically sends weight request commands (
W) - ✅ Parses 7-byte responses from CAS PD-II scale
- ✅ Emits weight in kilograms via callback
- ✅ Works with Node.js & TypeScript
- ✅ Tiny, dependency-light wrapper
📦 Installation
npm install @kortoaus/cas-scale🚀 Usage
import { initializeScale } from "@kortoaus/cas-scale";
initializeScale("/dev/tty.usbserial-B002EF3X", (weight) => {
console.log("Weight:", weight, "kg");
});Optional error callback:
initializeScale(
"/dev/tty.usbserial-B002EF3X",
(weight) => {
console.log("Weight:", weight);
},
(err) => {
console.error("Scale error:", err);
}
);⚙️ Scale Setup Instructions
Ensure your CAS PD-II scale is configured as follows:
| Setting | Value |
|---|---|
| ECR Type | 2 |
| Baud Rate | 9600 |
| Data Bits | 7 |
| Parity | Even |
| Stop Bits | 1 |
To change ECR Type:
- Turn off the scale
- Hold
ZERO+TAREand power on to enter setup mode - Navigate to
Ecrsetting and set to2 - Use
TARE(long press) to save and proceed
🧪 Tested On
- CAS PD-II with firmware version supporting ECR-TYPE 2
- macOS + USB-to-Serial adapter (FTDI, CH340 confirmed)
- Node.js 18+
📝 License
MIT — © kortoaus