5.1.16.1 Getting started
Purpose:
Allows user-defined mathematical expressions to process incoming sensor data.
Syntax in user-defined code
F14,<formula>,<A_pos>,<B_pos>,<C_pos>,<D_pos>
<formula>: A math expression using sensor placeholders (A, B, C, D), configurable global variables (G, H, I, K, L, M), the previous result (R), and temporary runtime variables (X, Y, Z).
<A_pos> to <D_pos>: Indexes referring to the values in the sensorString, starting after the timestamp
In the SmartConfig2 formula editor, the corresponding inputs are shown as a, b, c, and d. Their positions refer to fields in the last comma-separated sensor-data string and are one-based. Enter 0 when an input is not used.
Placeholders
| Placeholder | Description |
|---|---|
A–D | Values from the sensorString |
G, H, I, K, L, M | Six configurable global values available to user-defined formulas |
R | Result from the previous F14 calculation |
X–Z | Temporary runtime values for intermediate calculations |
The result of each calculation is stored in R, which can be used in subsequent formulas. SmartConfig2 also displays the result as r in supported value selectors.
Global variables allow the same formula to reuse configured values without changing the formula itself. For example, A * G multiplies sensor input A by the current value of global variable G. Set the required global value before running the program.
Configure and test a formula
- Open a formula action in the Visual Programmer.
- Enter the expression and the four input positions. Use
0for an unused position. - Enter a representative comma-separated sensor string in the test area.
- Select Test formula to display the resolved inputs and result.
- Use the validation feedback to correct an invalid expression or position before selecting OK.
Supported expressions include arithmetic operators, parentheses, unary plus and minus, supported constants, named runtime variables, and supported single-argument mathematical functions. Commas must not be entered inside the expression because commas separate the F14 fields.
Example
Configuration line:
F14,A*1,2,0,0,0
Incoming sensor string:
2025/06/23 09:46:50,12453,0,22.3
After skipping the timestamp:
- Index 0 →
12453 - Index 1 →
0 - Index 2 →
22.3
A = 22.3
Formula: A * 1
Result: R = 22.3
Notes
- Comma-separated
sensorStringvalues are indexed starting at 0 (after timestamp). - In the formula editor, input positions for
a–dare one-based fields in the sensor-data string; use0for an unused input. - Only available in User-Defined Mode
- Avoid invalid math operations, such as division by zero. Invalid expressions produce an evaluation error rather than a usable numeric result.
- Missing or out-of-range selected inputs are treated as zero by SmartSampler2.
- Use the Simulation tab to check how the formula result affects later actions.
- Useful for scaling, offsetting, combining, or converting raw values on-device.
