Last class drew arrows between boxes. Today we look at what flows along them: how data gets in, what happens to it, and what is worth keeping.
Recall first: the smart-speaker exit ticket. Cascade plus edge filter.
In your ML courses, data was a table. Here, it is a river.
a dataset · what you are used to
#
ax
ay
az
label
1
-0.10
0.12
9.85
run
2
-0.10
0.71
8.38
sit
3
-0.05
0.23
8.37
run
4
-0.39
-0.82
9.62
sit
5
0.27
0.19
8.79
run
6
0.31
0.23
8.31
walk
7
0.66
-0.87
8.07
walk
Finite. Shuffle it, load it whole, go back to row 3.
a stream · what the device sees
now
← already gonestill arriving →
Endless, in order, in real time. The device can hold only a few seconds of it. Everything in this class follows from that.
The dots move continuously. Ask: what would it mean to "shuffle" a stream? To "go back to row 3"? You cannot; the past is gone unless you chose to keep it.
The pipeline has three stages.
In Class 5's blueprint, ingestion is block 1, processing is block 2, and storage runs underneath all of them.
This slide is the map for the hour. Come back to it between sections.
1 · ingestion
Two numbers describe every digital signal.
sampling rate · how often
IMU 50–100 per second · voice 16,000 per second · camera 5–30 frames per second
resolution · how finely
8-bit = 256 levels · 16-bit audio = 65,536 levels. More bits, more bytes.
Bytes per second = samples per second × bytes per sample × channels. Every memory sum in this course starts here.
The "how fast is fast enough" rule (Nyquist) is Class 8. Today just the intuition: sample too slowly and you lose the shape.
try it live
How much memory does one window need?
sensor
window
vs SRAM · 512 KB
vs PSRAM · 8 MB
Ask the class to predict before each click. Good sequence: microphone 1 s (fits easily), VGA colour 1 s (does not fit SRAM, barely fits PSRAM), then temperature 10 s (almost nothing). Rates are typical values, set in the deck's code.
A single photo does not fit in the chip's own memory.
That is why camera projects need PSRAM, and why this course bought the N16R8 board.
And why vision models on microcontrollers work on tiny images: a 96 × 96 grey image is 9 KB.
Area is proportional to bytes: the dashed SRAM rectangle sits inside the frame. RGB565 means 2 bytes per pixel.
2 · processing
A ring buffer keeps the latest N samples, forever.
Twelve slots in a circle. Each new sample goes where the write head points, then the head moves on.
When it comes round again, the oldest sample is overwritten. Memory never grows.
Darker = newer. On the doorbell, a ring of 16,000 slots always holds the last second of sound.
Click "add a sample" a few times, then "add ten" to show wrap-around. Ask: what happens to sample 1 when sample 13 arrives?
The model sees fixed-size windows. Where you cut matters.
The price: twice as many windows, so twice as many inferences per second.
The overlap bars underneath show windows starting every half window. Ask: what overlap would you pick on a battery device, and why?
Clean it, then scale it the same way every time.
cleaning
the classic bug
0 – 1
pixels in training
0 – 255
pixels on the device
Same model, same images, garbage answers. The scaling on the device must match training exactly.
This bug has wasted more student project hours than any other. Make them say it: same scaling in training and on the device.
Two kinds of shrinking: resizing (keep the data, fewer of it) and feature extraction (describe the data in a few numbers). Class 8 builds the features properly.
3 · storage
Four places to keep data. Each step down is bigger and further away.
the rule
Keep results, not raw data. Except the samples the model was unsure about: those are the most valuable data for the next model.
Ask which tier the BrickML's alerts live in before they are sent (flash, so they survive a reboot), and which tier the doorbell's clip goes to (cloud).
Two ways the data betrays you after you ship.
training–serving skew · it was never the same
data drift · it slowly stops being the same
The fix for both lives in the pipeline: collect training data the way the device will see it, and keep watching after you ship.
Illustrative curves. Ask: how would the device even know its accuracy is dropping, with no labels in the field? (Watch the confidence; save the unsure samples; have a human check a few.)
// ESP32-S3 + MPU6050 · print a 3-axis stream#include<Adafruit_MPU6050.h>
Adafruit_MPU6050 mpu;
voidsetup() {
Serial.begin(115200);
Wire.begin(); // SDA, SCL: your board's I2C pins
mpu.begin();
}
voidloop() {
sensors_event_t a, g, t;
mpu.getEvent(&a, &g, &t);
Serial.print(a.acceleration.x); Serial.print(',');
Serial.print(a.acceleration.y); Serial.print(',');
Serial.println(a.acceleration.z);
delay(10); // about 100 samples a second
}
live demo · 8 minutes
Shake the board. Watch the river.
Open the Arduino Serial Plotter and shake, tilt, tap.
Then freeze it and mark 2-second windows on the screen. Ask: what would a model see in each one?
The delay(10) sets the sampling rate. Change it to 100 and watch the shape degrade, exactly like slide 4.
Uses the Adafruit MPU6050 library. On the ESP32-S3, Wire.begin() with no arguments uses the board's default I2C pins; check the pin map for your board revision before class, or pass SDA and SCL explicitly.
our running example
The doorbell's pipeline, with numbers.
Every number on this slide you can now calculate yourself. That is the skill: a pipeline is a budget.
Have students verify two numbers aloud: 16,000 × 2 bytes = 32 KB; 320 × 240 × 1 = 76,800 bytes ≈ 75 KB.
exit ticket · on paper, before you leave
A gesture band samples a 3-axis IMU at 50 Hz with 16-bit values, in 2-second windows with 50% overlap. How many bytes is one window? How many windows per minute?
Next class: embedded ML and TinyML. What a model actually is, and how to tell if it will fit.
Answer: 3 × 50 × 2 bytes × 2 s = 600 bytes. A new window starts every second, so about 60 per minute (59 complete ones in the first minute).