7  Energy Measurement and Profiling

7.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Select appropriate tools for power measurement at different current ranges
  • Set up measurement circuits for accurate current profiling
  • Interpret power measurement data to identify optimization opportunities
  • Use oscilloscopes and power analyzers for IoT development
  • Validate battery life predictions through testing

Key Concepts

  • Shunt Resistor Method: Measuring voltage across a small series resistor (0.1–10 Ω) to infer current via Ohm’s law; low-cost but adds series resistance that slightly affects circuit behavior
  • INA219/INA226: Dedicated current-sensing ICs with built-in ADC and I2C interface; measure both voltage and current simultaneously with 12-bit precision
  • Current Probe: A clamp-style measurement device that measures current through magnetic induction without breaking the circuit; convenient but less accurate for µA-level measurements
  • Power Profiler Kit II (nRF PPK2): Nordic Semiconductor’s dedicated IoT power profiler measuring 200 nA to 1 A with 100 kHz sampling; ideal for characterizing Bluetooth/cellular IoT devices
  • Oscilloscope Current Measurement: Using a current probe on an oscilloscope to capture current waveforms versus time; excellent for visualizing duty cycle and identifying intermittent current spikes
  • Accelerated Aging Test: Running the device at elevated temperature or shortened duty cycle to compress weeks of operation into hours; validates long-term battery life predictions
  • Development Board Isolation: USB interfaces on dev boards add 5–20 mA from USB chip and onboard LEDs; always isolate the target MCU for accurate low-power measurements
In 60 Seconds

Accurate energy measurement requires measuring current at µA resolution across all device operating states using a shunt resistor or dedicated current monitor, then calculating weighted average current from actual duty cycle data — datasheet values alone are insufficient for real-world battery life predictions.

Energy and power management determines how long your IoT device can operate between battery changes or charges. Think of packing for a camping trip with limited battery packs – every bit of power must be used wisely. Since many IoT sensors need to run for months or years unattended, power management is often the single most important engineering decision.

“You cannot improve what you do not measure,” said Bella the Battery. “Energy profiling tools show you exactly how much current the device draws at every moment – during sleep, during sensing, and during radio transmission. You often find surprises!”

Max the Microcontroller described the setup: “A shunt resistor is a tiny resistor in series with the power supply. By measuring the voltage across it, you calculate the current. A 1-ohm resistor with 10 millivolts across it means 10 milliamps of current. Simple but powerful!”

Sammy the Sensor shared a discovery: “When we profiled our weather station, we found a GPS module that was supposed to be off was actually in standby mode, drawing 5 milliamps continuously. That one bug was cutting battery life in half! We would never have found it without measurement.” Lila the LED added, “Professional tools like the Nordic Power Profiler can measure from nanoamps to amps and show you a timeline of exactly what your device is doing. It is like an X-ray for power consumption!”

7.2 Energy Measurement and Profiling

Theoretical calculations provide estimates, but actual measurement is essential for validating designs and identifying unexpected power drains. Many IoT projects fail to meet battery life targets because developers rely solely on datasheet values.

7.2.1 Why Measurement Matters

The Gap Between Datasheets and Reality
Source Typical Sleep Current Claimed Measured Current
ESP32 Datasheet 10 µA 10-20 µA (matched)
ESP32 + Dev Board 10 µA (ESP32 only) 5-50 mA (USB chip, LDO, LEDs)
nRF52840 Datasheet 1.5 µA 1.5-3 µA (matched)
nRF52840 DK 1.5 µA 300-500 µA (LEDs, regulators)

Key insight: Development boards are NOT representative of final product power consumption. Design custom PCBs for accurate measurement, or measure the MCU chip directly with peripherals disabled.

7.2.2 Measurement Tool Selection

Current Range Measurement Tool Resolution Cost
1 A - 10 A Benchtop DMM 1 mA $50-500
1 mA - 1 A DMM with shunt 10-100 µA $20-200
1 µA - 100 mA Precision shunt + scope 1-10 µA $200-1000
100 nA - 100 mA Power profiler (Nordic/Qoitech) 100 nA $300-1000
1 nA - 10 mA SMU (Keithley, Keysight) 1 nA $2000-20000

7.2.3 Shunt Resistor Method

The simplest measurement approach uses a shunt resistor in series with the power supply:

