Read up on variable types.? There are very good tutorials on the Node-Red.org web site:
In your case, you want to do the math on two variables.? The problem is getting both variables into the same node at the same time.
-Messages "flow" through?the nodes.? They only exist in the node in one instant of time, then pass to the next node.
- Context variables are stored in Node-Red memory and can be called into a function for doing the math.? As Dave points out, you must first get your variables stored in "context", then pull each into a function to do the math.
There are lots of ways to get a message to a context variable.? A common way is to use the change node.? Say you want to put the payload into a context location called ""
Then to add "xyz" to "abc" in a function node and output the result to "msg.payload"
On Mon, Jan 25, 2021 at 12:38 PM wa9mvz via <wa9mvz=[email protected]> wrote:
Sure. It's easy to start writing flows similar to BLINK and turn an LED on from an input. But once I get past that point it's like drinking from a fire hose.
I've been trying to figure out how to do a simple task like multiply two numbers together. I have a data stream coming in through a Serial port that is working and using a CALCULATOR node I can divide that by a constant. But I need to multiply it by a number from an INJECT node. I haven't found any tutorial that tells me how to do that that doesn't assume I'm an expert in NODE RED and JAVA.
Can anyone point me in the right direction? It's obvious I'm missing something very fundamental here. This should be easy.