Wanting to investigate a slightly Heath-Robinson idea to improve my CNC work setup process, I grabbed a digital dial guage (0-25.4mm) for probing things... The device had a cable option which I initially skipped, but the connector was a pain and rather than destroy my device to solder in a socket I bought the cable (for £1.99+tax).
It's supposedly 1.37volt logic, but the cable converts to RS232, and they included a USB-RS232 adapter. The device and cable came with 2x 8cm Compact-Discs (CDs) for software drivers and official software. I do actually still have a DVD/CD combo drive in one laptop, but forget about that. The instructions showed it in Chinese and windows only, and I plan to use a Raspberry Pi, so I went straight to an LLM to make a prototype web-serial demo.
Claude started the project, then I moved to claude-code in the hope claude would read the serial output too, but I/it got distracted with it nearly working for ages. In the end claude-code took it down an alley of insanity, and I switched to vscode in Agent mode to start afresh at the same time. VsCode sorted it right out first time. Then a quick correction for the initial boot messages received, and finally glam it up a bit along with adding scaling to the dial. Of course to use it with the Pi it would need converting to python/node, so I did that and tested via WSL.
Source Code / Readme etc:
https://github.com/tyeth/digital-dial-gauge-web-serial
Interactive Webpage:
https://tyeth.github.io/digital-dial-gauge-web-serial/
Live embedded iframe/oEmbed version:
So that's one less hurdle to getting my ultimate CNC setup going, along with some future shenanigans...
Keywords for future search ninjas:
Dial guage, guage, gauge, dial gauge, digital dial guage, digital dial gauge. Read gauge over serial at 9600
Readme from Project:
Digital Dial Gauge Serial Logger
This project provides scripts for reading and parsing digital dial gauge data from a serial port, in both Python and Node.js. It is useful for logging, automation, and integration with other tools.
There is also a web-serial version (no installation - only a Chrome based browser needed):
https://tyeth.github.io/digital-dial-gauge-web-serial/
Features
- Reads data from a digital dial gauge via serial port
- Parses and logs values in millimeters
- Supports reading a single value, multiple values, or continuous logging
- Timeout option to avoid waiting forever
- Usable as a CLI tool or as an importable module (Python and Node.js)
Python Usage
As a CLI tool
python3 serial-gauge-log.py /dev/ttyUSB0 --count 5 --timeout 3
-
--count N: Number of values to read before exiting (0 = infinite) -
--timeout SECONDS: Timeout in seconds (0 = no timeout)
Example output:
[RESULT] [(12.345, '12.345'), (12.346, '12.346'), ...]
As a module
from serial_gauge_log import get_gauge_values values = get_gauge_values('/dev/ttyUSB0', count=5, timeout=3) print(values)
Node.js Usage
As a CLI tool
node serial-gauge-log.js /dev/ttyUSB0 --count 5 --timeout 3
-
--count N: Number of values to read before exiting (0 = infinite) -
--timeout SECONDS: Timeout in seconds (0 = no timeout)
Example output:
[RESULT] [[12.345,"12.345"], [12.346,"12.346"], ...]
As a module
const { getGaugeValues } = require('./serial-gauge-log.js'); getGaugeValues({ portPath: '/dev/ttyUSB0', count: 5, timeout: 3 }).then(values => { console.log(values); });
Requirements
- Python 3 with
pyserial(pip install pyserial) - Node.js with
serialport(npm install serialport)
Notes
- Adjust
EXPECTED_DIGIT_LENGTHin the scripts if your gauge sends a different number of digits. - Both scripts log raw and parsed data for debugging.
- The scripts are designed for easy extension and integration.
License
MIT License
This page (Reading a Digital Dial Gauge using official usb serial cable (Web-serial, python, nodejs)) was last updated on May 18, 2025.
Text editor powered by tinymce.