Circuit diagram showing a power supply connected to a device under test (DUT) with a shunt resistor in series between them. Voltage across the shunt resistor is measured to calculate current flow using Ohm's law.
Figure 7.1: Shunt resistor measurement circuit for current profiling

Shunt Resistor Selection:

Current Range Shunt Value Voltage Drop at Max Consideration
1-100 µA 1 kΩ 100 mV @ 100 µA May affect sleep modes
100 µA - 10 mA 100 Ω 1 V @ 10 mA Significant drop
10 mA - 100 mA 10 Ω 1 V @ 100 mA Heat dissipation
100 mA - 1 A 1 Ω 1 V @ 1 A Low value needed
1 A - 10 A 0.1 Ω 1 V @ 10 A Must handle power

Challenge: Wide dynamic range (µA sleep to mA active) requires multiple shunts or automatic ranging.

Why does a 10,000:1 dynamic range (10µA to 100mA) require specialized measurement equipment?

Problem: With a fixed shunt resistor, voltage measurement resolution becomes inadequate:

\[\text{For } R_{\text{shunt}} = 1\,\Omega: \quad V_{10\mu\text{A}} = 10\,\mu\text{V}, \quad V_{100\text{mA}} = 100\,\text{mV}\]

Standard multimeters have 100µV resolution—inadequate for 10µV sleep current. Even a 10Ω shunt gives only 100µV at 10µA, but then creates 1V drop at 100mA (unacceptable voltage loss).

Solution: Power profilers use automatic ranging—switching between multiple shunt values (1Ω, 100Ω, 10kΩ) based on measured current, achieving 100nA resolution across the full 10,000:1 range.

7.2.4 Dedicated Power Profilers

Modern power profilers solve the dynamic range problem:

Tool Current Range Resolution Features Price
Nordic PPK2 200 nA - 1 A 100 nA 100 ksps, logic capture $99
Qoitech Otii Arc 1 µA - 5 A 200 nA 100 ksps, scripting $600
Joulescope JS220 10 nA - 10 A 10 nA 2 Msps, autorange $1000
Keysight N6705C 1 nA - 150 A 1 nA Lab grade, GPIB $8000+

7.2.5 Power Profiling Workflow

Step 1: Establish Baseline

1. Remove development board peripherals (LEDs, USB-serial)
2. Power device from profiler, not USB
3. Verify device enters expected sleep mode
4. Measure sleep current (should match datasheet)

Step 2: Profile Each State

1. Configure device for single state (always active, always sleep)
2. Measure current for 60+ seconds
3. Record average, peak, and minimum values
4. Repeat for each power state

Step 3: Profile Full Duty Cycle

1. Configure device for normal operation
2. Capture at least 10 full cycles
3. Calculate average current: I_avg = ∫I(t)dt / T
4. Compare to theoretical calculation

Step 4: Identify Anomalies

Look for:
- Unexpected current spikes during sleep
- Longer-than-expected active periods
- Periodic background activity
- Slow current decay after active phase

7.2.6 Interpreting Power Profiles

Time-series power profile graph showing current consumption over time with distinct labeled phases: deep sleep at microamp levels, sensor wake-up spike, sensor reading at moderate current, data processing, radio transmission at highest current peak, and return to deep sleep.
Figure 7.2: Annotated power profile showing distinct phases of IoT operation

7.2.7 Common Problems and Solutions

Observed Issue Likely Cause Solution
Sleep current 10× expected Pull-up on floating GPIO Configure as output or pull-down
Current spikes during sleep Watchdog timer activity Disable watchdog in deep sleep
Slow decay after active Peripheral not disabled Explicitly power down all peripherals
Radio current during sleep Radio not fully off Use radio shutdown command, not idle
Random high-current events Background task/interrupt Check all interrupt sources
Higher than expected TX Low battery voltage Check voltage drop under load

7.2.8 Measurement Setup Best Practices

  1. Power directly from profiler - USB power includes serial chip current
  2. Use short, thick wires - Minimize resistance and inductance
  3. Add bulk capacitor - 100-1000 µF near DUT for current spikes
  4. Disable debug - JTAG/SWD can add 1-10 mA
  5. Control temperature - Current varies with temperature
  6. Long measurements - Capture at least 10 full cycles
  7. Check at voltage extremes - Fresh battery vs. depleted

