Skip to content

About

Desktop app that streams several lab balances at once over RS-232/USB, charts live flow rates, and exports runs to Excel.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

90 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Balance Streamer

CI

A desktop app that reads several laboratory balances at once over RS-232/USB, turns the mass readings into a live flow rate, and saves each run to Excel.

Balance Streamer recording a run: mass and flow rate on one chart, with the readings table below

Screenshot made with simulated data: a pump running at 0.25 g/min, stepped up to 0.5 g/min at 25 minutes.

Why

When a pump feeds a column, the easiest honest measure of flow is the mass of liquid that comes out. Balance Streamer logs that mass every second (or at any interval you choose) from one or more balances, and shows the flow rate as it happens, so you can see a pump drift or a column clog while the run is still going. It was built for column experiments in a polymer engineering lab.

Features

  • Several balances at once: one tab per balance, each with its own connection, chart and settings.
  • Live flow rate: mass and flow rate (g/min) on one chart, plus a table of every reading.
  • Choice of smoothing: a Savitzky-Golay derivative, then Mean, Median, EMA, Butterworth, or an Adaptive filter that matches its window to your peristaltic pump's speed and roller count.
  • Excel export: one .xlsx per run with a Documentation sheet (balance, port, notes, your metadata), a Data sheet and a chart. File names come from a template built from tokens, for example <Start Date> <Start Time> Flow rate <Material>, where <Material> is a token you add yourself.
  • Auto-save and auto-stop: save every few minutes, or stop and save when the flow drops below a threshold for a set time. Quick Save overwrites the last file without asking.
  • Crash protection: every reading is also written to a backup CSV straight away. If the computer crashes or loses power, Recover Session brings the run back. Backups older than 30 days are deleted.
  • Balance guides: Settings → Balance Guides shows, for each brand, how to set the balance up for the app, calibrate it and read its error codes, plus fixes for common connection problems.
  • Tare, linear fit and pump calibration from the side panels.
  • Dark or light theme, and panels you can collapse and reorder.
  • Always know your version: the bottom-right corner shows the version. When a newer release is out it turns orange ("out of date") with an Update to … link.
  • One-click updates: the app checks GitHub when it starts (you can turn this off), and Check for Updates installs the newest release and restarts.
  • Desktop icon: the first time it starts on a computer, the app offers to put a Balance Streamer icon on the desktop, and it refreshes that icon after every update. No terminal window opens.
  • One copy at a time: opening the app again brings the open window to the front, instead of starting a second copy that would fight over the same balances.
  • Error log and diagnostics: problems are written to a log in the data folder (one folder per computer) instead of being skipped silently. Open Log Folder and Copy Diagnostics (Settings → Application Settings → Troubleshooting) make a bug report one paste.

Supported balances

Balance How it reads Set the balance to
Mettler Toledo Asks for a reading (MT-SICS SI) 9600 baud, host mode
Ohaus Adventurer Asks for a reading (IP) 9600 baud, 8 data bits, 1 stop bit, Stable off
Bonvoisin Listens to continuous output 9600 baud, output mode 3 (continuous), zero tracking off
Lachoi Listens to continuous output 9600 baud (C3-4), continuous output (C5-0)

All connections use 9600 baud, 8 data bits, no parity, 1 stop bit. Other balances that print a number and a unit on each line usually work with the Bonvoisin or Lachoi setting. Settings → Balance Guides has a page for each brand: the menu steps to set it up, how to calibrate it, its error codes, the right cable, and a "Start here" page for common problems (port missing, no readings, jumpy readings, flow rate too low at slow flows).

Install

Easiest: download the code (step 1 below), then double-click Launch_Windows.bat (Windows) or Launch_Mac.command (macOS). The first time, it sets itself up: it creates the .venv folder and installs everything the app needs (this takes a minute or two), then starts the app. After that it just starts the app. Setup_Windows.bat and Setup_Mac.command are for repairs: run one if the app says its packages are missing or broken. The manual steps follow.

