Average Three Sensor Values

This example uses the Math block to calculate the average of three numeric sensor readings.

Required blocks

  • Three sensor or device blocks with numeric outputs
  • Math
  • An optional block that stores or displays the result

Program flow

Sensors a, b and c → Math → Average value

Configuration

  1. Add the three sensor sources and a Math block to the workspace.
  2. Use the + control on the Math block to add input c.
  3. Connect the three sensor values to inputs a, b and c.
  4. Enter (a + b + c) / 3 in the F(x) field.
  5. Connect the F(x) output to the block that should use the average.

Example calculation

For the readings 21, 22 and 23, the formula calculates:

(21 + 22 + 23) / 3 = 22

Result

Whenever one of the sensor readings changes, the Math block recalculates the average and passes the new value to its output.