7.2.9 Code for Measurement Debugging

This technique helps correlate power profile traces with specific code execution phases. Add these GPIO toggles to your firmware during power profiling sessions:

// Add GPIO toggles to correlate with power profile
#define PROFILE_PIN 25

void profile_marker_high(void) {
    gpio_set_level(PROFILE_PIN, 1);
}

void profile_marker_low(void) {
    gpio_set_level(PROFILE_PIN, 0);
}

void measured_operation(void) {
    profile_marker_high();  // Scope trigger

    read_sensor();

    profile_marker_low();   // End of sensor read

    profile_marker_high();

    transmit_data();

    profile_marker_low();   // End of transmission
}

7.2.10 Validating Battery Life Predictions

Accelerated Life Test:

For 5-year battery life, you can’t wait 5 years to validate. Use accelerated testing:

1. Increase duty cycle 100×
   - Normal: 1 reading/hour
   - Test: 100 readings/hour (36 sec interval)

2. Run for 1 week
   - Simulates 2 years of operation

3. Measure battery voltage decline

4. Extrapolate to target lifetime

Margin Calculation:

Measured average current: 85 µA
Target for 5 years on 2400 mAh: 55 µA
Margin: 55/85 = 65% of target

Action needed: Optimize to reduce current by 35%

7.3 Knowledge Check

## Worked Example: Complete Power Audit of an ESP32 Weather Station

System: ESP32-based weather station reading BME280 (temp/humidity/pressure) every 10 minutes, transmitting via Wi-Fi to an MQTT broker.

Measurement Setup: Nordic PPK2 power profiler, inline between 3.7V LiPo battery and custom PCB (no dev board). All development board components removed.

Step 1: Sleep Current Baseline

Component Expected (datasheet) Measured Notes
ESP32 deep sleep 10 uA 12 uA Matched within spec
BME280 sleep 0.1 uA 0.1 uA Negligible
3.3V LDO quiescent 5 uA 8 uA Higher than expected
Total sleep 15.1 uA 20.1 uA 33% higher than calculated

Step 2: Active Phase Profile (measured with PPK2 at 100 ksps)

Phase Duration Current Energy (uAh)
Wake + init 50 ms 40 mA 0.56
BME280 read 10 ms 42 mA 0.12
Data processing 5 ms 35 mA 0.05
Wi-Fi connect 1.2 s 120 mA avg 40.0
MQTT publish 200 ms 170 mA 9.44
Wi-Fi disconnect 50 ms 80 mA 1.11
Enter deep sleep 5 ms 15 mA 0.02
Total active 1.52 s avg 120 mA 51.3 uAh

Step 3: Average Current Calculation

Active energy per cycle: 51.3 uAh
Sleep energy per cycle: 20.1 uA × (600s - 1.52s) / 3600 = 20.1 × 598.48 / 3600 = 3.34 uAh
Total per cycle: 51.3 + 3.34 = 54.64 uAh
Average current: 54.64 uAh / (600s/3600) = 54.64 / 0.1667 = 328 uA = 0.328 mA

Step 4: Battery Life Prediction

Battery: 18650 Li-ion, 3000 mAh (usable: 2700 mAh at 80% DoD)
Predicted life: 2700 mAh / 0.328 mA = 8,232 hours = 343 days

Step 5: Anomaly Found

The PPK2 trace revealed a 5 mA current spike every 60 seconds during sleep. Root cause: the ESP32 was configured with the default watchdog timer (IWDT), which briefly wakes the CPU.

Fix: Disable IWDT in deep sleep: esp_sleep_disable_wlan_wdt()

Result after fix:

  • Sleep current dropped from 20.1 uA to 15.2 uA
  • Battery life improved from 343 to 402 days (+17%)

Key Lesson: A single overlooked configuration (watchdog timer) reduced battery life by 59 days. Measurement found it in minutes. Without measurement, the team would have shipped with 17% shorter battery life and never known why.

7.4 Case Study: RAKwireless WisBlock Power Profiling for Smart Agriculture

Real-World Case Study: How Power Profiling Saved a 10,000-Node Vineyard Deployment

Company: A European precision agriculture company deploying RAKwireless WisBlock LoRa sensor nodes across 2,500 hectares of vineyards in France and Spain (2022-2023).

