The Headache: Dirty ASCII Strings Recently, I had to pull live weight data from a dozen legacy KeLi floor scales and Shimadzu analytical balances into a centralized Node-RED/SCADA dashboard.

The problem? They communicate over RS232 and spit out proprietary, unstructured ASCII strings. A standard transparent serial-to-ethernet server doesn't work here because the SCADA system expects clean Modbus TCP registers, not raw text with carriage returns.

If you hook up a serial sniffer, this is what these scales actually output:

  • KeLi Floor Scale (350 kg): 02 20 20 20 20 20 20 33 35 30 20 20 20 33 35 30 0d
  • Shimadzu Balance (-3.516 g): 20 20 20 2D 33 2E 35 31 36 20 20 47 53 0D 0A

Writing a custom Python script or Node-RED function node to parse these varying lengths, handle the negative signs, and strip the zero-offsets (50mg base) for 12 different scales was going to be a nightmare to maintain.

The Hardware Hack: Edge P

arsing Instead of handling the protocol conversion on the server side, I decided to offload it to the edge hardware. I used a Valtoris programmable Modbus gateway designed specifically for this kind of serial translation.

Here is how I set up the flow:

1. Wiring Standard RS232 cross-over. Scale TX to Gateway RX, Scale RX to Gateway TX, and common GND. Note: I specifically used the optically isolated version of the gateway (1500V) because these scales sit next to high-voltage conveyor motors, and ground loops were frying my previous cheap adapters.

2. Gateway Configuration Instead of setting the gateway to "Transparent Mode", I logged into its web UI and configured the string parser:

  • Baud Rate: 9600, 8, N, 1
  • Parsing Rule: Strip all non-numeric characters (CR, LF, spaces).
  • Math Logic (for the Shimadzu): Applied a linear transformation (value - offset) / scale directly in the gateway memory to handle the negative tare weights.
  • Output: Pushed the final clean integer to Modbus Holding Register 40001.

3. The Result
Now, instead of listening for messy ASCII strings, my SCADA simply polls the gateway's IP address on port 502 and reads register 40001 like a standard PLC.

Turned a two-week software integration headache into a 30-minute hardware setup. If anyone else is stuck integrating old logistics scales into a modern IoT stack, definitely look into doing the parsing at the gateway level. I'll drop the specific config files for the KeLi scales in the files section below.