You need Python 3.11 or newer (python.org) and a USB or RS-232 cable for each balance.

  1. Download the code: Code → Download ZIP on GitHub, or

    git clone https://github.com/brandonbtm29/Balance-Streamer-GUI.git
    cd Balance-Streamer-GUI
  2. Create a virtual environment and install:

    Windows

    python -m venv .venv
    .venv\Scripts\python -m pip install -r requirements.txt

    macOS

    python3 -m venv .venv
    .venv/bin/python -m pip install -r requirements.txt
  3. Start it, with no terminal window:

    • Windows: double-click Launch_Windows.bat.
    • macOS: double-click Launch_Mac.command (its Terminal window closes once the app has started), or Balance Streamer.app in the app's folder.
  4. The first time, the app asks whether to put a Balance Streamer icon on your desktop. Say yes, and from then on start it from there. (On a Mac you can also drag the desktop app to the Dock.) You can make the icon later with Settings → Application Settings → Create Desktop Shortcut.

If the app doesn't open, the launcher or a message box says why, and the details are written to the log in the data folder (see Where files go). Troubleshoot_Windows.bat and Troubleshoot_Mac.command run the app with its messages visible in a console window, which helps when asking for help. Once the app is open, Settings → Application Settings → Troubleshooting → Copy Diagnostics copies the version, your system, where the app keeps its files, your balances and ports, and the end of the log, ready to paste into a GitHub issue or an email. Open Log Folder next to it shows the log files. If macOS says Balance Streamer.app or a .command file "can't be opened" (this can happen with a ZIP download), right-click it and choose Open once.

If your computer doesn't list the balance's port, install the driver for your USB-serial adapter (for example FTDI).

Updating

When the app starts it asks GitHub whether a newer release is out. If there is one, the version in the bottom-right corner turns orange and says out of date; click Update to … (or press Check for Updates in Settings → Application Settings). Update and Restart saves your tabs, downloads it, reinstalls the requirements and restarts. A recording in progress stops; its data stays in the backup file for Recover Session. Your desktop icon is refreshed automatically the next time the app starts. To stop the check at startup, untick Check for updates when the app starts.

This works when the app was installed with git clone (step 1 above) and needs git on the computer. It only moves to published releases, never to unfinished work, and it won't overwrite files you changed in the app's folder. If installing the new requirements fails, the app goes back to the version you had. Copies downloaded as a ZIP, and standalone builds, show a link to the release page instead.

Version 1.0.0 has no update button: update it once by running git pull in the app's folder, then pip install -r requirements.txt with the virtual environment's Python.

