Virtual sensors
Overview
Virtual sensors allow displaying value calculated using:
- data from any sensors
- mathematical formulas
This powerful tool can can display gauges, piecharts, textual information, etc.
Data calculated by virtual sensors can also be viewed in charts module.
Visualization
Limits
Basic feature set allows you to create one virtual sensor per gateway.
This limit can be upgraded to up to 30 virtual sensors per gateway.
Formulas
Writing a formula
A formula is a mathematical expression.
Example 1 - summing power
Lets say we have two energy meters:
- e1 - a main incomer
- e2 - photovoltaic energy generation
and we would like to display how much power is our warehouse using at the moment.
To do that we need to add power from both meters. We can do it using this simple formula:
val("e1.pwr") + val("e2.pwr")
Example 2 - average temperature
Lets say we have three 1-Wire temperature sensors and we would like to find out what is the average temperature.
We can do it using this simple formula:
( val(70) + val(71) + val(72) ) / 3
Basic functions
Function | Description |
---|---|
val(sensorId) | returns value of sensor (recommended) |
raw(sensorId) | returns raw value of sensor (special use only) |
if(x,a,b) | if X then a else b |
text(x,a,b) | if X then a else b |
fixed(x,y) | display numeric value x as decimal with y digits after dot |
Mathematical functions
Function | Description |
---|---|
sin(x) | Sine of x (x is in radians) |
cos(x) | Cosine of x (x is in radians) |
tan(x) | Tangent of x (x is… well, you know) |
asin(x) | Arc sine of x (in radians) |
acos(x) | Arc cosine of x (in radians) |
atan(x) | Arc tangent of x (in radians) |
sqrt(x) | Square root of x. Result is NaN (Not a Number) if x is |
log(x) | Natural logarithm of x (not base-10). |
abs(x) | Absolute value (magnatude) of x |
ceil(x) | Ceiling of x — the smallest integer that’s >= x. |
floor(x) | Floor of x — the largest integer that’s <= x |
round(x) | X, rounded to the nearest integer. |
exp(x) | ex (exponential/antilogarithm function with base e) |
Aditional functions
Function | Description |
---|---|
random(n) | Get a random number in the range [0, n). If n is zero, or not provided, it defaults to 1. |
fac(n) | n! (factorial of n: “n * (n-1) * (n-2) * … * 2 * 1″) |
min(a,b,…) | Get the smallest (“minimum”) number in the list |
max(a,b,…) | Get the largest (“maximum”) number in the list |
pyt(a, b) | Pythagorean function, i.e. the c in “c2 = a2 + b2“ |
pow(x, y) | xy. This is exactly the same as “x^y”. |
atan2(y, x) | arc tangent of x/y. i.e. the angle between (0, 0) and (x, y) in radians. |