ESP32 Web Oscilloscope

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.

ParameterValueSource
BoardClassic 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 inputsUp to 4 at once, from GPIO 36, 39, 32, 33, 34, 35 (ADC1 only).design
Input range at the pin0 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
Resolution12 bits (4096 codes, ≈ 0.8 mV per code at 11 dB).datasheet
LinearityDNL ±7 LSB, INL ±12 LSB (uncalibrated).datasheet
CalibrationFactory 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 engineSet 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 engine1 / (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 memory24 000 16-bit values (halved again if RAM is short), shared by channels; peak detect uses two values per point.design
Points per captureMemory = 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
Timebase5 µ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
TriggerEdge (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 generatorOne 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 drive3.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
LinkUSB serial, 921 600 baud, 8N1 (firmware). Text streams: any baud.design
BrowserChrome 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.

Pin voltage0…3.1 V ADC code0…4095 (×16) Calibrationtable → mV × Probe× −1 if Invert BW limitmoving avg CouplingAC: − mean Displayed value v1…v4→ trace, measurements, cursors, math on the ESP32 (firmware) in the browser Trigger (firmware) comparesADC codes: level ÷ probe → code
Figure R1 — The signal chain. With the ScopeProbe library or a text sketch, the first three steps happen in your sketch, which sends millivolts.
  1. 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.
  2. 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.
  3. Probe and invert. Multiply by the probe factor; multiply by −1 if Invert is on.
  4. BW limit. A centred moving average over 3, 9, 33 or 99 samples (fewer at the ends of the record).
  5. 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:

MethodWhenHowDead time
BlockESP32-DSO firmware, time/div below the roll thresholdThe 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.
RollESP32-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 streamScopeProbe library or any sketch printing numbersOne 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.

analogRead engine: cost per point = t_read × N_ch, max rate = 1 / (cost × 1.12) (12 % margin) DMA engine: max rate = probe maximum / N_ch (no margin: the ADC clock is exact) Block mode, Memory = auto: Hi-Res points = 1000 Normal/Peak/Average points = the larger of 1000 and the smaller of max rate × T_screen (every sample the ADC can take) and the points whose transfer takes ≤ max(30 ms, ½ T_screen) Block mode, Memory = a number: points = that number Then: points ≤ 24000 / (N_ch × 2 if Peak else 1) (capture memory) rate = points / T_screen if rate > max rate: rate = max rate, points = round(max rate × T_screen) (at least 20) pre-trigger pts = points × (0.5 − Position / T_screen) (Position 0 → trigger in the centre) Roll mode: rate = smallest of (1000 if Hi-Res, else 10000) / T_screen, max rate / 1.3, 0.4 × link bytes/s ÷ (2 × N_ch)

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/divNormal: pointsNormal: Sa/sHi-Res: pointsHi-Res: Sa/sReadings averaged per Hi-Res point
10 µs – 2 ms3 – 432 (shown on screen)21.6 ksame21.6 k1
5 ms1 08121.6 k1 00020 k1
10 ms2 16221.6 k1 00010 k2
20 ms4 32421.6 k1 0005 k4
50 ms10 80921.6 k1 0002 k12
100 ms (roll)10 00010 k1 0001 k24
1 s (roll)10 0001 k1 000100240
10 s (roll)10 0001001 000102 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.

ModeAlgorithmNotes
NormalOne reading per point per channel.Shows the true noise.
PeakDuring 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-ResThe 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.
AverageIn 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.
ETSIn 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:

ModeBehaviourLimits
Y-TTriggered 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.
RollContinuous 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-YThe 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.

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/divScreenWith a trigger (periodic signal)No trigger (DC, Auto)
1 ms10 ms≈ 15–40 /s≈ 15 /s
10 ms100 ms≈ 5–9 /s≈ 6 /s
20 ms200 ms≈ 3–5 /s≈ 3 /s
50 ms500 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

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

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:

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 modeADC rate chosenPoint value
NormalThe 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-ResThe 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.
PeakThe fastestThe smallest and largest of the D conversions (every conversion is inspected; nothing between points is missed at the ADC rate).
AverageAs NormalAs 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:

RequestNADC rateDPoint rate
Normal, 5 µs/div (fastest)20250 kSa/s1250 kSa/s exactly
Hi-Res, 1 ms/div (1000 points → 100 kSa/s)25200 kSa/s2100 kSa/s exactly
Hi-Res, 10 ms/div (10 kSa/s)20250 kSa/s2510 kSa/s exactly
Roll Hi-Res, 2 kSa/s20250 kSa/s1252 kSa/s exactly
Roll Normal, 2 kSa/s12540 kSa/s202 kSa/s exactly
Normal, 10–100 ms/div (Memory auto: 23.04 kSa/s)31161.3 kSa/s723 041 Sa/s (0.01 % fast)
Normal, 5 ms/div (27.64 kSa/s)9055.6 kSa/s227 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)36138.9 kSa/s1138.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 clockShort captures (1000 points, ADC idle ≈ 20 ms)Long captures (0.5 s, idle 0.1–0.5 s)
20.0 kHz48 % of starts—
20.8 kHz32 %—
21.7 kHz0.4 %—
23.0 kHz0 of 71076 % (3–11 % in the D2 runs)
27.6 kHz0 of 8500 of 112 (0 of 299 at 5 ms/div)
31–100 kHz0 of 48000 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 rowAction
1, 2Stop and start the ADC; the capture starts again (roll: continues after a GAP)
3Load the configuration again
4Delete and recreate the driver
5Switch 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.

  1. 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.
  2. 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.
  3. 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).
  4. 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).
  5. 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.
  6. 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).
  7. 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.
  8. 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. etsDrift folds 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.
  9. 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.
  10. 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:

