TofuPilotTofuPilot

Numeric

Record numeric values with range validation.

Temperature
23.45°C
20<x<25
Pass
Output Voltage
4.50V
4.8<x<5.2
Fail
Current
0.15A
x!=0
Pass

You can create a numeric measurement with measurements:

measurements:
  - name: Output Voltage
    unit: V
    validators: 
      - operator: ">="
        expected_value: 4.8
      - operator: "<="
        expected_value: 5.2

You can set the measurement value in your Python phase:

def measure_voltage(run, measurements, multimeter):
    voltage = multimeter.read_voltage()
    measurements.output_voltage = voltage 

Definition

You can configure the measurement name and metadata.

PropertyTypeRequiredDescription
keystringNoUnique identifier for the measurement within the phase
namestringYesDisplay name (1-100 characters)
unitstringNoMeasurement unit (e.g., "V", "A", "°C", max 50 characters)
descriptionstringNoDetailed description (max 50,000 characters)

TofuPilot auto-generates the key from name (snake_case) if not specified, and uses it for Python access (e.g., measurements.output_voltage). The unit and description display in the web interface and reports.

Validators

You can add one or several validators to your measurement using the following properties:

PropertyTypeRequiredDescription
operatorstringYesComparison operator
expected_valuenumber or arrayYesExpected value(s) for comparison

You can use the following operators for numeric measurements:

OperatorExpected ValueDescriptionExample
==NumberValue must equal expectedexpected_value: 5.0
!=NumberValue must not equal expectedexpected_value: 0.0
>NumberValue must be greater thanexpected_value: 4.8
>=NumberValue must be greater than or equalexpected_value: 4.8
<NumberValue must be less thanexpected_value: 5.2
<=NumberValue must be less than or equalexpected_value: 5.2
inArray of numbersValue must be in the arrayexpected_value: [5.0, 12.0, 24.0]
not inArray of numbersValue must not be in the arrayexpected_value: [0.0, -1.0]

TofuPilot evaluates validators and sets the outcome to Pass if met, Fail if not, or Unset if no value provided.

You can use Aggregations for statistical validation on numeric arrays.

Examples

Voltage Measurement

We will measure output voltage with min/max limits:

phases:
  - name: Power Supply Test
    python:
      module: measure_voltage
    measurements:
      - name: Output Voltage
        unit: V
        description: Main power supply output voltage
        validators:
          - operator: ">="
            expected_value: 4.8
          - operator: "<="
            expected_value: 5.2
def measure_voltage(run, multimeter):
    log.info("Measuring output voltage")

    voltage = multimeter.read_voltage()
    measurements.output_voltage = voltage

    if voltage < 4.8 or voltage > 5.2:
        log.warning(f"Voltage out of spec: {voltage} V")

Set Point Validation

We will validate voltage is one of the allowed setpoints:

phases:
  - name: Voltage Check
    python:
      module: check_voltage
    measurements:
      - name: Output Voltage
        unit: V
        description: Verify output matches one of the valid setpoints
        validators:
          - operator: in
            expected_value: [5.0, 12.0, 24.0]
def check_voltage(run, multimeter):
    log.info("Checking voltage setpoint")

    voltage = multimeter.read_voltage()
    measurements.output_voltage = voltage

    if voltage not in [5.0, 12.0, 24.0]:
        log.warning(f"Unexpected voltage: {voltage} V")

How is this guide?