How to convert value with a stepwise linear function?

Using a plugin to convert value with a stepwise linear function

The msg-param-calibrate plugin enables efficient conversion of digital values based on a custom-defined stepwise function table. Ideal for applications requiring precise mapping between input values and their corresponding output ranges, the plugin allows users to define intervals and assign specific outputs for each range, creating a smooth, tailored value transformation process.

The plugin can be particularly useful in IoT or industrial automation, where sensor readings—such as temperature, fuel, pressure, or light levels—require precise conversion into specific output ranges.

How to use

Click on the "+" button in the Telematics Hub -> Plugins section to create a new plugin:flespi panel telematics hub plugins

Let's define a new plugin to help convert value from parameter param.1 and add the param.1.out message parameter:

Note: you can specify the same name of the output parameter as the input parameter, in this case, the parameter value will be overwritten. The plugin can only be applied to messages that are validated using the expression specified in the Validate message field.


Then we need to assign this plugin to the right devices. Go to the Plugins tab for the required device and click the "+" button:


At this stage, filling in the table for the transformation function is necessary. For example:

  points/values
1
2
3
4
5
6
input
401
530
645
700
803
1005
output
3.5
4.1
5.7
6.1
7.0
8.2


Note: In cases where the input value is out of range, a plugin error will be generated and the value will not be converted. To handle such cases, specify the Min error value and Max error value that will be set in the output parameter.


Note: you can change these values after the plugin assignment::


Now you can go to the device Logs&Messages tab and see how the values are converted:


Change log

Subscribe to the msg-param-calibrate change log to stay in sync with any updates.

More plugin types

Find a comprehensive list of available plugin types here.


See also
How to add data generated by calculators to device messages
Explore the pros and cons of various reverse geocoding services supported by flespi.