SignalPeriod foundStepRise 10–90 %Status
Normal mode, 20.011 kHz, 5 µs/div—4 µs (real)3.2 µs (one jump)—
ETS, 20 011 Hz49.975 µs (20.0100 kHz), ±0.2 ppm record to record25 ns26.7–27.9 nsTrig'd
ETS, 30 901 Hz, 100 ns/div32.363 µs (30.900 kHz)10.5 ns27.2 / 32.2 nsTrig'd
ETS, 19 391 / 15 451 Hz26 ns33.5 nsTrig'd
ETS, 10 013 Hz39 ns31 nsTrig'd (near-locked)
ETS, 50 021 Hz19.988 µs (50.031 kHz)25 ns40.5 nsTrig'd
ETS, 2 011 Hz83 ns193 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 µs5 positions—locked, little gain
ETS, 21 737 Hz46.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):

RequestedFrequency foundReadings per periodNormal: Pk-PkETS: Pk-PkNeighbour spread, one period → drift followingBin spread (offline)
1 kHz914.5 Hz2731.593 V—2.1 mV (not always tracked)—
5 kHz4 962.5 Hz50—1.568 V10 → 2.1 mV20 → 10 mV
20 kHz19 984 Hz12.5—1.568 V26 → 4.1 mV81 → 13 mV
50 kHz49 901 Hz5.01.465 V (peaks missed)1.565 V35 → 7.2 mV130 → 18 mV
100 kHz99 945 Hz2.50—1.552 V55 → 13 mV95 → 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.

NameFormula / methodUnit
Max, MinLargest and smallest sample.V
Pk-PkMax − 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, BaseA 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
AmplitudeTop − 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
Frequency1 / Period.Hz
+WidthAverage time from each rising edge to the next falling edge (only pairs closer than 1.5 periods).s
−WidthPeriod − +Width.s
Duty+Width ÷ Period.%
RiseTime 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
FallThe 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:

SymbolMeaning
μ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, maxSmallest and largest value so far.
nNumber 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:

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

NameValue at sample iUnit
v1 … v4Displayed value of CH1–CH4 (after probe, invert, BW limit and coupling).channel unit
dv1 … dv4Time derivative dv/dt of that channel (section 5.4).unit / s
iv1 … iv4Running integral ∫ v dt, zero at the left edge of the screen (section 5.4).unit · s
tTime 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 … m3Result 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 constantsFrom 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.

PriorityOperatorsMeaning
1 (first)( ), f(…)Brackets, function calls
2^ or **Power. Groups from the right: 2^3^2 = 29 = 512.
3-x, +x, !xNegative, 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 : bIf 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).

