On the Pi · the onboard display
The monitor that runs on the Pi itself.
No internet needed: a Pi, a browser and a lab network.
Besides this website, the Raspberry Pi serves its own display over the lab network. It is the web-based HMI from the report, the one that runs on the Pi, and the offline fallback for a demo: with no internet at all, the Pi still draws the waveform and shows the classifier's answer. When the Pi is on, the same display is also public at live.eecsyorku.app, through a Cloudflare Tunnel.
0
cloud calls · runs on the Pi
5000
default port · python -m hmi
1
command to start it
01 · Why it exists
A display that does not need the internet.
What it is
A small Flask web server written in Python, and one page built from the same code as this website. Start it withpython -m hmi on the Raspberry Pi, open the Pi's address from any laptop on the same network, and the browser draws the waveform and the classification. The server reads the ADC and classifies the newest window with the trained model on the Pi's own CPU.
It has two views, chosen with Live | Recorded in its header: Live, the newest seconds from the ADC, and Recorded, the same recording monitor as this website's, where Through the hardware shows the files the Pi has recorded through the speaker and microphone. When the Pi is on, the same display is online at live.eecsyorku.app, through a Cloudflare Tunnel. If the Pi is off or cannot connect, visitors see an offline page instead.
Why it exists
The report promises a web-based HMI that runs on the Pi and opens in a browser. This is that display. It needs only the Pi and a browser, so it keeps working when a venue has no internet: it is the offline fallback for demos.
This website is the public view of the same project. It needs the internet to load, and it cannot reach a Pi that is switched off.
Side by side
This website and the Pi's own display
| Question | This website | The Pi's own display |
|---|---|---|
| Where it runs | Static pages in your browser, served by Cloudflare. No server code runs for them. | A Flask server on the Pi. Your browser draws the page it sends. |
| Needs the internet | Yes, to load the pages. | No. It needs only the network between the Pi and the browser. |
| Where the data comes from | Recordings and results exported ahead of time. The Live monitor link opens the Pi's own display when it is online. | Live: the PCM1808 ADC (a replay of .wav files when started for a demo). Recorded: the same exported recordings as this website, and the files the Pi has recorded through the hardware. |
| Classification | Answers computed ahead of time by the trained model and shipped with the pages. | Computed on the Pi's own CPU by the trained model, for the Live view and for each file recorded through the hardware. The offline baseline in the Recorded view is the same model's answer, computed ahead of time. |
| The renderer | plot.js, a byte-for-byte copy. | plot.js, the original, unchanged since the midterm. |
| Best for | Explaining the project to anyone with a link. | A demo with no internet, and the display the hardware's samples will appear on. |
Both draw the waveform with the same renderer, so a plot on one looks like a plot on the other.
02 · The screens
Every part of the display, explained.
FIG. 1 · The Pi's display, Live view · replay of 9979_TV.wav and 84987_PV.wav
Real screenshot · 1440 px wide


