Measurements
Last updated on October 5, 2026
Measurements Overview (one phase, three measurements)
Device Name | String | "Device-A" | x != "" | PASS
Output Voltage | Numeric | 5.00 V | 4.8 < x < 5.2 | PASS
Power Enabled | Boolean | True | x == False | FAILYou can capture numeric, string, boolean, JSON, and multi-dimensional measurements with validators and aggregations.
TofuPilot will evaluate validators, record outcomes, and timestamp each measurement.
Type
Numeric
Floating-point values with validators and aggregations
String
Text values with pattern matching and validation
Boolean
True/false values for binary state checks
JSON
Structured objects and arrays for rich device state
Multi-Dimensional
Complex data structures for charts and waveforms
Name
You can create a new measurement by adding it to the phase's measurements list.
name: Power Supply Test
main:
- name: Measure Voltage
measurements:
- name: Output VoltageTofuPilot will automatically trim whitespace and enforce a 100 character limit.
Description
You can add an optional description to explain what the measurement captures.
measurements:
- name: Output Voltage
description: "5V power rail output voltage"TofuPilot will enforce a 50,000 character limit on descriptions.
Key
You can define a key for referencing this measurement in your Python phases or YAML procedure.
measurements:
- name: Output Voltage
key: output_voltageIf not specified, TofuPilot auto-generates a key from the measurement name. You can use the key in Python phases and for binding to operator UI. Keys must be valid Python identifiers: start with a letter or underscore, followed by letters, numbers, or underscores.
Your phase must record the measurement under its key. A declared measurement the phase never records is uploaded as an empty measurement, and the phase log warns that it will be filled as empty until a value is provided in the phase. An empty measurement can't meet its validators, so it is FAIL and fails its phase. Without validators, it is UNSET. The same rule applies to the key of each y axis in a multi-dimensional measurement and to the type of each aggregation. TofuPilot Studio shows the same warning before the run when the phase's Python never writes the measurement key.
A measurement recorded as None is empty too, and fails its validators the same way. Only a phase that ran to its end is completed this way: a phase that was skipped, raised an error, or returned early with phase.retry(), phase.stop() or phase.fail() keeps only what it recorded.
A measurement recorded under a key that isn't declared is uploaded as recorded, with the validators set from Python. When a declared measurement is missing, the phase log also lists the undeclared ones, since the two are usually a naming mismatch.
Value
You can set measurement values using the measurement name as an attribute on measurements.
def measure_voltage(run, measurements, multimeter):
voltage = multimeter.read_voltage()
measurements.output_voltage = voltage TofuPilot will automatically detect the measurement type from the value.
Validators
You can validate measurements against expected ranges or patterns.
measurements:
- name: Output Voltage
validators:
- operator: ">="
expected_value: 4.8
- operator: "<="
expected_value: 5.2TofuPilot will evaluate each validator and set the measurement outcome. See type-specific pages for available operators.
Outcome
You can check measurement outcomes to determine if validators passed or failed.
TofuPilot computes the outcome from every validator on the measurement, on its aggregations and on the axes of a multi-dimensional measurement.
| Validators | Outcome |
|---|---|
| Any validator fails | FAIL |
| A validator has no value to check: the measurement, the aggregation or the axis is empty | FAIL |
| None, or aggregations without validators | UNSET |
| A validator couldn't run, such as a numeric limit on a string | UNSET |
| A declared axis or aggregation without validators was never recorded, even if every validator passed | UNSET |
| Every validator passed | PASS |
A FAIL wins over everything else. UNSET means the measurement was not fully checked.
An UNSET outcome does not affect the final phase result.
Aggregations
You can compute statistics across numeric arrays.
measurements:
- name: Voltage Readings
aggregations:
- type: mean
validators:
- operator: ">="
expected_value: 4.9Your Python phase computes and sets the aggregation values; TofuPilot validates them against the declared validators. Learn more in Aggregations.
How is this guide?