FunctionResultExample
sin(x) cos(x) tan(x)Sine, cosine, tangentsin(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 tanhHyperbolic functionscosh(0) = 1
exp(x)exexp(-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 logarithmslog10(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 1sign(-3) = −1
floor(x) ceil(x)Round down / up to a whole numberfloor(-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 argumentsmax(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 … hiclip(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):

dv/dt(i) = Σ (t_j − t̄)(v_j − v̄) / Σ (t_j − t̄)² over j = i−w … i+w

∫ 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:

I(i) = Σ ½ (v_k + v_(k−1)) (t_k − t_(k−1)) over k = 1 … i, then I ← I − I(left edge)

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)

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

MessageCause
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 expressionThe 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 channelsFor example m2 inside M1 or M2.
"freq_m2" (a reading of M2) can only be used by later math channelsThe 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 constantsA 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)NameUnit
Max, Min, Pk-Pk, Mean, RMS, AC RMS, Top, Base, Amplmax1 min1 pp1 mean1 rms1 acrms1 top1 base1 amp1unit of the source
Freq, Periodfreq1 period1Hz, s
+Width, −Width, Rise, Fallpwidth1 nwidth1 rise1 fall1s
Dutyduty1a fraction from 0 to 1 (the Measure list shows it as %)
Areaarea1unit 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.

mean1 + pp1 / 2 * sin(2 * pi * freq1 * t + 1.047) // CH1, shifted 60° ahead v1 / pp1 // CH1 scaled to a peak-to-peak of 1 freq1 / freq2 // frequency ratio of two channels

6. Cursors, FFT and display details

Concepts: cursors, the spectrum and drawing in Oscilloscope fundamentals.

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)DefaultMeaning
DSO_BAUD (in platformio.ini build_flags)921600Serial 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_PINS36, 39, 32, 33, 34, 35Pins accepted as inputs (ADC1 only: ADC2 cannot be used while Wi-Fi runs).
GEN_PINS25, 26, 27, 4, 13, 14, 16–19, 21–23Pins 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_WANT24000Capture memory in 16-bit values (halved until the allocation succeeds).
STREAM_CHUNK128Points per roll-mode frame. A chunk is also sent after 40 ms even if not full.
DMA_FRAME, DMA_POOL512, 32768 bytesDMA 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

  1. Serial at BAUD, 12-bit ADC, 11 dB attenuation on all ADC pins.
  2. Times 2000 analogRead() calls alternating GPIO 34 and 35 → tread.
  3. 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).
  4. 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.
  5. 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

7.1 Signal generator

FrequencyHowAccuracy
0.01 Hz – < 100 HzSoftware 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 MHzHardware 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.
Frequencyres (bits)Duty stepWorst frequency error from the divider
1 – 76 Hz160.0015 %< 0.01 %
1 kHz120.024 %0 (divider 19.53125 is exact)
10 kHz80.39 %0 (divider 31.25 is exact)
100 kHz80.39 %≤ 0.06 %
1 MHz61.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).

FunctionDescription
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.

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:

LineExampleRule
Data12345.678,1650,8122 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,outStarts with #. Keys: time = s | ms | us; units = V | mV; names = comma list. Other keys are ignored.
Headerms,CH1_mV,CH2_mVSeparator-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 onA labelled flag at the time of the last data line (first 40 characters shown).
Anything elseCharging startedShown in the log (at most about 3 lines per second) and otherwise ignored.
BaudBytes/sText lines/s (1 value)Binary samples/s (firmware)
115 20011 520≈ 900≈ 5 700
921 60092 160≈ 7 000≈ 46 000
2 000 000200 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.

CommandReplyEffect
IDH frame, then L frameIdentify: hello (JSON) and calibration table.
CFG key=value …ok cfg … or err …Acquisition settings (table below). Applied at once and restarts the capture.
RUNok runStart acquiring.
STOPok stopStop acquiring (the current capture is abandoned).
SINGLEok singleSet mode = single and run. After one block (flag SINGLE_DONE) the firmware stops.
FORCEnoneTrigger now (once the pre-trigger memory is full).
GEN key=value …ok gen … or err gen …Signal generator (table below).
PINGpongLink check.
anything elseerr unknown command—

CFG keys

KeyValuesMeaning
id0 – 65535Configuration id, copied into every data frame.
ch1–4 pins, comma separated, e.g. 34,35Channels, 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.
pts16 … memory ÷ (channels × 2 if peak)Points per channel per block (clamped).
pre0 … pts − 1Points before the trigger.
modeauto | normal | single | rollTrigger mode, or continuous streaming.
edger | f | bRising, falling, both.
src0 … channels − 1Trigger source as a slot index (position in ch), not a pin number.
lvlintegerTrigger level as ADC code × 16. Example: 2048 × 16 = 32768 ≈ mid-scale.
hysintegerHysteresis in code × 16 (the browser sends 240 ≈ 12 mV, or 1200 ≈ 60 mV with Noise reject).
acqnormal | peak | hiresAcquisition (section 3.2).
os1 – 64Accepted for compatibility. Since firmware 1.2.0 hires averages every reading in each point interval, however many that is.
automsAuto-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).
engdma | cpuAcquisition 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

