FastAPI supervisor, Arduino Mega firmware, browser UI, and ORCA analysis tools for the HFE recirculation/cooling system.
firmware/: PlatformIO project for the Arduino Mega controller.supervisor/: FastAPI serial bridge, command API, WebSocket telemetry, and server-side logging.clients/web/: static browser UI served by the supervisor at/ui.analysis/: installable ORCA analysis package, notebooks, diagrams, and analysis documents.config/config.yaml: local serial, server, logging, and flow-meter unit configuration.data/raw/: runtime logger output; ignored by git.data/processed/: curated/generated analysis outputs that are tracked when useful.scripts/: project helper scripts for supervisor startup and focused maintenance tasks.
- (Optional) Activate the PlatformIO environment for firmware work:
source /home/pocar-lab/platformio-venv/bin/activate - Create a Python virtual environment for the supervisor + tooling:
python3 -m venv .venv && source .venv/bin/activate - Install Python dependencies:
pip install -e .[analysis,notebooks] - Install the analysis helpers for notebooks/CLI:
pip install -e analysis
- Upload the main controller firmware:
platformio run -d firmware -e megaatmega2560 -t upload firmware/platformio.inipins the main upload/monitor port to the Arduino-by-id path; update it if the board changes.- The controller uses MAX31856 thermocouple readers with per-channel type setup in
firmware/src/main.cpp. Installed loop probes are Type T, while the HX probes on U8 and U9 are Type K. - U8 is the colder HX channel and is logged as
THM_C; U9 is logged asTHI_C.
First-time connection (or new Arduino):
- Plug the Arduino in via USB.
- Find the serial port (Linux:
ls /dev/ttyACM* /dev/ttyUSB*) and setserial.portinconfig/config.yaml. - Start the supervisor (this uploads firmware by default):
bash scripts/start_supervisor.sh - Confirm the serial link in
logs/supervisor.log(look forSerial connected:). If you seeSerial unavailable, fix the port and restart the supervisor.
After a computer reboot/reset or after unplugging/replugging the Arduino:
- Verify the Arduino is connected and the port name in
config/config.yamlis still correct. - Restart the supervisor to reconnect to serial:
bash scripts/start_supervisor.sh - If you do not need to reflash firmware, skip it with
FLASH_FIRMWARE=0 bash scripts/start_supervisor.sh.
- Configure
config/config.yamlwith the serial port/baudrate, flow-meter source units, and optionallyserver.auth_token. - For the Global Industrial 318506 scale, set
scale.port,scale.baudrate,scale.byte_format, andscale.layoutto match the scale'sUSER-COM2-*menu settings. The default USB virtual RS232 setup here isCOM2,9600,8N1,MULTPL. - Launch the API with the project helper:
bash scripts/start_supervisor.sh- This helper uploads firmware by default, then starts
uvicorn supervisor.app:appin the background. - Default bind is
0.0.0.0:8000; override withHOST_OVERRIDEandPORT_OVERRIDE. - Useful runtime env vars:
SUPERVISOR_TOKEN(auth token),FLASH_FIRMWARE=0(skip upload),PIO_ACTIVATE(PlatformIO venv),PY_ACTIVATE(Python venv).
- This helper uploads firmware by default, then starts
- To run in the foreground using the
server.host/server.portvalues fromconfig/config.yaml, use:bash supervisor/run.sh - Typical SSH workflow:
- SSH into the lab host (no X forwarding needed).
- Activate the project environment if applicable (
source .venv/bin/activate). - Start the supervisor in one terminal:
bash scripts/start_supervisor.sh
Leave it running; by default it binds to0.0.0.0:8000for remote clients.
- Web GUI:
http://<host>:8000/ui- Dark/light aware layout with responsive temperature/pressure plots, live valve state, and per-sensor readouts.
- Control pump command, LN valve state, heaters, and auto-mode targets: HFE goal, HX limit, HX approach, and hysteresis.
- View VFD, pressure, flow-meter, fluid-property, safety-interlock, and heater telemetry when the firmware reports it.
- Forward over SSH:
ssh -L 8000:localhost:8000 <user>@<host>then browsehttp://localhost:8000/ui - Copy link with
?token=...if auth enabled, or load without token whenAuth required: False. - The logging toggle streams telemetry to
data/raw/log_<YYYYMMDD>_<HHMMSS>.csvon the supervisor host while buffering a local browser download; pressing it again ("Stop Logging") stops the server-side log and saves a copy to your browser when rows were buffered locally.
- Command-line pipeline:
hfe-hx --input data/raw/<file>.csv- Outputs go to the relevant subfolder under
data/processed/by default.
- Outputs go to the relevant subfolder under
- Top-level notebooks live in
analysis/notebooks/:TC_calibration.ipynb: thermocouple calibration tables and diagnostics.TC_reading_uncertainty.ipynb: thermocouple readout-noise and reading-uncertainty estimates.thermo_analysis.ipynb: HFE-7200 LN2 dip / thermal analysis.cooldown_model.ipynb: cooldown and pressure-drop modelling.HX_performance_analysis.ipynb: heat-exchanger performance reduction.pump_performance.ipynb: pump-speed and pump-performance analysis.leak_checks.ipynb: leak-test reductions and plots.viscosity_estimate.ipynb: recirculation-log viscosity estimates.HFE_properties.ipynb: HFE property plots.
- Per-log recirculation review notebooks live in
analysis/notebooks/log_review/. - Dissertation-style generated diagrams live in
analysis/diagrams/; runpython analysis/diagrams/build_figures.pyto regenerate the PDFs.
- The active calibration table is
data/processed/calibration/TC_calibration_20260420.csv. - The first April 10 calibration table is retained as
TC_calibration_20260410.csv, but it was recorded before the firmware thermocouple type fix and is historical only. - The thermocouple type fix boundary is
2026-04-20 11:15:45, matchingdata/raw/calibration/log_20260420_111545.csv. - For pre-fix logs,
orca.logbook.apply_legacy_tc_correctionback-converts Type T probes that were decoded as Type K before any final anchoring. - The pre-fix HX channels
THM_CandTHI_Cwere already Type K, so they use the active room + warmup-transfer HX calibration instead of the Type T legacy reconstruction. - For post-fix raw logs,
orca.logbook.read_tc_calibrated_csvapplies the current affine calibration in memory when a calibration path or logger metadata calibration file is available, while preserving raw columns. - Raw supervisor logs are written with
tc_calibrated=false; calibration belongs in analysis/UI normalization, not as destructive edits to raw logged values.
- Use the VS Code Source Control pane to commit and push changes.