Initial problem: Prototype nodes on the bench showed 2.8 years battery life with a 3,600 mAh battery (ER18505 lithium thionyl chloride cell). Field deployment achieved only 9 months before batteries died, requiring expensive manual replacement across remote vineyard rows.

Investigation using Nordic PPK2 power profiler:

The team profiled field-returned units and discovered three problems invisible to bench testing:

Problem Bench Current Field Current Root Cause
LoRa TX retransmits 1 TX/cycle 2.4 TX/cycle average Poor antenna placement inside enclosure caused 60% first-attempt failures
Extended ADC warm-up 2 ms 45 ms Soil moisture probe capacitance required longer settling time in wet soil
GPS cold start Not used in bench test 12-second active period every 6 hours Firmware enabled GPS location logging that bench firmware lacked

Measured vs. predicted power budget:

Phase Predicted Bench Measured Field Measured
Deep sleep (10 min cycle) 2.1 uA 2.3 uA 2.3 uA
Sensor read 15 mA x 50 ms = 0.21 mAh/day 15 mA x 55 ms = 0.23 mAh/day 15 mA x 95 ms = 0.40 mAh/day
LoRa TX 120 mA x 100 ms = 0.34 mAh/day 120 mA x 105 ms = 0.36 mAh/day 120 mA x 252 ms = 0.86 mAh/day
GPS fix 0 mAh/day 0 mAh/day 25 mA x 12 s x 4/day = 0.33 mAh/day
Daily total 0.60 mAh 0.64 mAh 1.64 mAh
Battery life 16.4 years 15.4 years 6.0 years (usable: ~9 months)

Note: Usable capacity of ER18505 at -10C winter temperatures drops from 3,600 mAh to ~2,200 mAh, explaining the 9-month field life vs. 6-year room-temperature calculation.

Fixes implemented (6-week engineering sprint):

  1. External antenna with SMA connector: TX success rate improved from 40% to 95%, eliminating 1.4 retransmissions per cycle
  2. Firmware: increased ADC settling delay to 50ms but added early-exit when reading stabilizes (average 20ms in field)
  3. Disabled GPS – vineyard nodes are stationary; GPS coordinates set once during installation
  4. Added low-temperature battery derating: switch to 2-hour reporting interval below 0C

Result after fixes: Field battery life improved from 9 months to 3.2 years, within specification. The $8,000 engineering investment in power profiling equipment and 6 weeks of work saved an estimated $180,000/year in battery replacement labor across 10,000 nodes.

Key lesson: Always profile in conditions matching deployment. Bench testing at room temperature with ideal antenna coupling and simplified firmware masks the three biggest power drains in real IoT: RF retransmissions, sensor settling times in real media, and forgotten firmware features.

7.5 How It Works

Power measurement tools capture current consumption over time, revealing device behavior:

Measurement chain: Battery → Shunt resistor (0.1-10Ω) → Device → Ground. Measure voltage drop across shunt: V = I × R, so I = V / R. For 1Ω shunt at 10mA: 10mV drop.

Dynamic range challenge: Sleep (10µA) to TX (200mA) = 20,000:1 range. A single shunt resistor cannot handle both accurately. Solutions: 1. Multiple shunts: Switch between 1kΩ (µA), 10Ω (mA), 0.1Ω (amps) 2. Auto-ranging profiler: Nordic PPK2 switches ranges automatically at 100 kHz 3. Current amplifier: TI INA226 with 80µV/µA sensitivity

Profiling workflow: (1) Baseline sleep current (device should match datasheet), (2) Profile each state independently (sensor read, processing, TX), (3) Capture full duty cycle (10+ cycles), (4) Calculate average current from integral, (5) Identify anomalies (unexpected spikes, slow decay).

7.6 Concept Relationships

Power measurement is the validation step that bridges theory and reality:

  • Validates: All predictions from Low-Power Strategies must be confirmed by measurement—assumptions fail 80% of the time
  • Prerequisite For: Cannot tune Energy Harvesting panel sizing without accurate consumption measurements
  • Reveals Gaps: Exposes mismatch between datasheet values and real hardware (pull-ups, peripheral leakage, regulator quiescent current)
  • Iterative Process: Measure → Identify bottleneck → Optimize → Re-measure. Single measurement is insufficient—profile after every change

Common sequence: Design calculates 50µA average → First measurement shows 500µA → Investigation finds GPIO pull-up (200µA) + LDO quiescent (150µA) + sensor standby (100µA) → Fixes achieve 60µA → Close enough to proceed.

7.7 See Also

Measurement Tools & Techniques:

  • Power Profiling with PPK2 - Nordic profiler setup
  • Oscilloscope Power Analysis - Capturing transients
  • DIY Current Shunt Design - Building custom measurement rigs

What to Measure:

Case Studies:

  • RAKwireless Profiling - Real deployment debugging
  • ESP32 Power Anomalies - Common measurement pitfalls

Platform-Specific:

7.8 Try It Yourself

7.8.1 Exercise 1: Shunt Resistor Selection

Goal: Choose appropriate shunt value for different current ranges.

Given: Measuring sensor with 10µA sleep, 50mA active. Voltmeter has 1mV resolution.

Calculate:

  1. For 10µA measurement, minimum shunt value for 1mV drop?
  2. For 50mA measurement, maximum shunt value to stay below 100mV drop (avoid affecting voltage)?
  3. Can one shunt cover both ranges?

Solution:

  1. R = V/I = 1mV / 10µA = 100Ω minimum
  2. R = V/I = 100mV / 50mA = 2Ω maximum
  3. No—100Ω at 50mA = 5V drop (kills device). Need switchable shunts or auto-ranging tool.

7.8.2 Exercise 2: Anomaly Detective

Scenario: PPK2 trace shows unexpected pattern:

Time  | Current
------|--------
0-10s | 12 µA   (deep sleep - good!)
10s   | 150 mA  (sensor read - expected)
10.5s | 10 µA   (back to sleep)
15s   | 5 mA    (SPIKE - unexpected!)
20s   | 12 µA   (sleep resumes)
...every 60 seconds, 5mA spike for 100ms

Your task: What causes the 60-second 5mA spike? (Hint: not in application code)

Answer: ESP32’s default watchdog timer wakes the CPU briefly every ~60s to verify the system is alive. Fix: esp_task_wdt_delete(NULL) or configure CONFIG_ESP_TASK_WDT=n in sdkconfig. This single configuration change saves 0.14mA average, resulting in a 17% battery life improvement.

7.9 Summary

Key measurement and profiling principles:

  1. Measure, Don’t Assume: Datasheet values are best-case; real hardware often differs
  2. Use Appropriate Tools: Match measurement resolution to expected current range
  3. Profile All States: Measure each power state independently, then full duty cycle
  4. Look for Anomalies: Unexpected current during sleep indicates optimization opportunities
  5. Validate Predictions: Use accelerated testing to verify battery life estimates
  6. Development Boards Lie: Use custom PCBs or isolate MCU for accurate low-power measurement

Common Pitfalls

Development boards include USB-to-serial chips, LEDs, and voltage regulators that add 5–20 mA baseline current. Always isolate the target MCU by powering it directly from a bench supply, bypassing the dev board’s USB power path, before measuring sleep current.

A standard multimeter averages over its 100 ms–1 s response time, completely smoothing out duty-cycle waveforms. It will show the same average whether the device has 0.1 mA sleep or 10 mA sleep if the active pulse is short enough. Always use an oscilloscope or dedicated power profiler to characterize transient current behavior.

Datasheet typical values are measured at room temperature (25°C) with minimal code running and no peripherals active. Real devices in -20°C to +60°C with full firmware often draw 20–50% more than typical. Always measure your actual hardware running your actual firmware.

A 100 Ω shunt resistor drops 100 mV at 1 mA, affecting circuit behavior significantly. For 3.3 V systems, use 1–10 Ω shunts (1–10 mV drop at 1 mA). For µA-level measurements, use a dedicated current-sensing IC (INA226) with internal 2–100 mΩ shunt.

7.10 What’s Next

If you want to… Read this
Supplement batteries with harvested energy Energy Harvesting Design
Apply low-power strategies based on measurements Low-Power Design Strategies
Analyze power across operating states Power Consumption Analysis
Practice in a simulated lab environment Hands-On Lab: Power Monitoring
Understand operational energy costs Energy Cost of Common Operations