KeyValuesMeaning
pinone of GEN_PINSOutput pin. Others: err gen pin N not allowed. Changing the pin releases the old one (back to input).
modeoff | high | low | pwm | sineOff = 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).
a0, 6, 12, 18Sine 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 … 127Sine only: DC offset in DAC codes (default 0; the app does not use it).
f0.01 – 1 000 000Frequency in Hz (clamped; whole Hz from 1 Hz up).
d0 – 100Duty 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)

OffsetSizeFieldDescription
01sync 10xA5
11sync 20x5A
21typeASCII letter: H 0x48, L 0x4C, B 0x42, S 0x53, T 0x54
31versionAlways 1
44lengthPayload length N in bytes, unsigned 32-bit, little-endian. The browser rejects N > 262 144.
8NpayloadDepends on the type (10.3)
8 + N2CRCCRC-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.

crc = 0xFFFF for each byte b: crc ^= b << 8 repeat 8 times: crc = ((crc << 1) ^ 0x1021) if (crc & 0x8000) else (crc << 1); crc &= 0xFFFF

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

TypePayload
H helloUTF-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 calibration8192 bytes: 4096 unsigned 16-bit little-endian values. Entry k is the voltage in mV for ADC code k.
T textASCII reply such as ok run or err … (no newline).
B blockOne triggered (or forced) capture: data header + samples.
S streamOne roll-mode chunk: data header + samples.

10.4 Data frames (B and S)

OffsetTypeFieldDescription
0u16cfgIdid of the CFG this data was taken with
2u16seqCounts data frames (B and S together), wraps at 65535
4u32n / firstB: points per channel. S: index of this chunk's first point since the stream started
8u8nchChannels (1–4)
9u8flagsBit field, below
10u16trigIdx / nB: index of the trigger point (= pre). S: points in this chunk
12f32dtSeconds between points of one channel
16f32skewSeconds between readings of consecutive channels (tread)
20u8 × 4pinsGPIO of slots 0–3 (0 = unused)
24u16 × …samplesPoint 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).

BitValueNameMeaning
01TRIGA real trigger occurred
12FORCEDCaptured without a trigger (Auto timeout or FORCE)
24PEAKSamples are min/max pairs
38SLOWThe requested rate could not be met; dt is the measured average
416SINGLE_DONELast capture of a Single; the firmware has stopped
532GAPStream: 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
BytesValueMeaning
a5 5a—sync
42'B'block frame
011version
20 00 00 0032payload length = 24 + 4 points × 1 channel × 2 bytes
03 003cfgId
02 01258seq (0x0102)
04 00 00 004n points
011nch
01TRIGflags
02 002trigIdx
17 b7 51 385.0e-5dt = 50 µs (float 0x3851B717)
9c 53 49 371.2e-5skew = 12 µs
22 00 00 0034, 0, 0, 0pins
80 3e16000point 0: code 1000 → t = −100 µs
c0 7630400point 1: code 1900 → t = −50 µs
40 8333600point 2: code 2100 → t = 0 (trigger)
80 bb48000point 3: code 3000 → t = +50 µs
57 290x2957CRC 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

EngineMax 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 / caseResult
Normal, 1 kHz, 200 µs … 50 ms/divHarmonics 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 Hz0.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-ResMatches 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 / 641 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.
PeakNo 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).
ETSAbove 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 recordsOnly 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.
Speed16 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:

Frequency10 kHz50 kHz100 kHz120 kHz150 kHz200 kHz
R = 1 kΩ1.0000.9970.9890.9760.9800.934 *
R = 100 kΩ0.9960.9180.7580.696 (−3.15 dB)0.6160.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

PropertyTest board
Floor (pin on GND)142 mV, σ 0 (shown as floor; markers stay lit 1 s)
Ceiling3.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 calibrationwithin ±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 slope0.826 mV/code up to code 2880 (2.52 V), 0.522 mV/code above
Noise, flat 1.65 V nodeAC RMS ≈ 2.9 mV (Normal, 125 kSa/s); statistics σ of Mean 0.1–0.5 mV
LinearityUneven code widths (DNL): visible in histograms, Top/Base, derivatives
Source resistancePin ≈ 14 pF: 100 kΩ → τ 1.4 µs, −3 dB ≈ 116 kHz, DC ≈ 10 mV off
Channel skewtread (analogRead) or 1 ÷ ADC rate (DMA) between channels; traces drawn shifted

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:

TermMeaning
Code, LSBOne ADC step (≈ 0.8 mV here). LSB = least significant bit.
DNL / INLDifferential / integral nonlinearity: uneven step sizes, and overall bend, of an ADC.
NaN"Not a number": a missing value; not drawn and skipped by measurements.
ppmParts per million: 10 ppm = 0.001 %.
SkewTime offset between channels that are read one after another.
12.4 fixed pointAn 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