1 · Live | Recorded
The page's two views, in its header. Live shows the Pi's input as it arrives; Recorded is the recording monitor. Recorded keeps its place in the address (/#recorded), so a link can open either view.
2 · Status
What the feed is doing, in one large word. While the Pi answers it is the input's state: Capturing, No signal from the ADC, ADC not available, or Replaying files, as here. Otherwise Connecting, Offline or Paused. The line under it says when the last samples arrived.
3 · Sweep, Scroll and Pause
Sweep writes the trace left to right like a bedside monitor; Scroll moves it past a fixed pen. Pause holds the display and stops asking the Pi for samples until you resume.
4 · Newest samples
The newest 10 s, drawn by plot.js on labelled axes, with the latest 5 s window the classifier used marked as a band. From the ADC these are the samples after the anti-alias low-pass and decimation to 4000 Hz: the samples the classifier receives.
5 · Readouts
How long the Pi has been acquiring, the span drawn, the sample rate and the band the model keeps (20–500 Hz).
6 · Classification card
The model's answer for the latest 5 s window, re-classified about once a second: the label, the confidence and the meter, which shows the share of the random forest's trees that vote murmur, against the fixed threshold of 0.32. Confidence is the share of trees that agree with the answer, not a probability. One window, not a whole recording, and a research output, not a diagnosis.
7 · Recent windows
One cell per window the Pi has classified, oldest first, the newest outlined: a circle for murmur absent, a triangle for murmur present, and the share of trees voting murmur.
8 · Input card
What feeds the display and how it is doing. On the Pi it is the PCM1808 ADC: capturing, no signal, or not available, with the reason. Here it names the replayed files and the one now playing. Then the sample rate, the time acquired and how long one classification took; that time was measured on the computer that took the screenshot.
Open the full-size screenshot Open the full-size screenshot
Live | Recorded
The page's two views, in its header. Live shows the Pi's input as it arrives; Recorded is the recording monitor. Recorded keeps its place in the address (/#recorded), so a link can open either view.
Status
What the feed is doing, in one large word. While the Pi answers it is the input's state: Capturing, No signal from the ADC, ADC not available, or Replaying files, as here. Otherwise Connecting, Offline or Paused. The line under it says when the last samples arrived.
Sweep, Scroll and Pause
Sweep writes the trace left to right like a bedside monitor; Scroll moves it past a fixed pen. Pause holds the display and stops asking the Pi for samples until you resume.
Newest samples
The newest 10 s, drawn by plot.js on labelled axes, with the latest 5 s window the classifier used marked as a band. From the ADC these are the samples after the anti-alias low-pass and decimation to 4000 Hz: the samples the classifier receives.
Readouts
How long the Pi has been acquiring, the span drawn, the sample rate and the band the model keeps (20–500 Hz).
Classification card
The model's answer for the latest 5 s window, re-classified about once a second: the label, the confidence and the meter, which shows the share of the random forest's trees that vote murmur, against the fixed threshold of 0.32. Confidence is the share of trees that agree with the answer, not a probability. One window, not a whole recording, and a research output, not a diagnosis.
Recent windows
One cell per window the Pi has classified, oldest first, the newest outlined: a circle for murmur absent, a triangle for murmur present, and the share of trees voting murmur.
Input card
What feeds the display and how it is doing. On the Pi it is the PCM1808 ADC: capturing, no signal, or not available, with the reason. Here it names the replayed files and the one now playing. Then the sample rate, the time acquired and how long one classification took; that time was measured on the computer that took the screenshot.
FIG. 2 · The Pi's display, Recorded view · 9979_TV.wav · tricuspid
Real screenshot · 1440 px wide


1 · Live | Recorded
Recorded is selected: the recordings the Pi carries, in the same monitor as this website's Recording monitor page.
2 · Result shown
Offline baseline, chosen here, is the model's score on the file, computed in software during training. Through the hardware is the same file as the Pi recorded it through the speaker, coupler, silicone layer and microphone. It shows a capture, a bench file whose score is held back until the whole bench is recorded, or Not measured; on the Pi's own page a file can be recorded from there.
3 · Recordings
The recordings on the Pi, one card each. The chips are the dataset's labels, not the model's output. Blind reading hides them until you make your own reading.
4 · Play and view
Play sounds the file and moves the view along with it. Window turns a page at a time; Strip chart scrolls the trace past a fixed pen.
5 · Waveform and marks
One window of the file on labelled axes, drawn by plot.js: time in seconds, amplitude in file units (full scale ±1). The ticks and hatched bands are the dataset's S1, S2 and murmur annotations, and the band marks the analysis window the card describes. Point at the plot, or focus it and use the arrow keys, to read one sample: its time, its position in the file and its amplitude.
6 · Overview and controls
The whole file in miniature, with the part on screen outlined, then where the view starts, how long it is (2, 5 or 10 s) and the amplitude scale.
7 · Classification card
The model's answer for the whole recording: the mean, over 5 s windows taken every 2.5 s, of the share of the random forest's trees that vote murmur, against the fixed threshold of 0.32. Confidence is the share of trees that agree with the answer, not a probability. Then one cell per window, and the window on screen. A research output, not a diagnosis.
8 · Recording card
The file, its valve, the dataset label, the sample rate and the length, and which half of the dataset it is in: here the test half, held out from training.
9 · See what the AI sees
Opens five steps for the window on screen, from the raw samples to the decision.
Open the full-size screenshot Open the full-size screenshot
Live | Recorded
Recorded is selected: the recordings the Pi carries, in the same monitor as this website's Recording monitor page.
Result shown
Offline baseline, chosen here, is the model's score on the file, computed in software during training. Through the hardware is the same file as the Pi recorded it through the speaker, coupler, silicone layer and microphone. It shows a capture, a bench file whose score is held back until the whole bench is recorded, or Not measured; on the Pi's own page a file can be recorded from there.
Recordings
The recordings on the Pi, one card each. The chips are the dataset's labels, not the model's output. Blind reading hides them until you make your own reading.
Play and view
Play sounds the file and moves the view along with it. Window turns a page at a time; Strip chart scrolls the trace past a fixed pen.
Waveform and marks
One window of the file on labelled axes, drawn by plot.js: time in seconds, amplitude in file units (full scale ±1). The ticks and hatched bands are the dataset's S1, S2 and murmur annotations, and the band marks the analysis window the card describes. Point at the plot, or focus it and use the arrow keys, to read one sample: its time, its position in the file and its amplitude.
Overview and controls
The whole file in miniature, with the part on screen outlined, then where the view starts, how long it is (2, 5 or 10 s) and the amplitude scale.
Classification card
The model's answer for the whole recording: the mean, over 5 s windows taken every 2.5 s, of the share of the random forest's trees that vote murmur, against the fixed threshold of 0.32. Confidence is the share of trees that agree with the answer, not a probability. Then one cell per window, and the window on screen. A research output, not a diagnosis.
Recording card
The file, its valve, the dataset label, the sample rate and the length, and which half of the dataset it is in: here the test half, held out from training.
See what the AI sees
Opens five steps for the window on screen, from the raw samples to the decision.
03 · How it works
A small server and a built page.
FIG. 3 · How a screen gets its data
In order
Browser
A laptop on the network, or the Pi's own screen.
- The Pi pageLive | Recorded, built from this website's code into web/dist-pi.
- plot.jsThe renderer: draws a window of samples. Unchanged since the midterm.
GET /api/live
JSON answer
Flask server, on the Pi
Checks the request, reads a window of samples, asks the classifier, sends JSON.
- hmi/app.pyThe routes under /api and the page itself. It does no signal maths.
read(start, duration)
classify(window)
samples, result
Source and classifier
The source is the one part that changes when the hardware arrives.
- WavFileSourceReads the .wav files in the data folder.
- FileReplaySource, LiveMonitorA real-time replay of .wav files that feeds the Live view when no ADC is used.
- AlsaCaptureSourceReads the PCM1808 through the Pi's I2S input (arecord, 48 kHz) and decimates to 4 kHz, behind the same BlockSource interface. Tested with a fake stream; not yet run against the wired ADC.
- MurmurModelRandom forest on 26 MFCC summary numbers per window (13 MFCCs, mean and standard deviation).
A JSON API
The server's job is small: serve the built page, check each request, ask the source for the newest samples, ask the classifier about them, and send back JSON. It does no signal processing of its own.
The page, built from this website
The page is the Pi build of this website (npm run bundle:pi): the same components as the Recording monitor, plus the Live view. Live asks /api/live for new samples several times a second; Recorded reads the exported recordings and the Pi's /api/reacquired. If the built page is missing, the server falls back to the plain page from the midterm.
A renderer that did not change
plot.js draws one window of samples on labelled axes. It has not changed since the midterm. This website loads a byte-for-byte copy of it, so the waveforms on Home and the Recording monitor are drawn by the same code as the Pi's display.
A source you can swap
The display was built so its data source can move from a file to live samples without touching the renderer. The Live view runs that way: on the Pi, AlsaCaptureSource reads the PCM1808 ADC; for a demo with no hardware, a real-time replay of .wav files feeds the same loop. The capture source is written and tested against a fake stream, and has not yet run against the wired ADC.
The JSON routes
- GET /, /_astro, /data
- The built page and the recordings exported with it (the Recorded view's offline baseline).
- GET /api/live
- The newest samples of the acquisition loop and its latest classification, with the state of the input (Live view).
- GET /api/reacquired
- The files recorded through the hardware so far, each classified by the same model and threshold. A bench file's answer is held back until the whole bench is recorded.
- POST /api/reacquire
- Records one file while the page plays it through the speaker. Only from the Pi itself or its local network, never through the public tunnel.
- GET /api/window
- One window of a .wav file in the data folder with its classification: the plain fallback page uses it when the page is not built.
Where to look in the code
- hmi/app.py
- The Flask app: the built page, its data and the JSON routes.
- hmi/__main__.py
- python -m hmi and its options: host, port, --capture or --live, the built page's folder.
- web/src/routes/monitor.astro
- The page: the Live | Recorded switch and the two views. npm run bundle:pi builds it into web/dist-pi.
- web/src/components/pi-monitor/
- The Live view: the plot, the Classification card and the Input card.
- web/src/components/recordings/
- The Recorded view: the same recording monitor as this website, with Through the hardware.
- hmi/static/plot.js
- The renderer: draws one window of samples. Unchanged since the midterm.
- pcg/sources.py, pcg/stream.py
- Where samples come from: WavFileSource, the BlockSource interface, the replay and the LiveMonitor.
- pcg/capture.py
- AlsaCaptureSource: reads the PCM1808 through the Pi's I2S input and decimates it to 4 kHz.
- pcg/reacquire.py
- Records a file played through the hardware, lines it up with the original and stores it for the experiment.
04 · Start it
Four steps, then open it in a browser.
Put the project on the Pi.
On a computer with Node, build the page:
npm run bundle:piinweb/writesweb/dist-pi. Then copy the project folder over, withscpor a USB stick, withweb/dist-pibut not.venv: it belongs to one machine. The recordings are not in git, so copy the .wav files intodata/: a Live replay plays them, and a file recorded through the hardware is lined up against its original there.Install the packages.
cd project python3 -m venv .venv .venv/bin/pip install --only-binary=:all: -r requirements.txtKeep the exact versions in requirements.txt: the saved model is tied to the scikit-learn and numpy versions it was trained with. The first run can take minutes while the feature code warms up.
Start the server.
.venv/bin/python -m hmi # Recorded only .venv/bin/python -m hmi --capture # Live from the PCM1808 ADC, and Recorded .venv/bin/python -m hmi --live data/9979_TV.wav data/84987_PV.wav # no hardware: Live from a replay, and RecordedThe Live view is switched on by
--capture(the ADC) or by--livewith at least one .wav file (a replay stands in for the ADC, for a demo with no hardware). Give only one of the two. If the ADC is missing or silent, the page says so and retries every few seconds. With--capture, the Recorded view can also record a file through the hardware, from the Pi itself or its local network only.Open it from a laptop.
On the same network, open
http://<pi-hostname>.local:5000, orhttp://<pi-ip>:5000: runhostname -Ion the Pi to find its address. On the Pi itself,http://localhost:5000works.If the page does not load, check that both devices are on the same network and that it allows device-to-device traffic. Some campus and guest Wi-Fi does not.
Keep it on a private network
The Flask server has no login. On the lab network it is fine as it is, but do not expose it to the internet with a port forward. The public copy at live.eecsyorku.app does not do that: it runs the same display under the waitress server (--production) and reaches it only through a Cloudflare Tunnel.