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, and reference 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.
- (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 - Upload the pump-test sketch, if needed:
platformio run -d firmware -e pump_test -t upload firmware/platformio.inipins the main upload/monitor port to the Arduino-by-id path; update it if the board changes.
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),SUP_ALLOW_DUMMY=1(dummy telemetry when serial is unavailable).
- 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.
- Serial/UI logger (legacy):
python3 scripts/plot_temp.py(edit thePORTconstant in that script if needed).
- Command-line pipeline:
hfe-hx --input data/raw/<file>.csv- Outputs go to
data/processed/by default (configurable via flags).
- Outputs go to
- Notebook: open
analysis/notebooks/HX_performance_analysis.ipynbafter installing the analysis package above.
- Use the VS Code Source Control pane to commit and push changes.