Using it

  1. Plug in the balance and set it up as in the table above.
  2. In the balance tab, pick the Balance Brand and COM Port (Refresh Ports if it's missing), then Connect. Each computer remembers the port it used for each balance, so the same tab can be COM12 on Windows and /dev/cu.usbserial-… on a Mac. If a balance's port isn't on this computer, the tab says so and waits for you to pick one; it never connects to another port by itself. Two tabs can't use the same port.
  3. Press ▶ to start recording. Press it again to stop.
  4. Press the Excel button to save, or set up Auto-Save Settings so it saves for you.
  5. Add a tab for each extra balance with Tab Management → Add Tab.

The buttons across the top of each balance tab, left to right (hover over one to see its name):

Button What it does
Start / Stop Recording Start or stop logging readings
Clear Data Clear the readings in this tab and start a new run (asks first if they aren't saved to Excel)
Save to Excel Save the run to Excel (asks where)
Quick Save Overwrite the last saved file without asking
Tare Balance Send a tare command (T) to the balance
Save Graph PNG Save the chart as an image
Recover Session Restore a run from the backup files

Where files go

The app keeps its code and its data apart:

  • Data folder: ~/SyncThing/Balance Streamer Application/ by default. The app works inside this folder, so exports land in Data/ and backups in Data Backups/. Set the UAKRON_APP_DATA_DIR environment variable to use another folder (or UAKRON_DATA_DIR to move the parent folder).
  • Settings (config.json): in the app's own folder by default. In Settings → Application Settings → Settings Folder you can move them, for example into the data folder so several computers share them. UAKRON_SETTINGS_DIR overrides this.
  • Window size, position, dividers and each balance's port: kept per computer in window_state.json in the app's own folder (gitignored). They never move to the settings folder, because each computer has its own screens and port names.
  • Log: logs/<computer name>/balance_streamer.log in the data folder (three files of up to 1 MB are kept). Each computer has its own folder, so SyncThing never has two computers writing the same file. Errors at start-up go there too, and a hard crash (in a driver or in Qt) leaves balance_streamer.fatal.log next to it. On Windows that file sometimes also gets a report for an error Windows handled itself (for example code 0x8001010d); if a later line says exited normally, the app didn't crash. If the data folder can't be written to, the logs go to %LOCALAPPDATA%\Balance Streamer\logs (Windows) or ~/Library/Logs/Balance Streamer (Mac). Open Log Folder in Settings → Application Settings → Troubleshooting opens the right folder. If config.json can't be read, it is kept as config.json.unreadable and the app starts with default settings.

Neither data nor settings are ever stored in the repository; both are in .gitignore.

Build a standalone app

python build_app.py

This installs PyInstaller (the everyday install doesn't include it) and uses it to make dist/Balance_Streamer/, which runs without Python installed. Build on the system you want to run it on (Windows for an .exe, macOS for a Mac app).

Good to know

  • The flow rate assumes the liquid is collected on the balance. It is reported in g/min; convert to mL/min with your liquid's density.
  • A balance tab only records while you press ▶. Being connected isn't enough.
  • Closing a tab forgets its saved connection settings.
  • Closing the window while a balance is recording, or has readings not saved to Excel, asks first. If you close anyway, the readings stay in the backup file and Recover Session brings them back.
  • Readings are timed when they arrive from the balance, so a busy window can't shift their times.
  • The app only goes online to ask GitHub for the latest release: at startup (unless you turn that off) and when you press Check for Updates.

Development

python -m pip install -e ".[dev]"
pytest              # headless Qt tests: parsers, flow rates, ports, export, errors, updater
ruff check .
ruff format .
python -m balance_streamer   # run from source

The code is in the balance_streamer package:

Module What's in it
app.py main(): starts the log, moves into the data folder, makes sure only one copy runs, sets up the theme, opens the window
paths.py Where data and settings live
main_window.py The window: a Settings tab plus one tab per balance
balance_tab.py One balance tab (layout, connection, recording, chart and table)
flow.py, export.py, recovery.py, tab_config.py The balance tab's flow maths, saving, crash recovery and saved tab settings
serial_worker.py, parsers.py Reading a balance in a background thread and decoding its lines
settings_tab.py, widgets.py The Settings tab and small shared widgets
guides.py Settings → Balance Guides: set-up, calibration and troubleshooting for each brand
updater.py, update_panel.py Checking GitHub and updating a git copy
shortcut.py, shortcut_panel.py Desktop icon: create it, offer it on first start, refresh it after updates
diagnostics_panel.py The Troubleshooting box: Open Log Folder and Copy Diagnostics
theme.py, logs.py Dark/light theme and the error log

multi_balance_stream.py only starts the app; it stays for the launchers and build_app.py. settings_location.py (settings folder), crash_log.py (log file and error handling), single_instance.py (one copy at a time) and diagnostics.py (Copy Diagnostics) are shared, unchanged, with the other UAkron lab apps.

The tests point the app at a temporary data folder, so they never touch your real data. CI runs them on Windows, macOS and Linux with Python 3.11 to 3.13, and scans the history for secrets.

The version number lives in one place: __version__ in balance_streamer/__init__.py. Changes are listed in CHANGELOG.md. Updates find new versions through GitHub releases, so each release needs an vX.Y.Z tag and a published release.

How this was built

Balance Streamer is written and maintained by Brandon T. McReynolds with the help of AI coding assistants. Earlier versions (before October 10, 2026) were co-developed with Google Gemini in Antigravity. Later versions were co-developed with Claude (Anthropic); those commits list Claude as a co-author. Brandon directs the work, reviews and tests the changes, and is responsible for the project.

License

MIT

About

Desktop app that streams several lab balances at once over RS-232/USB, charts live flow rates, and exports runs to Excel.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages