Skip to main content
Joulescope Python API automated power measurement setup for embedded firmware testing

Automating Power Measurement With the Joulescope Python API

GSAS Engineering · · 7 min read

Beyond Manual Measurement

Manual power measurement, connecting the Joulescope, starting a capture, triggering the device, reading the results from the UI, works well for one-off characterization. But modern embedded firmware development is iterative. Firmware is updated weekly or daily.

Every update can change power consumption, a new peripheral driver, a modified sleep state configuration, an updated radio stack, a bug fix that inadvertently leaves a clock gate open. Without automated power measurement, each firmware update requires a manual measurement session, and regressions slip through until someone notices that battery life has degraded in the field.

The Joulescope Python API (pyjoulescope_driver) transforms the JS220 from a manual instrument into an automated measurement node that integrates into firmware build pipelines, regression test frameworks, and continuous integration systems.

Getting Started With the Python API

Installation

The Joulescope Python package installs via pip on Windows, macOS, and Linux:

pip install joulescope

The package includes the device driver, the data acquisition interface, and utility functions for statistics computation and data export. It requires Python 3.8 or later and a USB 2.0 or USB 3.0 port.

Basic Measurement Script

A minimal measurement script opens the device, configures the sample rate, captures data for a specified duration, and computes statistics:

import joulescope
import numpy as np

with joulescope.scan_require_one(config='auto') as js:
    data = js.read(contiguous_duration=10.0)  # 10 seconds
    current = data['signals']['current']['value']
    voltage = data['signals']['voltage']['value']
    
    print(f"Mean current: {np.mean(current) * 1e6:.2f} uA")
    print(f"Peak current: {np.max(current) * 1e3:.2f} mA")
    print(f"Mean voltage: {np.mean(voltage):.3f} V")

The scan_require_one() function finds the connected Joulescope and opens it. The read() function captures the specified duration of data and returns it as NumPy arrays. From there, standard NumPy and SciPy operations provide any statistical analysis needed.

Energy Per Event

For duty-cycled devices, the key metric is energy per event, the total energy consumed during one complete operational cycle (wake, process, transmit, sleep). The API can compute this by integrating instantaneous power over the event window:

power = current * voltage
energy_joules = np.trapz(power, dx=1.0/js.sample_rate)
charge_coulombs = np.trapz(current, dx=1.0/js.sample_rate)

For devices with periodic events, capture multiple cycles and compute the statistical distribution of energy per event. The mean and standard deviation provide the inputs for battery life projection with confidence intervals.

CI/CD Integration

The Measurement Pipeline

A firmware CI/CD pipeline with power measurement follows this sequence:

  1. Build: Compile the firmware from the latest commit
  2. Flash: Program the DUT with the new firmware (via J-Link, ST-Link, or other programmer)
  3. Stabilize: Wait for the device to enter its steady-state operating mode
  4. Measure: Use the Joulescope Python API to capture a defined number of duty cycles
  5. Analyze: Compute mean current, peak current, energy per event, and sleep current
  6. Compare: Check measured values against the baseline thresholds
  7. Report: Log the results and flag any regressions

Steps 2 through 7 can be automated in a Python test script invoked by the CI system (Jenkins, GitLab CI, GitHub Actions). The Joulescope’s USB interface makes it available to any machine that can run Python and has a USB port, a dedicated test bench, a developer’s workstation, or a CI runner with physical hardware access.

Regression Detection

Define baseline thresholds for the key power metrics:

THRESHOLDS = {
    'sleep_current_ua': 2.5,      # max acceptable sleep current
    'peak_current_ma': 150.0,     # max acceptable peak current
    'energy_per_tx_uj': 500.0,    # max energy per transmission event
}

After each measurement, compare the actual values against the thresholds. If any metric exceeds its threshold, fail the CI step and alert the development team. The alert should include the measured value, the threshold, the percentage deviation, and the firmware commit hash, enabling the developer to immediately identify which change caused the regression.

Trend Tracking

Beyond pass/fail thresholds, log every measurement result to a time-series database or a simple CSV file. Over weeks and months, this data reveals trends: sleep current gradually creeping up as new features are added, energy per transmission increasing as protocol overhead grows, peak current spikes from driver changes. These trends are invisible without continuous measurement and become problems only when a customer reports reduced battery life.

Multi-Device Testing

The Python API supports multiple Joulescope devices connected to the same host. Each device is identified by its serial number, allowing scripts to address specific instruments in a multi-device test setup. This enables parallel testing of multiple DUT variants, multiple firmware configurations, or multiple operating conditions simultaneously.

For production testing, a multi-Joulescope setup can measure every unit coming off the production line, screening for units with abnormal power consumption, a proxy for manufacturing defects such as solder bridges, cold joints, or missing components that alter the power profile.

Data Export and Analysis

The API exports data in JLS (native lossless), CSV, and raw binary formats. JLS files preserve the full 2 Msps data stream and can be reopened in the Joulescope UI for visual analysis. CSV exports are suitable for import into spreadsheet tools or custom analysis scripts. Raw binary exports provide the fastest data transfer for high-throughput automated analysis.

For advanced analysis, the captured data integrates naturally with the Python scientific computing ecosystem, NumPy for numerical computation, SciPy for signal processing and statistical analysis, Matplotlib for visualization, and Pandas for time-series data management.

Why Buy Joulescope From GSAS

GSAS provides Joulescope instruments with INR invoicing and technical support from offices in Bengaluru, Hyderabad, Chennai, Pune, Mumbai, and Delhi NCR. Our team assists with Python API integration, CI/CD pipeline setup, and measurement methodology for automated power profiling workflows.

Contact sales@gsasindia.com or call +91 80 6590 1783 to discuss your power measurement requirements.

Interested in Joulescope tools?

Talk to our application engineers for personalized tool recommendations.

Stay in the Loop

Get monthly compliance updates, product insights, and engineering best practices delivered to your inbox.

Related Articles

Embedded engineering bench in India, illustrating the hardware a developer can act on today, supported by GSAS
Technical Guides Arm

Arm's Agentic AI Push: What Indian Embedded Teams Can Actually Use Today

Arm has set out its platform strategy for the agentic era, putting inference everywhere it has compute. Indian embedded teams can start on that direction this quarter with the Cortex-M toolchain they already own: Helium, CMSIS-NN, Ethos-U and Vela, on boards you can order today.

13 Sept 2026 · 7 min read
Horizontal stacked bar showing where an ADAS test vehicle's bandwidth budget is spent, split into cameras, lidar, radar and bus traffic, with the logger uplink limit drawn as a vertical rule crossing the bar, from GSAS Micro Systems India
Automotive Ethernet Automotive & Mobility

ADAS Sensor Data Logging: Bandwidth Budgets That Add Up

Every page that tells you an ADAS test vehicle produces terabytes a day states the headline and skips the arithmetic, so you cannot redo it for your own sensor set. This article publishes the arithmetic instead: one formula, every table row derived on the page, a worked eight-hour drive that chains those rows into a sustained write rate, a media count and an offload window, and the five places bandwidth budgets go wrong. Written by the GSAS Micro Systems engineering team in India.

29 Aug 2026 · 15 min read
Ladder chart of the T1 single-pair Ethernet family by data rate: 10BASE-T1S (802.3cg), 100BASE-T1 (802.3bw), 1000BASE-T1 (802.3bp), 2.5/5/10GBASE-T1 (802.3ch) and 25GBASE-T1 (802.3cy), one balanced pair across five IEEE standards, from GSAS Micro Systems India
Automotive Ethernet Automotive & Mobility

The T1 Family Explained: 10BASE-T1S to Multi-Gig 802.3ch

The T1 family is the set of single-pair Ethernet physical layers used in vehicles, and every member is documented separately inside a different datasheet. This guide puts all of them in one table with rate, symbol rate, line code, specified reach and cabling traced to public IEEE task force documents, then answers the two questions that keep coming back: why 100BASE-T1 has no auto-negotiation, and why one end has to be master. Written by the GSAS Micro Systems engineering team in India.

29 Aug 2026 · 13 min read