Technical reference
How every number on the screen is produced: the signal chain, sample-rate rules, measurement formulas, the math-channel language, and the firmware's command and frame formats down to the byte, and the measured limits of the test board. The version is shown at the end of this page.
This page is deliberately concise. The ideas behind each section (what sampling, triggering, decimation, ETS or the FFT are) are explained in Oscilloscope fundamentals; each section here starts with a link to the matching chapter. How to operate the controls is in the user guide.
Read the user guide first for safety, wiring and operating the scope. This document is the precise version: where the two differ, this one is correct. Claims here can be checked with the verification guide (hardware) and the self-test (software).
1. Specifications
Values marked datasheet come from Espressif's ESP32 documentation. Values marked measured are measured on your board when it connects. design means a limit set by this firmware or software. Verify the important ones on your own board with the verification guide.
| Parameter | Value | Source |
|---|---|---|
| Board | Classic ESP32 (ESP32-WROOM-32 / ESP32-DevKitC, 30 or 38 pins). Not the S2, S3, C3 or C6 variants: their ADC and pins differ. | design |
| Analogue inputs | Up to 4 at once, from GPIO 36, 39, 32, 33, 34, 35 (ADC1 only). | design |
| Input range at the pin | 0 V to ≈ 3.1 V readable (11 dB attenuation). Recommended accurate range 0.15–2.45 V. | datasheet |
| Absolute maximum at the pin | −0.3 V to VDD + 0.3 V (3.6 V on a 3.3 V board). Not 5 V tolerant. | datasheet |
| Resolution | 12 bits (4096 codes, ≈ 0.8 mV per code at 11 dB). | datasheet |
| Linearity | DNL ±7 LSB, INL ±12 LSB (uncalibrated). | datasheet |
| Calibration | Factory eFuse values, applied by the ESP32's own driver to build a 4096-entry code → mV table that is sent to the browser. | design |
| Max sample rate, DMA engine | Set by the board's start-up probe (section 3.6): the fastest of 40 k, 100 k, 250 k, 500 k, 1 M, 1.25 M, 1.667 MSa/s at which this chip delivered every conversion. Measured on the test board (ESP32-D0WD, core 3.3.12): 250 kSa/s, the same in three runs. Shared by the channels (two channels: half each). Arduino core 3.x only. Shown in the top bar. | measured |
| Max sample rate, analogRead engine | 1 / (tread × channels × 1.12), where tread is one analogRead(), timed at start-up. It depends on the Arduino core. Measured on one ESP32-D0WD board: core 3.3.12 → 41.2 µs (21.6 kSa/s on one channel), core 4.0.0 → 53.4 µs, core 2.0.17 → 127.2 µs. | measured |
| Capture memory | 24 000 16-bit values (halved again if RAM is short), shared by channels; peak detect uses two values per point. | design |
| Points per capture | Memory = auto (default): as many as keep the fastest sample rate, up to the capture memory (24 000 with one channel), limited so the transfer takes no longer than half a screen time (at least 30 ms). At 921 600 baud, one channel: 1382 points at 5 ms/div, 2304 at 10 ms/div, 11 520 at 50 ms/div; from 10 ms/div to 100 ms/div this gives 23 kSa/s. Hi-Res: 1000. Fixed choices 500 … 16 000. | design |
| Timebase | 5 µs/div … 50 s/div in 1-2-5 steps (50 ns/div … 2 µs/div in addition with ETS, section 3.7); 10 divisions per screen. The fastest step offered gives about 10 samples per screen at the engine's maximum (DMA at 250 kSa/s: 5 µs/div, 12.5 samples per screen; analogRead at 21.6 kSa/s: 50 µs/div). Roll mode from 100 ms/div by default (50, 100, 200 ms/div or off). | design |
| Trigger | Edge (rising, falling, both) with hysteresis, Auto / Normal / Single, force, holdoff (text streams). DMA engine: evaluated on every conversion of the trigger channel, independent of the acquire mode. | design |
| Signal generator | One output pin: high (3.3 V), low (0 V), square wave 0.01 Hz – 1 MHz, duty 0–100 % (square waves of 1 Hz and up are whole hertz), or (firmware 1.5.0) a sine from the DAC on GPIO25 / GPIO26, 130.6 Hz – 200 kHz in whole steps of ≈ 130.6 Hz (the app's Frequency field only offers those steps). | design |
| Generator drive | 3.3 V logic output; always use a series resistor (330 Ω minimum). The pin's current rating is in the ESP32 datasheet; this design assumes no more than about 10 mA. | design |
| Link | USB serial, 921 600 baud, 8N1 (firmware). Text streams: any baud. | design |
| Browser | Chrome or Edge on Windows, Linux or macOS (Web Serial); tested with Edge on Windows 11 and Helium (Chromium-based) on Ubuntu, not on macOS. Firefox desktop has Web Serial from version 151 (not tested with this app). Any browser for Demo and log files. | design |
2. Signal chain: from pin to screen
Concepts: the signal path in Oscilloscope fundamentals.
Every displayed value passes through the same steps, in this order. Knowing the order explains, for example, why AC coupling changes an integral, and why the trigger level is set in displayed volts.
- ADC code. The firmware stores each reading shifted left by 4 bits ("12.4 fixed point"), so averaged readings keep their fractional part: value ÷ 16 = code, 0.0000 … 4095.9375.
- Calibration. The browser converts code → millivolts with the table the firmware sends at connection, interpolating linearly between neighbouring codes. If a board calibration is set (Data → ADC calibration), it then corrects gain and offset: v = (reading − offset) ÷ gain. The trigger level is converted back with the inverse, reading = gain × v + offset.
- Probe and invert. Multiply by the probe factor; multiply by −1 if Invert is on.
- BW limit. A centred moving average over 3, 9, 33 or 99 samples (fewer at the ends of the record).
- Coupling. DC: unchanged. AC: the mean of the samples on screen is subtracted from the whole record. This is a software operation: the pin still sees the full voltage, and the input range does not change.
Math channels, measurements and cursors all use the final displayed values. The firmware trigger compares raw codes, so the browser converts the trigger level back: code = table−1(level ÷ probe), and swaps rising/falling when Invert is on.
3. Acquisition
There are three ways samples arrive, and the scope picks the matching method automatically:
| Method | When | How | Dead time |
|---|---|---|---|
| Block | ESP32-DSO firmware, time/div below the roll threshold | The ESP32 samples into RAM at a fixed rate, checks the trigger itself, then sends the whole capture. | Yes: while a capture is being sent, nothing is sampled. |
| Roll | ESP32-DSO firmware: Horizontal → Mode = Roll (50 ms/div and slower), or Y-T/X-Y at or above the Auto roll time/div (default 100 ms/div) | Continuous stream in chunks of up to 128 points. No trigger. | None, unless USB falls behind (then a GAP is marked). |
| Text stream | ScopeProbe library or any sketch printing numbers | One line per sample with its own timestamp. The browser keeps up to about a million samples and triggers on them itself. | None. |
3.1 How the sample rate and number of points are chosen
Concepts: memory, record length and the time base in Oscilloscope fundamentals.
With the firmware, the browser computes the settings and sends them in a CFG command (section 10). Symbols: tread = time of one reading (from the hello frame), Nch = channels switched on, Tscreen = 10 × time/div.
The idea: Normal (and Peak, Average) keep every sample the ADC can deliver for as long as memory and the USB link allow, like a bench scope's deep memory, so slow time bases are not sampled slowly. Hi-Res instead takes about 1000 points per screen and averages all readings within each point's interval into it (section 3.2), giving clean traces with no false slow waves.
Example, one channel, tread = 41.3 µs (measured with core 3.3.12) → max rate = 21.6 kSa/s, 921 600 baud:
| Time/div | Normal: points | Normal: Sa/s | Hi-Res: points | Hi-Res: Sa/s | Readings averaged per Hi-Res point |
|---|---|---|---|---|---|
| 10 µs – 2 ms | 3 – 432 (shown on screen) | 21.6 k | same | 21.6 k | 1 |
| 5 ms | 1 081 | 21.6 k | 1 000 | 20 k | 1 |
| 10 ms | 2 162 | 21.6 k | 1 000 | 10 k | 2 |
| 20 ms | 4 324 | 21.6 k | 1 000 | 5 k | 4 |
| 50 ms | 10 809 | 21.6 k | 1 000 | 2 k | 12 |
| 100 ms (roll) | 10 000 | 10 k | 1 000 | 1 k | 24 |
| 1 s (roll) | 10 000 | 1 k | 1 000 | 100 | 240 |
| 10 s (roll) | 10 000 | 100 | 1 000 | 10 | 2 400 |
Version 1.1 used 1000 points in every mode, so from 10 ms/div down the sample rate halved with each slower step (5 kSa/s at 20 ms/div, 10 Sa/s at 10 s/div) and fast signals aliased. With more channels, divide the rates by the number of channels.
The firmware checks the request again: if one point costs more than 1 / rate (with a 10 % margin), it samples as fast as it can, measures the real interval and sets the SLOW flag; the status bar then shows max rate. Its reply ok cfg … rate=… reports the rate it will really use.
3.2 Acquire modes, exactly
Concepts: decimation and acquire modes in Oscilloscope fundamentals.
| Mode | Algorithm | Notes |
|---|---|---|
| Normal | One reading per point per channel. | Shows the true noise. |
| Peak | During each point interval the firmware reads continuously and keeps the minimum and maximum code per channel. Both are sent; the trace is drawn as a band, and its centre line ((min + max) / 2) is used for measurements and math. | Block mode only. If the requested rate is already the maximum (no time to spare), the firmware falls back to Normal and clears the PEAK flag. |
| Hi-Res | The ESP32 reads continuously during each point's whole interval and stores the average of all those readings (a "box-car" filter). Averaging K readings of random noise divides the noise by about √K. Because the average covers the full interval, anything that changes faster than the sample rate is averaged away instead of turning into a false slow wave (aliasing): a box-car of length T removes frequencies 1/T, 2/T, 3/T … completely and attenuates everything above about 1/(2T). | At the maximum rate there is time for only one reading (plain Normal). The Acquire settings show the average number of readings per point (×N avg/pt). Before 1.2, only a few readings at the start of each interval were averaged, which did not prevent aliasing. Averaged in millivolts (firmware 1.4.5): each reading is converted through the calibration table before averaging, and the average is sent as the fractional code whose table value it is. The ESP32's table is straight up to code 2880 (about 2.5 V) and bends above it, so averaging raw codes (1.4.4 and older) gave a wrong mean when a point spanned that region: a 0–3.3 V square read 1.80 V instead of 1.62 V on the test board. Signals that stay below about 2.5 V were never affected. |
| Average | In the browser, over successive triggered captures with the same settings: after the n-th capture, avg ← avg + (new − avg) / min(n, N). For the first N captures this is the exact mean; after that it is an exponential average where each new capture has weight 1/N. | Block mode only. Needs a stable trigger: an untriggered signal averages towards a flat line. Any settings change restarts it. |
| ETS | In the browser, from one full-length record: period measurement and folding (section 3.7). | Block mode and DMA engine only (otherwise Normal is used and the Acquire line says so). Repeating signals only. |
Horizontal modes
Modelled on bench scopes, which offer the time modes Y-T (called Normal on some), X-Y and Roll:
| Mode | Behaviour | Limits |
|---|---|---|
| Y-T | Triggered pictures, block or text acquisition. With Auto roll set, switches to rolling at and above that time/div (like the "Roll: Auto" choice on some bench scopes). | All time bases. |
| Roll | Continuous streaming; the newest sample is at the right edge. The trigger, horizontal position, Peak detect, Average and ETS are not used (the acquire badge is dimmed). SINGLE records one screen and stops. Autoset returns to Y-T. | 50 ms/div and slower; choosing Roll at a faster time base sets 50 ms/div. Bench scopes have similar limits: Rigol's DS2000A/DS4000 allow 200 ms/div to 1 ks/div and set 200 ms/div when Roll is turned on; Keysight's U2701A sets 500 ms/div. |
| X-Y | The two chosen traces plotted against each other, from the same acquisition as Y-T (including Auto roll). 8 × 8 square divisions; each axis uses its trace's scale and position. Channels are lined up in time first (1.11.2): each is interpolated linearly back to slot 0's time, as Y-T shifts them, so two channels on the same signal draw a line. Before 1.11.2 point i of X was paired with point i of Y, which showed 360° × f × skew of false phase. Test board, CH1 and CH2 both on GPIO34 (same signal), DAC sine ±0.8 V (2026-11-28): the pairing alone gave 9.0° at 6138 Hz with DMA (skew 4 µs) and 13.8° at 914 Hz with analogRead (41 µs); after the correction the samples agree within 1° and the figure is a line as thin as the trace, in Normal and Hi-Res. The DAC's short dip at mid-scale (10.1) is caught by one channel and not the other, so it shows as a small spur on the line: that is the signal, not the alignment. Math traces stay at slot 0's time, as everywhere. Two steady values (a single point) are drawn as a dot; a switched-off channel or a math trace with no data is named on the grid instead of leaving it empty. | All time bases. |
3.3 Trigger
Concepts: the trigger in Oscilloscope fundamentals.
- Edge detection with hysteresis. A rising trigger arms when the signal goes below level − h, and fires at the first sample at or above level. Falling is the mirror image; Both accepts either. Because the firmware re-arms after an exactly repeatable delay, a periodic signal would otherwise hit the same edge first every time; so in RUN mode Both prefers the edge opposite to the previous capture's, as long as that edge occurs within one capture length (firmware 1.3.0; SINGLE takes whichever comes first). h is 12 mV at the pin (60 mV with Noise reject) in block mode, and 0.12 division (0.5 division with Noise reject) for text streams. Level outside the ADC range (browser 1.6.8): the browser converts the level to an ADC code with the calibration table; a level above full scale is sent as 4095×16 + h + 16 and a level below 0 V as −(h + 16), values no sample can reach, so the trigger never fires (Normal waits, Auto free-runs), as on a bench scope with the level above the signal. Before 1.6.8 such a level was clamped to code 4095 (or 0), and a clipped signal reaches that code, so it triggered on every edge with the level marker drawn above the trace. Trigger source switched off (browser 1.6.9): the source channel is still acquired, but not shown, as a bench scope still triggers on a channel that is not displayed; it shares the sample rate with the visible channels, and the trigger status adds "CHn hidden". Before 1.6.9 the board was told to trigger on the first channel that was on, so the picture was triggered by the wrong signal.
- Trigger point resolution. analogRead engine: the trigger tests each stored point (in Peak mode its min/max band). DMA engine: the trigger tests every conversion of the trigger channel before averaging or decimation, like the trigger system of a bench scope, so it also works in Peak mode when a point's band straddles the level, and in Hi-Res mode on edges shorter than a point. The trigger point is the first stored point that shows the signal past the level: the point that contains the crossing if its value already does (Normal: the crossing was in its first conversion; Hi-Res: in the first half of its average), otherwise the next point. The browser then interpolates the exact crossing between that point and the one before (firmware 1.4.4; earlier versions could mark the point before the edge when D > 1).
- Pre-trigger. The firmware records continuously into a circular buffer and only accepts a trigger once the pre-trigger part is full, so the samples before the trigger are always real.
- Auto mode. If no trigger comes within 0.6 screen widths (6 × time/div, at least 50 ms, at most 2 s) after the pre-trigger memory is full, the firmware captures anyway and sets the FORCED flag. The status bar shows Auto instead of Trig'd. 0.6 screens is long enough for any signal with two or more periods on screen. Text streams use the same, but at least 150 ms.
As on a bench scope, a signal that repeats more slowly than the Auto timeout gives a mix of triggered and forced pictures; use Normal mode for it, which waits for as long as it takes. (Firmware 1.4.0 stretched the timeout to the learned trigger spacing. That made Auto lock onto anything slow, including a potentiometer turned by hand, so firmware 1.4.1 returned to the fixed timeout above.) - Trigger interpolation. The firmware reports the first sample past the level. The browser finds where the signal crossed the level between that sample and the previous one (straight-line interpolation) and puts t = 0 exactly there. Without this, a triggered picture would jitter left-right by up to one sample period. Not applied to forced captures or Peak mode.
- Status. The first badge shows the run control (RUN, SINGLE, STOP). The second shows the trigger status: Trig'd (pictures start at real triggers), Auto (Auto mode is capturing without triggers; Keysight shows this as "Auto?"), Wait (Normal or SINGLE waiting for a trigger), Armed (first capture after a settings change), Roll and Stop. The trigger status is taken from each capture's TRIG/FORCED flag. The third badge (app 1.11.1) shows the acquire mode: NORM, PEAK, HRES, AVG or ETS. It is dimmed, with the reason in its tooltip, when the mode is not in effect: Peak, Average or ETS in roll mode (Normal is used), ETS without DMA (Normal) or while it cannot fold (plain record), and any mode with a text stream.
- Autoset (AUTO key) searches block-mode time bases (≤ 50 ms/div) for a repeating signal whose Amplitude (Top − Base) exceeds 100 mV. The ESP32's own noise is a few tens of mV peak-to-peak, so smaller "signals" are indistinguishable from it. When found, it sets about 2.5 periods per screen, the trigger level to the middle, rising edge, Auto mode, and fits the vertical scales. Otherwise it fits only the vertical scales and restores the original time base.
- Channel skew. Channels are read one after another, tread apart. Traces are drawn shifted by that amount, so their timing on screen is correct; X-Y interpolates the channels to the same instant (Horizontal modes, section 3.2). Math channels combine samples with the same index, i.e. readings taken up to (Nch − 1) × tread apart.
3.4 Update rate (frames per second)
Concepts: update rate in Oscilloscope fundamentals.
In block mode a picture can only be shown after the whole screen has been recorded, so a block-mode scope can never update faster than once per screen time (10 × time/div). Each update takes:
pre-trigger part + wait for a trigger + post-trigger part + transfer = one screen time + (time to the next edge, or the Auto timeout if there is none) + bytes ÷ link speed| Time/div | Screen | With a trigger (periodic signal) | No trigger (DC, Auto) |
|---|---|---|---|
| 1 ms | 10 ms | ≈ 15–40 /s | ≈ 15 /s |
| 10 ms | 100 ms | ≈ 5–9 /s | ≈ 6 /s |
| 20 ms | 200 ms | ≈ 3–5 /s | ≈ 3 /s |
| 50 ms | 500 ms | ≈ 1.5–2 /s | ≈ 1.2 /s |
That is why slow time bases feel sluggish in block mode, and why bench scopes switch to roll mode there: in roll mode samples stream continuously and the screen is redrawn about 25 times per second with whatever has arrived, so nothing waits for a full screen. The link speed hardly matters: a 1000-point capture takes about 22 ms on the wire at 921 600 baud, small next to the screen time. The status bar's frames/s is counted over one second and disappears below one frame per second.
3.5 Timing accuracy
- DMA engine: the ADC is clocked by hardware: 160 MHz ÷ (32 × N) per conversion, from the board's crystal. There is no software timing in the sample clock, so no interrupt jitter. Whether every conversion arrives is checked by the start-up probe (section 3.6) and during each capture (lost results set the GAP flag).
- analogRead engine, block mode, not SLOW: the sample clock is the CPU cycle counter (240 MHz from the board's crystal). The average interval is as accurate as the crystal (typically tens of ppm). Each sample waits for its exact cycle count, so errors do not accumulate, but an individual reading can be delayed when an interrupt runs (USB/serial, system tick). That delay has not been measured yet: verification test D3 checks it.
- Block mode, SLOW: the interval is the measured average over the capture (elapsed µs ÷ points).
- Roll mode: samples are scheduled on the 1 µs system timer and the browser assumes ideal spacing. A sample can be late by up to the time the loop spends sending a chunk.
- Text streams: every line carries its own timestamp (ScopeProbe: microsecond timer at the moment of reading), so timing is as good as the sketch's clock.
3.6 The DMA engine (firmware 1.4.0 and later, Arduino core 3.x)
With analogRead() the CPU starts every conversion and waits for it, about 41 µs each (21.6 kSa/s on one channel). The ESP32 can also convert continuously in hardware: the SAR ADC's digital controller is clocked by the I2S0 peripheral, and the results go to memory by DMA while the CPU only processes them. The firmware uses ESP-IDF's continuous-mode driver (esp_adc/adc_continuous.h) for this. Acquire → ADC selects the engine: DMA (fast) or analogRead. Both use 12 bits and 11 dB attenuation and the same calibration table. Arduino core 2.x (ESP-IDF 4.4) has a different, older driver and keeps the analogRead engine only.
What the ESP-IDF 5.5 source and published reports establish
- Sample clock. On the ESP32 the driver sets the I2S master clock to 32 × the sample rate F, divided from the 160 MHz PLL with a fractional divider. The firmware only uses F = 5 MHz ÷ N for whole numbers N (250 … 3: 20 kSa/s … 1.667 MSa/s), where the divider is exact, so there is no fractional-divider jitter. The driver accepts 20 kSa/s to 2 MSa/s.
- Data format. Each conversion is a 16-bit word: bits 15…12 = ADC1 channel number, bits 11…0 = code. The channel tag lets the firmware check that every result belongs where it expects it.
- Word order. In 16-bit mono mode the ESP32's I2S stores each pair of 16-bit words swapped, and the silicon cannot change that (Espressif staff on the ESP32 forum). The driver configures this mode and does not reorder. Undone pairs would put every other sample in the wrong place, which looks like jagged steps on fast edges. The probe below detects the order from the channel tags; the firmware swaps the pairs back.
- Lost conversions. The ESP32's ADC controller has a "conversion limit" that made early ESP-IDF 5 versions skip conversions (2 out of every 11; esp-idf issue 10612). The fix (in ESP-IDF 5.5, used by Arduino core 3.3.x) clears the limit 60 µs after starting. The probe measures the delivered rate, which would show any loss that remains.
- Conversion speed. The driver runs the SAR clock at 80 MHz ÷ 16 = 5 MHz. How many conversions per second that sustains on the ESP32 is not documented clearly, and published reports disagree (from about 1 MSa/s to failures above 1.3 MSa/s). This is why the firmware measures it. On the test board it was 250 kSa/s, i.e. 20 SAR clock cycles per conversion: at 500 kSa/s and above the requested rate was still delivered, but 50–83 % of the results were repeats of the previous channel (conversions that had not finished), so those rates fail. Lowering the driver's SAR clock divider might be faster, but its accuracy is unknown and the firmware does not do it.
Start-up probe
At start-up (about 0.5 s) the firmware runs a three-channel pattern (GPIO 36, 39, 32; nothing needs to be connected) at each of 40 k, 100 k, 250 k, 500 k, 1 M, 1.25 M and 1.667 MSa/s (a rate whose start delivers nothing within 100 ms is started once more), and records:
- delivered rate: results received over at least 10 conversion frames ÷ the time they took;
- bad results: channel tags that are not in the pattern;
- repeated results: the same channel twice in a row. With a three-channel pattern this cannot happen if every conversion completes, so it shows conversions the ADC did not finish in time;
- overflows of the driver's buffer, and which word order (raw or pair-swapped) makes the tags follow the pattern.
A rate passes when the delivered rate is within 2 % of nominal, with fewer than 1 % bad and 1 % repeated results and no overflow. The engine's maximum is the fastest rate up to which every rate passed. The result is in the hello frame (dma, section 10.3) and in a text line in the log, for example, from the test board: dma probe: 40000:ok 100000:ok 250000:ok 500000:FAIL(rate 500000 dup 500 bad 0) … -> max 250000 Sa/s, words swapped (dup and bad are per thousand). If no rate passes, the DMA engine is off and the ADC selector is disabled.
From conversions to points
For the point rate the browser asks for, the firmware chooses N (ADC rate) and D (conversions per channel per point) so that N × D × Nch ≈ 5 MHz ÷ rate, within 0.2 % where possible; the frame header carries the exact point interval N × D × Nch ÷ 5 MHz, and the reply to CFG reports F and D.
| Acquire mode | ADC rate chosen | Point value |
|---|---|---|
| Normal | The slowest that gives the point rate (largest N), but never below 40 kSa/s (N ≤ 125; see the start failures below) | The first conversion of each group of D. Like sampling at the point rate: aliasing behaves as on any sampling scope. |
| Hi-Res | The fastest (smallest N) | The average of all D conversions, in millivolts (1.4.5): noise falls by about √D, and content faster than the point rate is averaged away. |
| Peak | The fastest | The smallest and largest of the D conversions (every conversion is inspected; nothing between points is missed at the ADC rate). |
| Average | As Normal | As Normal; the browser averages successive captures. |
Examples, one channel, probe maximum 250 kSa/s (N = 20 or more), worked out with the firmware's planning loop:
| Request | N | ADC rate | D | Point rate |
|---|---|---|---|---|
| Normal, 5 µs/div (fastest) | 20 | 250 kSa/s | 1 | 250 kSa/s exactly |
| Hi-Res, 1 ms/div (1000 points → 100 kSa/s) | 25 | 200 kSa/s | 2 | 100 kSa/s exactly |
| Hi-Res, 10 ms/div (10 kSa/s) | 20 | 250 kSa/s | 25 | 10 kSa/s exactly |
| Roll Hi-Res, 2 kSa/s | 20 | 250 kSa/s | 125 | 2 kSa/s exactly |
| Roll Normal, 2 kSa/s | 125 | 40 kSa/s | 20 | 2 kSa/s exactly |
| Normal, 10–100 ms/div (Memory auto: 23.04 kSa/s) | 31 | 161.3 kSa/s | 7 | 23 041 Sa/s (0.01 % fast) |
| Normal, 5 ms/div (27.64 kSa/s) | 90 | 55.6 kSa/s | 2 | 27 778 Sa/s (0.5 % fast: 181 is prime, so no exact pair under the floor) |
| Normal, 138.2 kSa/s (deep memory at 1 ms/div) | 36 | 138.9 kSa/s | 1 | 138.9 kSa/s (0.5 % fast: the nearest exact rate) |
Losses during a capture
Each capture discards the first 64 results after starting the ADC. If results are lost before the trigger (driver buffer overflow, or a channel tag out of sequence), the capture restarts, up to three times; after that, or after the trigger, the frame is sent with the GAP flag and the browser writes a line in the log. In roll mode the point counter is reset from the clock after a loss, so the time axis stays correct, and the chunk carries the GAP flag.
Start failures at slow ADC clocks (firmware 1.4.3)
On the test board the DMA engine stopped after a few captures at 10 ms/div and slower (firmware 1.4.0–1.4.1); the capture then waited for ever, in Auto too. Measured with firmware 1.4.2 (every stall logged): the ADC sometimes does not start at all after adc_continuous_start() (0 results, every time), and how often depends on the ADC clock and on how long the ADC was idle before (the frame transfer):
| ADC clock | Short captures (1000 points, ADC idle ≈ 20 ms) | Long captures (0.5 s, idle 0.1–0.5 s) |
|---|---|---|
| 20.0 kHz | 48 % of starts | — |
| 20.8 kHz | 32 % | — |
| 21.7 kHz | 0.4 % | — |
| 23.0 kHz | 0 of 710 | 76 % (3–11 % in the D2 runs) |
| 27.6 kHz | 0 of 850 | 0 of 112 (0 of 299 at 5 ms/div) |
| 31–100 kHz | 0 of 4800 | 0 of 413 (33, 40, 50 kHz) |
So firmware 1.4.3 never runs the ADC below 40 kSa/s: slower point rates take every D-th conversion (table above), which keeps the timing exact. The start-up probe begins at 40 kSa/s and retries a rate once if its start delivers nothing. With 1.4.3 the same D2 test ran 1320 captures at 5–100 ms/div with no stall. Why the chip fails at slow clocks is not known; it is close to the driver's 20 kSa/s minimum.
No-data watchdog (firmware 1.4.2)
The watchdog stays as a safety net. The firmware treats 10 conversion frames without a result (at least 100 ms) as a stall and recovers in steps, each written to the log as dma: no results for … ms (…, F=… Hz, N results so far); step [total]:
| Stalls in a row | Action |
|---|---|
| 1, 2 | Stop and start the ADC; the capture starts again (roll: continues after a GAP) |
| 3 | Load the configuration again |
| 4 | Delete and recreate the driver |
| 5 | Switch to analogRead and report err dma: … (a toast). Any new setting from the browser tries DMA again. |
A good capture resets the count. N results so far tells the two cases apart: 0 = the ADC did not start delivering; more = it stopped partway.
Hardware results
On the test board (ESP32-D0WD, Arduino core 3.3.12, firmware 1.4.0): the probe gave 250 kSa/s with swapped word pairs in three runs (B4); DC readings agreed with the analogRead engine (C3d); a 10 kHz square read 10.00 kHz (σ 0) and 50 % duty with clean, in-order samples, and its Rise read 3.2 µs = 0.8 sample intervals, which is what an edge faster than one sample gives (D6). Your chip may differ, so the probe stays. The ADC's analogue input has since been measured (firmware-independent test, 2026-11-27): see section 11.
3.7 Equivalent-time sampling (ETS, app 1.7.0; drift following 1.8.0)
Concepts: equivalent-time sampling in Oscilloscope fundamentals.
Acquire → ETS rebuilds one period of a repeating signal from many periods of one long record. Everything is done in the browser (js/dsp.js: etsPeriod, etsFold, etsBins, etsAlign, etsSpread); the firmware is unchanged. Self-test group "Equivalent-time sampling" checks it against exact synthetic signals.
- Record. CFG with rate = DMA maximum ÷ Nch and points = memory ÷ Nch (one channel: 250 kSa/s, 24 000 points, 96 ms), whatever the time base. Trigger mode as set (Auto/Normal/Single); pre-trigger 50 %. Records with lost samples (F_GAP) are not folded.
- Crossings. On the trigger source: every crossing of the trigger level in the trigger direction (Both = rising), armed below level − h, h = 15 mV (60 mV with Noise reject) at the pin, interpolated linearly between the two readings around the crossing. Fewer than 2 → level outside; fewer than 21 → too few periods.
- Coarse period. Median gap m between crossings; m < 2.5 readings → signal too fast. P₀ = mean of the gaps within 0.6 m … 1.4 m (missed or extra crossings excluded).
- Line fit. Each crossing gets a cycle number k = round((c − c₀) ÷ P₀); least-squares line c = a + P·k, refitted once without crossings more than max(3σ, 0.75 readings) off. Residual σ ≥ 0.25 P → not repeating. Standard error of P: sP = σ√(12/N) ÷ (klast − kfirst).
- Refinement. 4 rounds of 33 candidate periods within ±max(6 sP, 0.2 ppm × P), shrinking ×6 per round, scored by the within-bin variance per degree of freedom of the folded record (B = n ÷ 8, 64 … 2048 bins): Σbins Σ(v − mean)² ÷ (n − filled bins). Candidates are tried from the centre outwards and must be better by a factor 1 − 10⁻⁶ to win, so a noise-free locked signal keeps its measured period. The search is kept narrow because slow drift in a record otherwise pulls a locked signal to a period that spreads its readings.
- Repeat check. All readings sorted by phase; spread = 1.4826 × median |difference of neighbours| ÷ √2 (≈ the RMS noise if the signal repeats; edges are ignored by the median). Spread > 6 mV and > 0.25 × the record's AC RMS → not repeating (picture still drawn).
- Bins. If P is a whole number R of readings (|P − R| · n ÷ P < ½: the readings sit on exactly R places), B = R: the real readings, reordered. Otherwise: wanted bins per period = 2000 × T ÷ Tscreen, at least ⌈P⌉ (never coarser than the real readings), at most n ÷ 4, rounded up to even; reduced in steps of 0.8 until ≥ 95 % of the bins receive a reading (
etsBins, pure arithmetic on frac(k ÷ P)); an odd result is lowered by one. Why even: the folded record is the period sampled at B points, so harmonic h of the signal also appears at |h − mB|; with B odd a square wave's odd harmonics land on even ones (1.11.0 at 10 013 Hz, 2 ms/div, B = 25: false 2nd/4th/6th harmonics −41 / −35 / −31 dBV; 1.11.1, B = 26: −47 dBV), and with B = R + 1 one interpolated bin did the same (1000 Hz: −41.7 → −86 dBV). The finest fillable count for n ÷ 4 decides locked, little gain: fewer than 3 × P positions per period. - Drift following (1.8.0). A source with an RC oscillator (the board's DAC sine, a 555) does not keep one period for 96 ms (100–250 ppm seen), which smears a fold made with one P.
etsTrack: cycle numbers from the gaps between crossings (gaps that are not a whole number of periods ± 0.3 are skipped); each crossing time is replaced by a straight-line fit through its 13 nearest neighbours (±6, averaging the noise of single interpolated crossings); a reading between two smoothed crossings gets the matching fraction of that cycle, and its phase is the fractional part.etsDriftfolds the record both ways (B = n ÷ 8 bins, within-bin variance per degree of freedom) and uses the tracked phases only if their spread is below 0.7 × that of the single period; a steady square wave (edges faster than the readings make single crossings meaningless) always stays on one period (tracked / single spread 105–107 × on the recorded squares). The Acquire line reports the frequency change between the first and last quarter. The repeat check, bin count and fold below then use the tracked phases (a channel's skew is added as skew ÷ P cycles). Test board, DAC sine 5 / 20 / 50 / 100 kHz: neighbour spread 10 / 26 / 35 / 55 mV → 2 / 4 / 7 / 13 mV; bin spread 20 / 81 / 130 / 95 mV → 10 / 13 / 18 / 26 mV. - Fold. Reading k of channel slot s goes to bin ⌊B · frac((k + s · skew ÷ Δt) ÷ P)⌋; each bin shows the mean of its readings; empty bins are interpolated linearly between their neighbours.
- Align and draw. On the folded source: from its lowest bin (highest for falling) forward to the first crossing of the level, interpolated: that phase is t = 0 (none → level outside, status Auto). The period is repeated across the screen on a uniform grid of step T ÷ B (shown as Sa = B ÷ T, marked ETS). Above 300 000 points (time base far slower than the period) the plain record is shown instead.
Limits: repeating signals only; ≥ 20 periods per record (≳ 210 Hz); below half the sample rate (the period is measured from the readings, so an aliased signal is folded at its alias period without warning; refused below 2.5 readings per period); edges no faster than the input RC; jitter widens edges by about its own size; 1–2 updates per second; DMA engine only.
Measured on the test board (GPIO25 → 1 kΩ → GPIO34, one channel, 250 kSa/s, app 1.7.0–1.8.0). Square waves from the generator:
| Signal | Period found | Step | Rise 10–90 % | Status |
|---|---|---|---|---|
| Normal mode, 20.011 kHz, 5 µs/div | — | 4 µs (real) | 3.2 µs (one jump) | — |
| ETS, 20 011 Hz | 49.975 µs (20.0100 kHz), ±0.2 ppm record to record | 25 ns | 26.7–27.9 ns | Trig'd |
| ETS, 30 901 Hz, 100 ns/div | 32.363 µs (30.900 kHz) | 10.5 ns | 27.2 / 32.2 ns | Trig'd |
| ETS, 19 391 / 15 451 Hz | 26 ns | 33.5 ns | Trig'd | |
| ETS, 10 013 Hz | 39 ns | 31 ns | Trig'd (near-locked) | |
| ETS, 50 021 Hz | 19.988 µs (50.031 kHz) | 25 ns | 40.5 ns | Trig'd |
| ETS, 2 011 Hz | 83 ns | 193 ns (bin-limited) | Trig'd | |
| ETS, 10 000 Hz (exact) | 100.000 µs | ≈ 4.5 µs (22 positions) | — | locked, little gain |
| ETS, 50 000 Hz (exact) | 20.000 µs | 5 positions | — | locked, little gain |
| ETS, 21 737 Hz | 46.000 µs (21 739.1 Hz = 2/23 of 250 kHz) | 20 positions | — | locked, little gain |
Sine from the DAC (amplitude ±0.8 V, firmware 1.5.0, app 1.8.0):
| Requested | Frequency found | Readings per period | Normal: Pk-Pk | ETS: Pk-Pk | Neighbour spread, one period → drift following | Bin spread (offline) |
|---|---|---|---|---|---|---|
| 1 kHz | 914.5 Hz | 273 | 1.593 V | — | 2.1 mV (not always tracked) | — |
| 5 kHz | 4 962.5 Hz | 50 | — | 1.568 V | 10 → 2.1 mV | 20 → 10 mV |
| 20 kHz | 19 984 Hz | 12.5 | — | 1.568 V | 26 → 4.1 mV | 81 → 13 mV |
| 50 kHz | 49 901 Hz | 5.0 | 1.465 V (peaks missed) | 1.565 V | 35 → 7.2 mV | 130 → 18 mV |
| 100 kHz | 99 945 Hz | 2.50 | — | 1.552 V | 55 → 13 mV | 95 → 26 mV |
| 120 kHz | (≈ 119.9 kHz expected) | < 2.5 | — | refused: "signal too fast" | — | — |
Drift of the DAC's RC oscillator within one 96 ms record: 100–290 ppm (later records +21, +48, −117, −159 ppm), wander 230–450 ns RMS. DAC mid-scale glitch: 0.2–0.3 V deep, ≈ 0.3–0.5 µs wide, once per cycle on the falling half (raw 1 kHz readings −376 / −209 / −325 mV at phase 0.500). Steady squares are never tracked (tracked/single fold spread 105–107, or ≈ 1).
4. Measurements
Concepts: automatic measurements in Oscilloscope fundamentals.
4.1 Definitions
All measurements use the displayed samples (section 2) that lie inside the screen's time window: v1 … vn at times t1 … tn. Gaps (NaN) are skipped. Source code: DSP.measure in js/dsp.js.
| Name | Formula / method | Unit |
|---|---|---|
| Max, Min | Largest and smallest sample. | V |
| Pk-Pk | Max − Min. | V |
| Mean | (1/n) Σ vi. Each sample counts equally (assumes even sample spacing, which holds in block and roll mode). | V |
| RMS | √( (1/n) Σ vi² ). Includes the DC part. | V |
| AC RMS | √( (1/n) Σ vi² − Mean² ). The RMS of the signal with its DC removed (the population standard deviation). For a sine of amplitude A: A / √2. | V |
| Top, Base | A histogram of the samples is made with 100 equal bins between Min and Max. Top = average of the samples in the fullest bin of the upper half, provided that bin holds at least 3 × the average count of the upper-half bins (i.e. there is a clear flat level). Otherwise Top = Max. Base: the same for the lower half, otherwise Min. | V |
| Amplitude | Top − Base. | V |
| Edges (used below) | Crossings of the middle level m = (Top + Base)/2, with hysteresis h = max(10 % of Amplitude, 2 % of Pk-Pk): an edge counts only after the signal has gone past m ± h. The crossing time is interpolated linearly between the two samples around m. | — |
| Period | (last rising edge − first rising edge) ÷ (number of rising edges − 1); falling edges are used if there are fewer than two rising ones. Needs at least two edges of the same kind on screen, so show two or more periods. | s |
| Frequency | 1 / Period. | Hz |
| +Width | Average time from each rising edge to the next falling edge (only pairs closer than 1.5 periods). | s |
| −Width | Period − +Width. | s |
| Duty | +Width ÷ Period. | % |
| Rise | Time from the first upward crossing of Base + 10 % × Amplitude to the following crossing of Base + 90 % × Amplitude (first edge on screen only). For an RC charge that settles fully: τ × ln 9 ≈ 2.197 τ. If the voltage does not settle (half-period shorter than about 5 τ), Top and Base are not the final levels and the result is shorter. | s |
| Fall | The same from 90 % down to 10 %. | s |
| Area | Σ ½ (vi + vi−1) (ti − ti−1): the integral ∫ v dt across the screen by the trapezoid rule. Area below 0 V counts negative. | V·s |
For math channels the unit is the channel's unit (for example A instead of V, A·s for Area).
4.2 Statistics and readout rate
With Statistics ticked, each measurement also shows, over many acquisitions:
| Symbol | Meaning |
|---|---|
| μ | Mean of all values so far. |
| σ | Sample standard deviation: √( Σ (x − μ)² / (n − 1) ). How much the reading scatters from one acquisition to the next. Roughly two thirds of readings fall within μ ± σ if the scatter is random. |
| min, max | Smallest and largest value so far. |
| n | Number of values. |
- One value is added per new acquisition in block mode, and per screen update with new data in roll and text modes.
- The statistics restart by themselves whenever something that changes the numbers changes: time/div, position, channel or math settings, acquisition mode, trigger, source. Reset restarts them by hand. Nothing is added while stopped.
- The mean and σ are computed with Welford's running method, which stays accurate over millions of values.
Readout rate sets how often the numbers on screen refresh: live (every update), 4 per second (default) or once per second, as on a bench scope. Only the display is slowed: statistics still collect every acquisition, and a stopped scope updates immediately.
4.3 Why Max and Min jump, and what to use instead
Max and Min are single samples: the most extreme reading in the capture. Every capture contains different noise, so the most extreme sample changes every time, and with the ESP32's few millivolts of noise and occasional DNL steps these numbers move constantly. Bench scopes behave the same way. That is expected, not a fault. Options:
- For the level of a pulse or square wave, use Top, Base and Amplitude: they come from the most common levels and ignore spikes.
- For a steady reading, tick Statistics and read μ. σ tells you how much a single reading can be trusted.
- To reduce the noise itself: Acquire Hi-Res (any signal) or Average (repetitive, triggered signals), or BW limit. These make Max/Min steadier because they remove the noise that causes the jumps.
- Use Max/Min when you want the extremes: overshoot, spikes, worst-case ripple, ideally with Acquire Peak.
5. Math channel language
A math channel (M1–M4) evaluates one expression for every sample index i of the record, producing a new trace. Constants are evaluated once. Source: DSP.compileMath and DSP.parseConstants in js/dsp.js. Every function below is checked by the self-test.
5.1 Names
| Name | Value at sample i | Unit |
|---|---|---|
v1 … v4 | Displayed value of CH1–CH4 (after probe, invert, BW limit and coupling). | channel unit |
dv1 … dv4 | Time derivative dv/dt of that channel (section 5.4). | unit / s |
iv1 … iv4 | Running integral ∫ v dt, zero at the left edge of the screen (section 5.4). | unit · s |
t | Time of the sample in seconds. 0 = the trigger point (block mode and triggered text streams), the newest sample (roll mode), or the frozen reference (stopped). | s |
m1 … m3 | Result of an earlier math channel: M2 may use m1; M4 may use m1–m3. | that channel's unit |
freq1, pp2, mean3, freq_m1 … | Live readings: the numbers of the Measure list, as a constant for the whole record (section 5.8). | that reading's unit |
PI, pi, E | π = 3.14159…, e = 2.71828… | — |
| your constants | From the constants box (section 5.5). | — |
A channel that is not recorded (switched off and not the trigger source; a hidden trigger source is still recorded and keeps its values), or has no data, reads as NaN ("not a number"), and NaN results are simply not drawn. Names are case-sensitive: V1 and e are unknown.
5.2 Numbers and operators
Numbers: 12, 1.5, .5, 1e-3, 2.2E6. There are no SI suffixes: write 10e3, not 10k.
| Priority | Operators | Meaning |
|---|---|---|
| 1 (first) | ( ), f(…) | Brackets, function calls |
| 2 | ^ or ** | Power. Groups from the right: 2^3^2 = 29 = 512. |
| 3 | -x, +x, !x | Negative, positive, not. A minus directly in front of a power is ambiguous and is rejected: write -(v1^2) or (-v1)^2. |
| 4 | * / % | Multiply, divide, remainder (7 % 3 = 1). Division by zero gives Infinity, which is not drawn. |
| 5 | + - | Add, subtract |
| 6 | < <= > >= | Comparisons: result 1 (true) or 0 (false) |
| 7 | == != | Equal, not equal (exact; rarely useful with measured values) |
| 8 | && | And |
| 9 | || | Or |
| 10 (last) | c ? a : b | If c is non-zero then a, else b. Example: v1 > 1.65 ? 3.3 : 0 (a comparator). |
Write the multiplication sign: 2*v1, not 2v1 or 2 v1 (both are rejected).
5.3 Functions
Angles are in radians (multiply degrees by PI/180).
| Function | Result | Example |
|---|---|---|
sin(x) cos(x) tan(x) | Sine, cosine, tangent | sin(PI/2) = 1 |
asin(x) acos(x) atan(x) | Inverses (radians). asin/acos need −1 ≤ x ≤ 1, otherwise NaN. | atan(1) = 0.785 |
atan2(y, x) | Angle of the point (x, y), −π … π. Use it for phase from two signals. | atan2(1, -1) = 2.356 |
sinh cosh tanh | Hyperbolic functions | cosh(0) = 1 |
exp(x) | ex | exp(-t/tau): an RC decay |
log(x) | Natural logarithm ln x (not base 10!) | log(E) = 1 |
log10(x) log2(x) | Base-10 and base-2 logarithms | log10(1000) = 3 |
sqrt(x) cbrt(x) | Square root (NaN below 0), cube root (keeps the sign) | cbrt(-27) = −3 |
abs(x) | |x|. Full-wave rectifier: abs(v1) | abs(-2.5) = 2.5 |
sign(x) | −1, 0 or 1 | sign(-3) = −1 |
floor(x) ceil(x) | Round down / up to a whole number | floor(-2.5) = −3 |
round(x) | Nearest whole number; halves go up (towards +∞) | round(-2.5) = −2 |
trunc(x) | Drop the fraction (towards zero) | trunc(-2.7) = −2 |
min(a, b, …) max(a, b, …) | Smallest / largest of any number of arguments | max(v1, v2) |
pow(x, y) | xy (same as x^y) | pow(2, 10) = 1024 |
hypot(a, b, …) | √(a² + b² + …) | hypot(3, 4) = 5 |
clip(x, lo, hi) | x limited to lo … hi | clip(v1, 0, 3.3) |
sq(x) | x² | sq(v1)/R: power |
db(x) | 20 · log10 |x|: a voltage ratio in dB. For a power ratio use 10*log10(x). | db(v2/v1): gain |
step(x) | 1 if x > 0, otherwise 0 (also 0 at x = 0) | 3.3*step(t): a step at the trigger |
5.4 Derivative and integral
Concepts: the derivative and the integral in Oscilloscope fundamentals.
dv/dt (dv1 … dv4) is the slope of the straight line that best fits (least squares) the samples i − w … i + w, where w is the d/dt window setting (1–64 samples, default 3):
- Exact for straight lines and parabolas (the self-test checks this).
- At the first and last w samples of the record the window is cut short, so those values are less accurate.
- The window is a number of samples, so its length in time is 2w × sample interval and changes with time/div.
- It smooths. For a sine wave whose period is P, the derivative comes out low by about 0.3 % when the window spans 5 % of P, 1.1 % at 10 %, 4.4 % at 20 % and 9.6 % at 30 %. Keep the window under a tenth of the fastest period you care about.
- It amplifies noise. The derivative of noise grows as the sample spacing shrinks: random noise of σ volts gives roughly σ / (dt · √(Σk²)) volts per second, where Σk² = w(w+1)(2w+1)/3. Going from w = 1 to w = 8 reduces it about 14 times. Use Hi-Res, a wider window, or measure current through a resistor instead.
∫ v dt (iv1 … iv4) is the running sum by the trapezoid rule, shifted so it is exactly 0 at the left edge of the screen:
- Integrating averages noise away, so integrals look smooth. But any offset error integrates into a steady slope: an error of 10 mV integrates to 10 mV·s per second.
- With AC coupling the screen mean is removed before integrating, which removes that drift (and also any real DC part).
- Gaps (NaN) contribute nothing.
5.5 Constants
R = 10e3 // ohms C = 100e-9 # farads (both comment styles work) tau = R * C // may use earlier constants, functions, PI and E f = 1 / (2 * PI * tau)- One
name = expressionper line (or separated by;), evaluated top to bottom. - Names: letters, digits and _; must start with a letter or _. They cannot use
t,v1or any other per-sample name. - Reserved (rejected as constant names): every function name,
PI pi E t i n,v1…v4,dv1…,iv1…,m1…m4, and every live-reading name (freq1,pp_m2… section 5.8). The constants are evaluated once and cannot use live readings; put the reading in the formula instead. - The constants are shared by all four math channels.
5.6 Units and scaling
The Unit box is only a label: the scope never converts units. With one of the base units V A W s Hz Ω F H C J V·s A·s V/s A/s W·s the readout adds SI prefixes automatically (0.00021 A → 210 µA). Any other text (mA, rpm, °C) is shown with the number as calculated. So either compute in base units ((v2-v1)/R, unit A) or include the factor yourself ((v2-v1)/R*1000, unit mA). Fit scale picks a 1-2-5 scale and position that fits the trace on screen.
5.7 Error messages
| Message | Cause |
|---|---|
| unexpected "…" | A character that is not part of the language (for example [, =, µ). |
| unknown name "…" | Misspelt variable or constant, or a constant that isn't defined. |
| unknown function "…" | Not in the list in 5.3. |
| empty expression | The channel is on but its formula box is empty. |
| use brackets around powers, e.g. -(v1^2) | A minus sign directly before a power. |
| syntax error (missing operator or bracket?) | Two values without an operator (2 3, 2v1), unbalanced brackets, a dangling operator. |
| mN can only be used by later math channels | For example m2 inside M1 or M2. |
| "freq_m2" (a reading of M2) can only be used by later math channels | The reading of a math channel is available only to channels after it (pp_m1 may be used by M2–M4, not by M1). |
| "pp1" is a live reading: use it in a math expression, not in the constants | A live reading was written in the constants box. Move it into the formula (5.8). |
| constants: … | A problem in the constants box; the message names the line. |
5.8 Live readings
Concepts: using the scope's own measurements in a formula (fundamentals). Source: DSP.measName in js/dsp.js, called from processRecord in js/scope.js.
Every measurement of section 4.1 can be used by name in a math expression. The name is the reading followed by the source: a digit for CH1–CH4, or _m and a digit for M1–M4. So freq1 is the frequency of CH1, pp3 the peak-to-peak of CH3 and acrms_m2 the AC RMS of M2.
| Measurement (4.1) | Name | Unit |
|---|---|---|
| Max, Min, Pk-Pk, Mean, RMS, AC RMS, Top, Base, Ampl | max1 min1 pp1 mean1 rms1 acrms1 top1 base1 amp1 | unit of the source |
| Freq, Period | freq1 period1 | Hz, s |
| +Width, −Width, Rise, Fall | pwidth1 nwidth1 rise1 fall1 | s |
| Duty | duty1 | a fraction from 0 to 1 (the Measure list shows it as %) |
| Area | area1 | unit of the source · s |
The same names exist with 2, 3 and 4 for CH2–CH4, and with _m1 … _m4 for M1–M4 (freq_m1). Names are case-sensitive.
- One value for the whole record. The reading is computed over the part of the record that is on the screen (the same data as the Measure list, with the same definitions, including channel coupling, probe, invert and BW limit), once per acquisition, and is then a constant for every sample of the formula. It is recomputed whenever the picture is.
- Not a number means no trace. If a reading cannot be computed (a frequency needs at least two edges of the same kind on the screen; a channel that is not recorded, or has no data, has no readings; a hidden trigger source is still recorded and keeps its readings), it is NaN, and so is the result: nothing is drawn, and no error is shown, exactly as for
v3on a channel that is off. - Order. The readings of CH1–CH4 can be used by any math channel. The reading of a math channel (
_mK) can be used only by later channels, likemK(5.1), because it needs the finished trace. - Choosing the reading. For the amplitude of a sine use
pp1 / 2(exact for a clean sine; it grows with noise and spikes) oracrms1 * sqrt(2)(insensitive to spikes; exact for whole periods).amp1is Top − Base, which suits pulses: on a synthetic sine it came out 0.7 % below the true amplitude (4.1: Top is the most common value of the upper half, not the peak). - Time zero.
tis zero at the trigger point (5.1). A sine built asmean1 + pp1 / 2 * sin(2 * pi * freq1 * t + φ)has phase φ at the trigger. It coincides with a sine on CH1 when the trigger fires on a rising edge at the mean level; for another level or slope it starts with a fixed offset. - Accuracy. Each value is exactly the number shown in the Measure list. In the self-test a sine measured over 3 000 points and rebuilt this way agrees with the ideal phase-shifted sine to better than 10 mV (the measurement's own error: the window does not hold a whole number of periods).
6. Cursors, FFT and display details
Concepts: cursors, the spectrum and drawing in Oscilloscope fundamentals.
- Time cursors report tA, tB, ΔT = tB − tA, 1/ΔT, and every trace's value at A and B (linear interpolation between samples).
- Level cursors report a, b and Δ = b − a on the chosen trace, in its unit.
- FFT: the on-screen samples of one trace (up to 16 384, the newest if more), mean removed, multiplied by a Hann window, zero-padded to a power of two N. The level of each frequency bin is the sine's RMS value in dBV (0 dBV = 1 V RMS): amplitude = 2·|Xk| / Σw, RMS = amplitude/√2. The DC bin shows the removed mean; the top bin (exactly half the sample rate) is neither doubled nor divided by √2, because a line there is sampled as ±amplitude (fixed in 1.11.1: it read 3 dB high). Bin spacing Δf = sample rate / N. A sine that falls between bins reads up to 1.4 dB low in the drawn spectrum (the Hann window's "scalloping loss"), and a bin centre is up to ½ bin from the tone. Text streams are resampled to a uniform grid of at most 16 384 points (more are thinned without filtering).
Peak readout: the strongest bin k from bin 2 up to the end of the visible span; "peak —" when it is below −150 dBV (flat signal). Since 1.11.2 the label is corrected between bins (DSP.peakInterp): with q = samples used ÷ N (zero padding), the Hann lobe |W(x)| = |sin πx ÷ (πx (1 − x²))| gives, for a tone at k + d (|d| ≤ ½), the ratio |X[k+1]| ÷ |X[k−1]| = W((1 − d) q) ÷ W((1 + d) q); d is solved from the measured ratio (bisection), frequency = (k + d) Δf, level = bin k − 20 log₁₀ W(d q). Simulation, one sine, 1000 … 16 384 points: within 0.002 bin and 0.01 dB (the single bin: 0.5 bin, 1.4 dB). Falls back to bin k when the tone is below 2 cycles (k q < 2: its mirror at −f leaks in), at the ends, near the −150 dBV floor, when a neighbour is higher than bin k, when no tone fits the ratio, or when bin k against its stronger neighbour misses the fit by more than 2 dB (two close tones, noise). The ▼ marker is drawn at the corrected point. Warnings (⚠, 1.11.1; meanings in the user guide §6.9): <2 cycles: frequency unreliable when bin 1 is within 3 dB of the peak or the peak completes less than 1.5 cycles in the window; last 16384 of n pts only; thinned to 16384 pts, no filter (text stream); Avg: highs may read low (Acquire Average). Peak acquire: no spectrum (each point is a min/max pair; the midpoint of the pairs gave levels off by up to 11 dB on the test board). No source data (channel off, formula error, < 16 samples): the pane says so and shows no peak (before 1.11.1 the previous peak stayed). - Persistence keeps older traces and fades them out exponentially (time constant 0.25 s for Short, 1.5 s for Long) or never (∞). The canvas stores 8-bit transparency, where many tiny fade steps would get stuck at a faint grey, so the fade is applied in steps of at least 12 % and nearly transparent pixels are cleared every 0.5 s. Changing the persistence setting clears it.
- Lines vs dots: lines join samples with straight segments. They are not a reconstruction of what happened between samples. Use Dots to see the real samples.
7. ESP32-DSO firmware
Source: firmware/esp32-dso/src/main.cpp. Builds with Arduino-ESP32 core 2.x and 3.x; platformio.ini has three environments: esp32dev (default: official platform 8.x, Arduino core 3.3.x), esp32dev-core2 (core 2.0.17) and esp32dev-latest (pioarduino, core 4.0.0 in Nov 2026). Upload uses only the default unless you pick another. Version 1.1.0 was built and run on hardware with core 3.3.12 (no errors or warnings, hello and calibration correct, analogRead 41.3 µs). Versions 1.2.1 to 1.4.0 build with all three cores without warnings; 1.4.0 was compiled and linked with each core's own toolchain and libraries (2.0.17 / ESP-IDF 4.4.7, 3.3.12 / 5.5.5, 4.0.0 / 6.1) with -Wall -Wextra. Its DMA engine (cores 3.x and 4.x) has been tested on a PC with a simulated ADC (firmware/esp32-dso/test, run with sh run.sh; needs g++ and Node.js), not yet on hardware. analogRead measured on one board: core 3.3.12 41.2 µs (fastest, hence the default), core 4.0.0 53.4 µs, core 2.0.17 127.2 µs.
| Setting (top of main.cpp) | Default | Meaning |
|---|---|---|
DSO_BAUD (in platformio.ini build_flags) | 921600 | Serial speed. monitor_speed only affects PlatformIO's own monitor; change both together, and the browser's Baud too (the browser warns if they differ). CH340/CH9102/CP2102N boards usually manage 2000000; the original CP2102 rounds requests above 921 600 down. |
ADC_PINS | 36, 39, 32, 33, 34, 35 | Pins accepted as inputs (ADC1 only: ADC2 cannot be used while Wi-Fi runs). |
GEN_PINS | 25, 26, 27, 4, 13, 14, 16–19, 21–23 | Pins accepted as generator output. Boot-strapping pins (0, 2, 5, 12, 15), flash pins (6–11) and the serial pins (1, 3) are excluded on purpose. |
MEM_WANT | 24000 | Capture memory in 16-bit values (halved until the allocation succeeds). |
STREAM_CHUNK | 128 | Points per roll-mode frame. A chunk is also sent after 40 ms even if not full. |
DMA_FRAME, DMA_POOL | 512, 32768 bytes | DMA engine: conversion frame (256 results; one interrupt each) and the driver's buffer between DMA and the processing loop (13 ms at 1.25 MSa/s). |
Start-up
- Serial at
BAUD, 12-bit ADC, 11 dB attenuation on all ADC pins. - Times 2000
analogRead()calls alternating GPIO 34 and 35 → tread. - Allocates capture memory, builds the calibration table from the eFuse values (scheme reported as
cal: two-point, efuse-vref, efuse (core 3 line fitting) or default if the chip has no calibration). - Core 3.x: opens the ADC continuous-mode driver and runs the DMA probe (about 0.5 s, section 3.6). The DMA engine becomes the default if it passed.
- Sends a hello frame, the table and the probe line, then waits for commands. It starts in block mode, one channel, but the browser always sends its own CFG first.
Behaviour
- While waiting for a trigger, any byte arriving on the serial port abandons the capture (checked about every millisecond), so new settings take effect at once. Once triggered, a capture always finishes.
- Each data frame carries the configuration id of the CFG it was made with. The browser ignores frames from older configurations.
- All generator pins stay as inputs (high impedance) until a GEN command arrives. The browser sends
GEN … mode=offafter every connection.
7.1 Signal generator
| Frequency | How | Accuracy |
|---|---|---|
| 0.01 Hz – < 100 Hz | Software timer (esp_timer) toggles the pin. Each edge is scheduled from the ideal time of the previous one, so errors do not add up over many periods. (Up to firmware 1.3.1 this range ended at 1 Hz; low LEDC frequencies reset some boards through the watchdog.) | Microsecond timer; edge jitter of some tens of µs, which is below 1 % of a period up to 100 Hz. |
| 100 Hz – 1 MHz | Hardware LEDC PWM timer. The frequency is rounded to whole hertz. | See below. |
The LEDC timer divides an 80 MHz clock by a number with 8 fractional bits, then counts 2res steps per period, so frequency and duty resolution trade against each other. The firmware chooses:
res = floor(log2(80 MHz / (16 · f))) if that is ≥ 8 (divider ≥ 16: frequency error ≤ 0.012 %) res = min(floor(log2(80 MHz / f)), 8) otherwise (above ≈ 19.5 kHz) res is limited to 1 … 14 (from 1.3.2; was 16); duty step = 100 % / 2^res. Duty 0 % or 100 %: constant level.| Frequency | res (bits) | Duty step | Worst frequency error from the divider |
|---|---|---|---|
| 1 – 76 Hz | 16 | 0.0015 % | < 0.01 % |
| 1 kHz | 12 | 0.024 % | 0 (divider 19.53125 is exact) |
| 10 kHz | 8 | 0.39 % | 0 (divider 31.25 is exact) |
| 100 kHz | 8 | 0.39 % | ≤ 0.06 % |
| 1 MHz | 6 | 1.6 % | ≤ 0.16 % |
The reply reports what the ESP32's LEDC driver says it set (actual=, whole hertz rounded down by the driver). The crystal adds its own error, typically ±10–30 ppm. For very low frequencies the driver may switch the LEDC to its 1 MHz reference clock; the table assumes the 80 MHz clock.
8. ScopeProbe library
Header-only: firmware/probe-example/lib/ScopeProbe/ScopeProbe.h. Copy the ScopeProbe folder into a project's lib/ folder (PlatformIO) or into Documents/Arduino/libraries/ (Arduino IDE).
| Function | Description |
|---|---|
bool ScopeProbe::begin({pins…}, hz = 100, oversample = 4, Stream &out = Serial) | Starts sampling. Pins: up to 4 of 32–39 except 37/38 (others are skipped). hz: 1–2000. oversample: 1–16 readings averaged per sample. Returns false if already running or no valid pin. Call Serial.begin() first. |
void ScopeProbe::mark("text") | Sends #mark text (up to about 70 characters): a flag on the time axis and a log entry. |
void ScopeProbe::pause() / resume() | Stop and restart sending. The timer keeps running. |
void ScopeProbe::end() | Stops and frees the timer and task. |
- An
esp_timerwakes a FreeRTOS task (priority 2, core 0, 4 kB stack) at the chosen rate. Yourloop()runs on core 1, sodelay()there does not disturb the probe. - Each sample: timestamp (µs timer), then for each pin
oversamplecalls toanalogReadMilliVolts(), averaged and rounded. Line format:12345.678,1650,812(ms with three decimals, then mV). - Every 5 seconds' worth of samples it repeats a header:
#scope time=ms units=mV rate=100 pins=34,35. - Throughput limit: each line is about 10 + 5 × pins bytes. At 115 200 baud (11 520 bytes/s) that is about 900 lines/s for one pin; at 921 600 baud about 7000. If the requested rate exceeds the link, lines queue up and the sketch slows.
- Your own prints: end each with a newline in the same call (
Serial.printf("…\n")), otherwise a probe line may be glued to your text and that line is skipped. Don't callanalogRead()on the probe's pins from your code at the same time.
9. Text protocol
Any program can feed the scope with lines of text ending in \n (a trailing \r is ignored). Each line is one of:
| Line | Example | Rule |
|---|---|---|
| Data | 12345.678,1650,812 | 2 to 5 numbers separated by commas, semicolons, tabs or spaces: time, then up to 4 values (CH1–CH4). Extra numbers are ignored. |
| Meta | #scope time=us units=V names=in,out | Starts with #. Keys: time = s | ms | us; units = V | mV; names = comma list. Other keys are ignored. |
| Header | ms,CH1_mV,CH2_mV | Separator-delimited words. The first column's name sets the time unit if it contains us/µs/micros, ms/millis, or is s/t/time; mV or V in the other names sets the value unit. |
| Mark | #mark motor on | A labelled flag at the time of the last data line (first 40 characters shown). |
| Anything else | Charging started | Shown in the log (at most about 3 lines per second) and otherwise ignored. |
- Default units when nothing says otherwise: time in ms, values in mV. The Data → Text time / values menus override everything, including data already received.
- If the time goes backwards (the board restarted), the recording starts again.
- Lines longer than 4096 bytes are cut. Samples need not be evenly spaced, but measurements weight each sample equally.
| Baud | Bytes/s | Text lines/s (1 value) | Binary samples/s (firmware) |
|---|---|---|---|
| 115 200 | 11 520 | ≈ 900 | ≈ 5 700 |
| 921 600 | 92 160 | ≈ 7 000 | ≈ 46 000 |
| 2 000 000 | 200 000 | ≈ 15 000 | ≈ 100 000 |
10. Binary protocol (ESP32-DSO firmware)
The link is a serial port at 921 600 baud, 8 data bits, no parity, 1 stop bit. The PC sends text commands; the ESP32 answers with binary frames. Text lines may also appear between frames (the ESP32's boot messages, at 115 200 baud, show up as garbage and are ignored). An independent Python implementation written from this section is in tools/dso_read.py.
10.1 Commands (PC → ESP32)
ASCII lines ending in \n or \r, at most 255 characters. Arguments are key=value pairs separated by single spaces, in any order. Keys that are left out keep their previous value; unknown keys are ignored.
| Command | Reply | Effect |
|---|---|---|
ID | H frame, then L frame | Identify: hello (JSON) and calibration table. |
CFG key=value … | ok cfg … or err … | Acquisition settings (table below). Applied at once and restarts the capture. |
RUN | ok run | Start acquiring. |
STOP | ok stop | Stop acquiring (the current capture is abandoned). |
SINGLE | ok single | Set mode = single and run. After one block (flag SINGLE_DONE) the firmware stops. |
FORCE | none | Trigger now (once the pre-trigger memory is full). |
GEN key=value … | ok gen … or err gen … | Signal generator (table below). |
PING | pong | Link check. |
| anything else | err unknown command | — |
CFG keys
| Key | Values | Meaning |
|---|---|---|
id | 0 – 65535 | Configuration id, copied into every data frame. |
ch | 1–4 pins, comma separated, e.g. 34,35 | Channels, in slot order. Only ADC1 pins; otherwise err pin N is not an ADC1 pin and nothing changes. |
rate | ≥ 0.5 (float) | Samples per second per channel. |
pts | 16 … memory ÷ (channels × 2 if peak) | Points per channel per block (clamped). |
pre | 0 … pts − 1 | Points before the trigger. |
mode | auto | normal | single | roll | Trigger mode, or continuous streaming. |
edge | r | f | b | Rising, falling, both. |
src | 0 … channels − 1 | Trigger source as a slot index (position in ch), not a pin number. |
lvl | integer | Trigger level as ADC code × 16. Example: 2048 × 16 = 32768 ≈ mid-scale. |
hys | integer | Hysteresis in code × 16 (the browser sends 240 ≈ 12 mV, or 1200 ≈ 60 mV with Noise reject). |
acq | normal | peak | hires | Acquisition (section 3.2). |
os | 1 – 64 | Accepted for compatibility. Since firmware 1.2.0 hires averages every reading in each point interval, however many that is. |
auto | ms | Auto-trigger timeout, counted from when the pre-trigger memory is full. Fixed: since firmware 1.4.1 it is no longer stretched to the spacing of real triggers (section 3.3). |
eng | dma | cpu | Acquisition engine (firmware 1.4.0). dma is used only if the start-up probe passed; otherwise the firmware uses cpu and says so in the reply. Without this key the engine stays as it was (DMA after a successful probe). |
Reply, analogRead engine: ok cfg id=7 nch=2 rate=20000.00 pts=400 pre=200 os=1 eng=cpu. DMA engine: ok cfg id=7 nch=1 rate=100000.000 pts=1000 pre=500 eng=dma F=1000000 D=10 (F = ADC conversions per second, D = conversions per channel per point). Either is followed by slow when the rate cannot be met. rate is the point rate that will really be used. (Before 1.4.0 the reply had no eng.)
GEN keys
| Key | Values | Meaning |
|---|---|---|
pin | one of GEN_PINS | Output pin. Others: err gen pin N not allowed. Changing the pin releases the old one (back to input). |
mode | off | high | low | pwm | sine | Off = input (high impedance). sine (firmware 1.5.0, core 3.x): cosine generator + DAC, GPIO25 (DAC channel 0) or GPIO26 (channel 1) only; err gen sine only on GPIO25 or GPIO26, err gen sine f must be 135 Hz ... 200 kHz, err gen sine needs Arduino core 3.x (nothing changes on an error). |
a | 0, 6, 12, 18 | Sine only: amplitude attenuation in dB (default 6). Measured peak amplitude on the test board: 0 dB ≈ ±1.6 V (clips in the ADC), 6 dB ±0.8 V, 12 dB ±0.4 V, 18 dB ±0.2 V; centre ≈ 1.62 V. |
o | −128 … 127 | Sine only: DC offset in DAC codes (default 0; the app does not use it). |
f | 0.01 – 1 000 000 | Frequency in Hz (clamped; whole Hz from 1 Hz up). |
d | 0 – 100 | Duty cycle in %. |
Replies: ok gen off, ok gen high pin=25, ok gen pwm pin=25 f=1000 d=25.0 res=12 actual=1000.000, ok gen pwm pin=25 f=0.500 d=25.0 (software) actual=0.500, ok gen sine pin=25 f=1000 a=6 o=0 (internal RC clock: frequency approximate). The sine's real frequency is n × ≈ 130.6 Hz (n = ⌊f ÷ 130.6⌋: 1 000 Hz gave 914.5 Hz, 5 000 → 4 962.5, 20 000 → 19 984, 50 000 → 49 901, 100 000 → 99 945). The app's Sine frequency field only offers n × 130.6 Hz (DSP.sineSnap: the nearest step, n = 1 … 1530) and sends the middle of the step, (n + ½) × 130.6 Hz, so that the board's ⌊f ÷ step⌋ still gives n if its step differs slightly. The step is a measurement on one board: other boards may differ, from an internal ≈ 8 MHz RC oscillator (about ±5 %, drifting by 100–250 ppm during a 96 ms record on the test board); it is independent of the ADC's crystal. The DAC output has a ≈ 0.3–0.5 µs, 0.2–0.3 V dip when its 8-bit code passes mid-scale on the falling half.
Steps measured on the test board (app 1.10.2; Frequency μ, ETS period, or for step 1530 the alias at 250 kSa/s, 250 000 − 50 179 Hz): step 1 130.60 Hz, 2 261.25, 7 914.64, 8 1 045.25, 10 1 306.61, 14 1 828.97, 38 4 965.0, 77 10 059, 153 19 990, 383 50 043, 765 99 968, 1530 199 821 Hz. Every step lies within +0.06 % of n × 130.6 Hz on this board, at the moment of measuring; the oscillator drifts, and another board's step can differ by several percent.
10.2 Frame format (ESP32 → PC)
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 1 | sync 1 | 0xA5 |
| 1 | 1 | sync 2 | 0x5A |
| 2 | 1 | type | ASCII letter: H 0x48, L 0x4C, B 0x42, S 0x53, T 0x54 |
| 3 | 1 | version | Always 1 |
| 4 | 4 | length | Payload length N in bytes, unsigned 32-bit, little-endian. The browser rejects N > 262 144. |
| 8 | N | payload | Depends on the type (10.3) |
| 8 + N | 2 | CRC | CRC-16/CCITT-FALSE over bytes 2 … 7 + N (type, version, length and payload), little-endian. |
CRC-16/CCITT-FALSE: polynomial 0x1021, initial value 0xFFFF, no bit reflection, no final XOR. Check value: the ASCII bytes 123456789 give 0x29B1.
Receiving and re-synchronising: scan for A5 5A. If the version isn't 1, the type is unknown or the length is too large, it was not a frame start: treat one byte as text and continue scanning. Wait until 10 + N bytes are available, then check the CRC; on a mismatch, drop one byte and scan again. Bytes outside frames are text, split at \n. So a damaged frame is lost, but never misread.
10.3 Frame types
| Type | Payload |
|---|---|
H hello | UTF-8 JSON, sent at start-up and after ID. Fields: fw ("ESP32-DSO"), ver, core (Arduino-ESP32 version), cpu (MHz), tread (µs per reading), mem (capture memory in values), baud, cal (calibration scheme), pins (ADC pins), gen (generator pins), chunk (points per roll chunk), rst (why the chip last started: poweron, external, software, panic, int_wdt, task_wdt, watchdog, brownout, …; from 1.3.1) and up (milliseconds since start; from 1.3.1), and with the DMA engine (1.4.0, core 3.x) dma: max (fastest rate that passed the probe, total conversions/s; 0 = engine off), swap (1 = word pairs were swapped and are being undone) and probe, one entry per tested rate: [nominal, delivered, repeated ‰, bad ‰, passed]. The browser computes when the board started (now − up); a hello with a different start time is treated as a board restart: the browser logs it, shows the reason and sets the generator to off, because the board's output is off again. A hello that only answers ID has the same start time. The demo adds "virtual": true. |
L calibration | 8192 bytes: 4096 unsigned 16-bit little-endian values. Entry k is the voltage in mV for ADC code k. |
T text | ASCII reply such as ok run or err … (no newline). |
B block | One triggered (or forced) capture: data header + samples. |
S stream | One roll-mode chunk: data header + samples. |
10.4 Data frames (B and S)
| Offset | Type | Field | Description |
|---|---|---|---|
| 0 | u16 | cfgId | id of the CFG this data was taken with |
| 2 | u16 | seq | Counts data frames (B and S together), wraps at 65535 |
| 4 | u32 | n / first | B: points per channel. S: index of this chunk's first point since the stream started |
| 8 | u8 | nch | Channels (1–4) |
| 9 | u8 | flags | Bit field, below |
| 10 | u16 | trigIdx / n | B: index of the trigger point (= pre). S: points in this chunk |
| 12 | f32 | dt | Seconds between points of one channel |
| 16 | f32 | skew | Seconds between readings of consecutive channels (tread) |
| 20 | u8 × 4 | pins | GPIO of slots 0–3 (0 = unused) |
| 24 | u16 × … | samples | Point by point, channel by channel: p0c0, p0c1, …, p1c0, … With PEAK: p0c0min, p0c0max, p0c1min, … |
All multi-byte values are little-endian; f32 is IEEE-754 single precision. Payload size = 24 + n × nch × (2 if PEAK else 1) × 2 bytes. Each sample is ADC code × 16 (section 2).
| Bit | Value | Name | Meaning |
|---|---|---|---|
| 0 | 1 | TRIG | A real trigger occurred |
| 1 | 2 | FORCED | Captured without a trigger (Auto timeout or FORCE) |
| 2 | 4 | PEAK | Samples are min/max pairs |
| 3 | 8 | SLOW | The requested rate could not be met; dt is the measured average |
| 4 | 16 | SINGLE_DONE | Last capture of a Single; the firmware has stopped |
| 5 | 32 | GAP | Stream: points were skipped before this chunk (the link fell behind) |
Time of point i: B: ti = (i − trigIdx) × dt, so the trigger is at t = 0 (the browser then refines it, section 3.3). S: t = (first + i) × dt. Channel c (slot index) was read c × skew later than slot 0.
10.5 Worked example
A block with one channel (GPIO 34), 4 points, triggered at point 2, 50 µs per point. Complete frame, 42 bytes, generated by the scope's own encoder:
a5 5a 42 01 20 00 00 00 03 00 02 01 04 00 00 00 01 01 02 00
17 b7 51 38 9c 53 49 37 22 00 00 00 80 3e c0 76 40 83 80 bb
57 29
| Bytes | Value | Meaning |
|---|---|---|
| a5 5a | — | sync |
| 42 | 'B' | block frame |
| 01 | 1 | version |
| 20 00 00 00 | 32 | payload length = 24 + 4 points × 1 channel × 2 bytes |
| 03 00 | 3 | cfgId |
| 02 01 | 258 | seq (0x0102) |
| 04 00 00 00 | 4 | n points |
| 01 | 1 | nch |
| 01 | TRIG | flags |
| 02 00 | 2 | trigIdx |
| 17 b7 51 38 | 5.0e-5 | dt = 50 µs (float 0x3851B717) |
| 9c 53 49 37 | 1.2e-5 | skew = 12 µs |
| 22 00 00 00 | 34, 0, 0, 0 | pins |
| 80 3e | 16000 | point 0: code 1000 → t = −100 µs |
| c0 76 | 30400 | point 1: code 1900 → t = −50 µs |
| 40 83 | 33600 | point 2: code 2100 → t = 0 (trigger) |
| 80 bb | 48000 | point 3: code 3000 → t = +50 µs |
| 57 29 | 0x2957 | CRC over bytes 2–39 |
With the demo's calibration table (mV = 142 + 0.7357 × code), the four points are 878, 1540, 1687 and 2349 mV. A text reply looks like this: a5 5a 54 01 04 00 00 00 70 6f 6e 67 85 8f = T frame, 4 bytes, "pong", CRC 0x8F85.
10.6 A typical session
(ESP32 boots) → H frame, L frame (also garbage text at 115200 baud: ignored)
PC: ID → H frame, L frame
PC: CFG id=1 ch=34,35 rate=74400 pts=744 pre=372 mode=auto edge=r src=0 lvl=20480 hys=240 acq=normal os=1 auto=60
→ T "ok cfg id=1 nch=2 rate=… pts=744 pre=372 os=1"
PC: RUN → T "ok run", then B frames continuously
PC: GEN pin=25 mode=off f=1000 d=50 → T "ok gen off"
(user changes time/div)
PC: CFG id=2 … → current capture aborted; T "ok cfg id=2 …"; B frames with cfgId 2
(user picks 500 ms/div)
PC: CFG id=3 … mode=roll … → S frames every ≤ 40 ms
10.7 Writing your own client
tools/dso_read.py (Python 3, needs pyserial) is a complete minimal client of about 150 lines: it sends ID and a CFG line, parses frames with the rules above, converts samples with the calibration table and can save a capture as CSV.
pip install pyserial
python dso_read.py --port COM5 --csv capture.csv (Windows; /dev/ttyUSB0 on Linux)
Close the browser scope first: only one program can open the port.
11. Limits, measured
Concepts: the ADC, the input, aliasing and sample rate vs bandwidth in Oscilloscope fundamentals.
Sample rate and frequency
| Engine | Max rate (1 ch) | Shapes (≈ 10 samples/period) | Frequency readings (Nyquist) |
|---|---|---|---|
| DMA (core 3.x) | 250 kSa/s (test board probe) | ≈ 25 kHz | < 125 kHz |
| analogRead | ≈ 21.6 kSa/s (41.2 µs per reading, core 3.3.12) | ≈ 2 kHz | < 10 kHz |
No analogue anti-alias filter. Mitigations: Hi-Res (box-car over each point, §3.2) and deep memory in Normal (§3.1). Example: Normal at 500 Sa/s shows a 1 kHz square as a steady, wrong level; Hi-Res shows its mean (test board 1.62 V).
FFT (measured, app 1.11.1)
Test board, GPIO25 → 1 kΩ → GPIO34, generator square 0.130 / 3.106 V (fundamental 2.54 dBV), FFT checked against an independent FFT of the same samples and against the theory of a rectangular wave.
| Mode / case | Result |
|---|---|
| Normal, 1 kHz, 200 µs … 50 ms/div | Harmonics 1–11 in the samples within 0.04 dB of theory; the display reads that minus the window's scalloping (≤ 1.4 dB). Duty 25 % and 10 %: within 0.3 dB, nulls where expected. |
| Frequency readout (1.11.1, strongest bin) | Within ½ resolution cell (sample rate ÷ samples) from 100 Hz to 120 kHz with ≥ 2 periods on screen. 1 period or less: wrong (1 kHz at 100 µs/div reads 1953 Hz) — warned. |
| Peak label between bins (1.11.2, app 1.11.2 on the test board, 2026-11-28; 3 captures each, compared with a least-squares sine fit of the same samples) | DAC sine ±0.8 V (−5.13 dBV in the samples), steps 44–47 (≈ 5.75–6.14 kHz): ETS 200 µs/div (≈ 2000 pts, bin 488 Hz) within 0.015 bin (≤ 7 Hz) and 0.01 dB; the strongest bin alone was up to 0.49 bin (240 Hz) off and 1.31 dB low. Normal 200 µs/div (500 pts) and 1 ms/div (1382 pts, bin 67.8 Hz): within 0.016 bin and 0.01 dB (bin alone: 0.46 bin, 1.0 dB). 914 Hz (step 7), Normal and Hi-Res 1 ms/div: 914.4–914.8 Hz, −5.13 dBV (bin alone 878.9–881.6 Hz, 0.6–0.7 dB low; the step measured 914.64 Hz in 10.1). Square 1000 Hz at 2 ms/div: 999.97–1000.02 Hz, 2.54 dBV (bin alone 983.3 Hz, 1.92 dBV); 1007 Hz at 5 ms/div: 1007.04 Hz. 914 Hz at 200 µs/div (1.8 periods): falls back to the strongest bin, as intended. |
| Aliases (no filter, no warning) | 130 / 200 / 300 kHz at 250 kSa/s appear at 120 / 50 / 50 kHz. At a non-whole number of samples per period they fall between the harmonics (spurs): 1 kHz at 10 ms/div (23.04 kSa/s) has −23.9 dBV at 2041.5 Hz (alias of the 21st). At a whole number they land on the harmonics and look clean (Hi-Res, 1 kHz at 2 ms/div: 50 samples per period). |
| DAC sine 1045 Hz | 0.73 / −5.13 / −11.35 / −17.65 dBV at amplitude 0 / 6 / 12 / 18; noise floor −73 … −78 dBV (below the default bottom of the screen, −70 dBV). |
| Hi-Res | Matches the box-car response plus aliasing (e.g. 1 kHz at 50 ms/div: 2 samples per period, 1 kHz on the top bin). |
| Average 8 / 64 | 1 kHz at 10 ms/div: 9th harmonic −21.3 / −20.5 dBV vs −16.6 in Normal, 11th −25.2 / −24.2 vs −18.6. Cause: each capture starts at a slightly different place relative to the signal (the trigger moves by up to one sample), and captures are averaged point by point. At 250 kSa/s with 1 kHz (whole samples per period) no difference. Warned in the pane. |
| Peak | No FFT (1.11.0 used the midpoint of each min/max pair: 5 kHz at 20 ms/div read −8.2 dBV instead of 2.3). |
| ETS | Above 125 kHz correct (10 013 Hz at 20 µs/div: 15th harmonic −21.4 dBV vs −21.0 theory, 21st −23.9 vs −23.9). 12 frequencies 300 Hz … 37 kHz at 2 and 20 periods per screen: false even harmonics ≤ −47 dBV unlocked, ≤ −75 dBV locked on an even number of readings. Locked on an odd number (10 000 Hz: 25 readings per period) the readings themselves alias odd harmonics onto even ones: −21 dBV (the Acquire line says locked; use 10 013 Hz). The −47 dBV floor at 10 013 Hz is the ETS time grid: 799 reading positions per period (125 ns), so each edge is placed only to ±½ step. |
| Long records | Only the newest 16 384 points are used (ETS 1 kHz at 10 ms/div: 25 000 points, so the right 65 % of the screen) — warned. |
| Speed | 16 384-point spectrum 1.6 ms in Edge; frame rate unchanged with FFT on. |
Input bandwidth (measured)
ESP32 DAC cosine → R → GPIO34, 24 frequencies, 4096 samples each at 250 kSa/s, sine fits. Amplitude relative to 1 kHz:
| Frequency | 10 kHz | 50 kHz | 100 kHz | 120 kHz | 150 kHz | 200 kHz |
|---|---|---|---|---|---|---|
| R = 1 kΩ | 1.000 | 0.997 | 0.989 | 0.976 | 0.980 | 0.934 * |
| R = 100 kΩ | 0.996 | 0.918 | 0.758 | 0.696 (−3.15 dB) | 0.616 | 0.507 (−5.90 dB) |
100 kΩ fits a single RC pole with C ≈ 14 pF (fc = 1 / (2π R C) ≈ 114–120 kHz); DC shift ≈ 10 mV. With 1 kΩ, fc ≈ 11 MHz. * The 200 kHz point is limited by the DAC staircase (fit residual 189 codes), not the input. Step response seen with ETS (generator edge, 30.9 kHz, app 1.8.0): 10–90 % rise 26–32 ns through 1 kΩ, 236–253 ns through 10 kΩ, 2.55 µs through 100 kΩ, i.e. 2.2 × R × 11–12 pF; the frequency-response fit gives ≈ 14 pF (the input is not an ideal capacitor: the sample-and-hold is switched, and the pin capacitance varies with voltage). Above 125 kHz the measured frequencies were the aliases (130 kHz → 120.1 kHz … 200 kHz → 50.1 kHz).
The ADC
| Property | Test board |
|---|---|
| Floor (pin on GND) | 142 mV, σ 0 (shown as floor; markers stay lit 1 s) |
| Ceiling | 3.155 V with 3.31 V at the pin (shown as CLIP) |
| Accuracy, eFuse table only | +17 mV at 0.31 V … +39 mV at 2.39 V |
| Accuracy after two-point calibration | within ±4 mV (0.3–2.5 V): filtered PWM (G4, v1.10.3) 0.8224 / 1.6517 / 2.4817 V vs meter 0.826 / 1.652 / 2.478 V |
| Calibration table slope | 0.826 mV/code up to code 2880 (2.52 V), 0.522 mV/code above |
| Noise, flat 1.65 V node | AC RMS ≈ 2.9 mV (Normal, 125 kSa/s); statistics σ of Mean 0.1–0.5 mV |
| Linearity | Uneven code widths (DNL): visible in histograms, Top/Base, derivatives |
| Source resistance | Pin ≈ 14 pF: 100 kΩ → τ 1.4 µs, −3 dB ≈ 116 kHz, DC ≈ 10 mV off |
| Channel skew | tread (analogRead) or 1 ÷ ADC rate (DMA) between channels; traces drawn shifted |
The link
921 600 baud ≈ 92 kB/s. A 1000-point, one-channel block is 2 034 bytes, ≈ 22 ms on the wire (≤ ≈ 45 updates/s minus capture time); a full 24 000-point record ≈ 0.52 s.
12. Terms used in this reference
Every general scope term (ADC, aliasing, dBV, ENOB, hysteresis, RMS …) is explained in the glossary of Oscilloscope fundamentals, with a link to the chapter that explains it. Terms that appear only here:
| Term | Meaning |
|---|---|
| Code, LSB | One ADC step (≈ 0.8 mV here). LSB = least significant bit. |
| DNL / INL | Differential / integral nonlinearity: uneven step sizes, and overall bend, of an ADC. |
| NaN | "Not a number": a missing value; not drawn and skipped by measurements. |
| ppm | Parts per million: 10 ppm = 0.001 %. |
| Skew | Time offset between channels that are read one after another. |
| 12.4 fixed point | An ADC code shifted left by 4 bits, so averages keep a fractional part (value ÷ 16 = code). |
ESP32 Web Oscilloscope v1.11.2 · firmware ESP32-DSO 1.5.1 · ScopeProbe 1.0