Scaling data in svg plot. ( unit conversion )

Begonnen von Wallyllama, 23 März 2021, 06:09:23

Vorheriges Thema - Nächstes Thema

Wallyllama

I have a bme280 tenp/pressure/humidity sensor reporting via MQTT. I graph them with gplot. Sofar, so good. The problem is pressure is reported in Pascals. I could modify the code that reads the me, but I'm hoping there is a way to app,y a scale to each reading as the gis made. made. For example multiplying Pascals by 0.00296 gives in hes of mercury, or dividingb by100 gives hPa,

xenos1984

You can use the fourth parameter in a plot data entry to specify a function, which is applied to each data point. For example, if your plot line reads


#FileLog 4:pressure:0:


you can divide each pressure value by 100 like this:


#FileLog 4:pressure:0:($fld[3]*0.01)

rudolfkoenig

#2
The function field is also present in the SVG-Editor, it is the last text-input field in the row.
Note: $fld[ x ] is a perl array, the index starts with 0.

Wallyllama

perfect! thank you, I knew it would be somewhat obvious once i knew the answer.  :)    oh and sorry about duplicating this. I don't see that I can delete the other one.   :(

EmCeBeh

#4
I am trying to accomplish the same thing, but I am using dbLogging.

Readings come from a KM200, so they have these weird names with slashes.

Here is the excerpt from the Gplot file.
But I am still getting the normal value

    #DBLogging LANiMB:/heatSources/workingTime/totalSystem::(fld[1]*0.001)
    plot "<IN>" using 1:2 axes x1y1 title 'Central Heating' ls l2 lw 1 with steps

Also this did not work:

    #DBLogging LANiMB:/heatSources/workingTime/totalSystem::
    plot "<IN>" using 1:(2/1000) axes x1y1 title 'Central Heating' ls l2 lw 1 with steps


I know this is a 2-year old thread, but it seemed fitting to ask here, googling will lead you here.

betateilchen

Please do not modify the plot... line unless you really know, what you do.

$fld is not available in plots based on DbLog. Instead you have to adjust the value itself, which is available as $val.

E.g. like this to divide by 100:

#DbLog LANiMB:/heatSources/workingTime/totalSystem:::$val=$val/100
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!