TinyGo 3 — UART timed sensor loop

Updated

July 30, 2026

TinyGo elective 3 — UART timed sensor loop

Elective · ~3h
Goal: Fixed-period sampling loop with deadline-miss counter and CSV/status lines over serial; mock or real ADC.

Theory

Soft realtime logging needs:

  1. Period T (e.g. 50 ms → 20 Hz)
  2. Miss counter when work overruns
  3. Bounded work per tick (no unbounded alloc/print spam)
  4. UART as primary debug channel on MCUs
tick → read → filter (EMA) → print line → sleep until next deadline

Lab

  1. Configure machine.Serial at 115200.
  2. Loop with next += period; count misses when late.
  3. Mock sensor from time; optional real machine.ADC.
  4. EMA filter; print raw, ema, misses.
  5. Host: picocom / screen on the serial device.

Full listing: monorepo Go project 43.

Checkpoint

  • Stable serial stream
  • Miss counter present
  • Period chosen and justified

Next elective

TinyGo 4 — Cooperative tasks (95-tinygo-04-…).