Duty-cycle energy and latency budget
Build an energy-latency budget from components and explain when duty cycling helps or hurts.

Edge Eddie
Build an energy-latency budget from components and explain when duty cycling helps or hurts.
Predict the reading, then compare it with the measurement.
Python 3 in your browser (JupyterLite)
Python · no installOpen the notebook in your browser and run each Python cell; no install or account is needed.
Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.
Steps
Step 1
- Do
- Run the Step 1 notebook cell to inspect the labelled synthetic current and timing assumptions.
- You will see
Run the cell. You should see:
- SYNTHETIC engineering assumptions; seed=2626; no random draws; supply=3.0 V; active=8.00 mA for 100 ms; radio=35.00 mA for 80 ms per attempt; sleep=0.040 mA; retry adds 80 ms radio-on; latency limit=300 ms; daily energy limit=30 J
- Why it matters
- Every estimate must reveal its units and assumed inputs.
Code for step 1import platform import pyodide print(f'Runtime: Python {platform.python_version()} / Pyodide {pyodide.__version__}') """Explicitly synthetic duty-cycle energy and response budget.""" SEED = 2626 # deterministic assumptions; no random draws SUPPLY_V = 3.0 ACTIVE_MA, ACTIVE_MS = 8.0, 100 RADIO_MA, RADIO_MS = 35.0, 80 SLEEP_MA = 0.04 RETRY_MS = 80 LATENCY_LIMIT_MS = 300 DAILY_ENERGY_LIMIT_J = 30 def budget(interval_s, retries=0): awake_ms = ACTIVE_MS + RADIO_MS + retries * RETRY_MS assert interval_s * 1000 > awake_ms active_mas = ACTIVE_MA * ACTIVE_MS / 1000 radio_mas = RADIO_MA * (RADIO_MS + retries * RETRY_MS) / 1000 sleep_mas = SLEEP_MA * (interval_s - awake_ms / 1000) cycle_mas = active_mas + radio_mas + sleep_mas average_ma = cycle_mas / interval_s daily_j = average_ma / 1000 * SUPPLY_V * 86400 return active_mas, radio_mas, sleep_mas, average_ma, daily_j, awake_ms def run_step(n): if n == 1: lines = ["SYNTHETIC engineering assumptions; seed=2626; no random draws", f"supply={SUPPLY_V:.1f} V; active={ACTIVE_MA:.2f} mA for {ACTIVE_MS} ms", f"radio={RADIO_MA:.2f} mA for {RADIO_MS} ms per attempt", f"sleep={SLEEP_MA:.3f} mA; retry adds {RETRY_MS} ms radio-on", f"latency limit={LATENCY_LIMIT_MS} ms; daily energy limit={DAILY_ENERGY_LIMIT_J} J", "These are assumed inputs, not bench measurements."] elif n == 2: a, r, s, avg, day, latency = budget(60) lines = ["One 60 s reporting cycle; no retries", "energy proxy mA*s = current_mA * duration_s", f"active={a:.3f} mA*s; radio={r:.3f} mA*s", f"sleep={s:.3f} mA*s", f"total={a+r+s:.3f} mA*s; average={avg:.4f} mA", f"daily energy={day:.3f} J at {SUPPLY_V:.1f} V", f"active + radio latency={latency} ms"] elif n == 3: lines = ["Increase reporting frequency from 60 s to 10 s", "interval_s avg_mA daily_J", *[f"{i:>10} {budget(i)[3]:>6.4f} {budget(i)[4]:>7.3f}" for i in (300, 60, 10)], "Shorter intervals repeat the active and radio cost more often."] elif n == 4: lines = ["Radio retries at 60 s interval", "retries radio_mA*s latency_ms daily_J", *[f"{k:>7} {budget(60,k)[1]:>10.3f} {budget(60,k)[5]:>10} {budget(60,k)[4]:>7.3f}" for k in (0,1,2,3)], "More retries add radio energy and consume latency headroom."] elif n == 5: rows = [(i,k,budget(i,k)) for i,k in ((10,0),(60,0),(60,1),(60,2),(60,3),(300,0),(300,2))] lines = ["Sweep under 30 J/day and 300 ms response limits", "interval_s retry daily_J latency_ms feasible", *[f"{i:>10} {k:>5} {b[4]:>7.3f} {b[5]:>10} {'YES' if b[4]<=DAILY_ENERGY_LIMIT_J and b[5]<=LATENCY_LIMIT_MS else 'NO'}" for i,k,b in rows], "YES requires both assumed limits to hold."] elif n == 6: lines = ["RESULT CARD: synthetic budget assumptions; seed=2626", f"60 s, no retry: {budget(60)[4]:.3f} J/day; {budget(60)[5]} ms", f"10 s, no retry: {budget(10)[4]:.3f} J/day; {budget(10)[5]} ms", f"60 s, 3 retries: {budget(60,3)[4]:.3f} J/day; {budget(60,3)[5]} ms", f"limits: {DAILY_ENERGY_LIMIT_J} J/day and {LATENCY_LIMIT_MS} ms", "The calculation excludes battery derating, wake-up, and network queueing.", "It does not establish measured battery life or deployed latency."] else: raise ValueError(n) lines.append(f"STEP {n} complete") output = "\n".join(lines) print(output) return output run_step(1);
Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 2
- Do
- Run the Step 2 notebook cell to inspect the active, radio, and sleep terms for one cycle.
- You will see
Run the cell. You should see:
- One 60 s reporting cycle; no retries; energy proxy mA*s = current_mA * duration_s; daily energy=25.889 J at 3.0 V; active + radio latency=180 ms
- Why it matters
- Separate terms show which state consumes the charge.
Code for step 2run_step(2);
Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 3
- Do
- Run the Step 3 notebook cell to compare interval length with average current and daily energy.
- You will see
Run the cell. You should see:
- Increase reporting frequency from 60 s to 10 s; interval_s avg_mA daily_J; 10 0.3993 103.493; Shorter intervals repeat the active and radio cost more often.
- Why it matters
- More frequent reporting repeats wake and radio costs.
Code for step 3run_step(3);
Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 4
- Do
- Run the Step 4 notebook cell to add radio retries and inspect energy and latency.
- You will see
Run the cell. You should see:
- Radio retries at 60 s interval; retries radio_mA*s latency_ms daily_J; 3 11.200 420 62.135; More retries add radio energy and consume latency headroom.
- Why it matters
- Retries can cross both energy and response limits.
Code for step 4run_step(4);
Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 5
- Do
- Run the Step 5 notebook cell to identify rows meeting both assumed limits.
- You will see
Run the cell. You should see:
- Sweep under 30 J/day and 300 ms response limits; interval_s retry daily_J latency_ms feasible; 300 2 18.305 340 NO; YES requires both assumed limits to hold.
- Why it matters
- Feasibility requires both constraints to hold together.
Code for step 5run_step(5);
Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 6
- Do
- Run the Step 6 notebook cell and read the conclusion and excluded costs.
- You will see
Run the cell. You should see:
- RESULT CARD: synthetic budget assumptions; seed=2626; 60 s, no retry: 25.889 J/day; 180 ms; The calculation excludes battery derating, wake-up, and network queueing.; It does not establish measured battery life or deployed latency.
- Why it matters
- An arithmetic budget cannot substitute for field measurements.
Code for step 6run_step(6);
Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
Why does this chapter say fog computing is not automatically faster, cheaper, or lower power?
Return to the chapter’s knowledge checkA fog node compresses routine data before upload. What measurement decides whether this helps overall?
Return to the chapter’s knowledge check
Caution
Before you start
Read this before you start.
These synthetic assumptions do not establish measured battery life or deployed response latency.
Technical details
- Version tested
- Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium real browser capture, 2026-10-09. Date: 2026-10-09.
https://iotclass.org/labs/duty-cycle-energy-latency.html