# Elementary math, how to solve this?

``````var real_pH = "real pH";
real_pH =pHSlope - pH_current;
msg.topic = "pH";
return real_pH;
``````

function do nothing return., sorry for my english.
Some is missing, Thanks.

You must always return a message. Probably at the end you want

``````msg.payload = real_pH
return msg
``````

Couldn't that be -

``````var pHSlope = msg.payload.pHSlope;
var real_pH = pHSlope - pH_current;
``````

or preferably -

``````const pHSlope = msg.payload.pHSlope;
const real_pH = pHSlope - pH_current;
``````
``````var real_pH = "real pH";
real_pH =pHSlope - pH_current;
//msg.topic = "pH";
return msg
//return msg
//return real_pH;
``````

NaN

I don't think that the paths are correct for retrieving the values in your function node for `pHSlope` and `current`.

Thereâ€™s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

Holy cats! Dude, chill out. We are all here to help as we can.

If you put a flag of the Russian Federation on your avatar, would we even recognise it as a flag, unless you drew our attention to it?

(For the benefit of anyone like me who doesn't know without googling, it's horizontal stripes, white, blue, red)

Thanks very much.

What am I, to associate two colors with something! And I thought higher mathematics was complicated greetings.

``````[
{
"id": "7a04b08e2eab1a33",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c46a5c92f29f3709",
"type": "join",
"z": "7a04b08e2eab1a33",
"name": "",
"mode": "custom",
"build": "object",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 570,
"y": 320,
"wires": [
[
"19d8a890e7db135c",
"aba6e607dc568136"
]
]
},
{
"id": "aba6e607dc568136",
"type": "function",
"z": "7a04b08e2eab1a33",
"name": "function 4",
"func": "var real_pH = real_pH;\nvar pHSlope = msg.payload.pHSlope;\nvar current = msg.payload.current;\nreal_pH = pHSlope - current ;\nmsg.topic = \"pH\";\nmsg.payload = real_pH;\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 720,
"y": 320,
"wires": [
[
"94b65cd2bebab7f9"
]
]
},
{
"id": "94b65cd2bebab7f9",
"type": "debug",
"z": "7a04b08e2eab1a33",
"name": "debug 6",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 880,
"y": 320,
"wires": []
},
{
"id": "edd70a9c95a7cbd3",
"type": "inject",
"z": "7a04b08e2eab1a33",
"name": "",
"props": [
{
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "current",
"x": 430,
"y": 340,
"wires": [
[
"c46a5c92f29f3709"
]
]
},
{
"id": "19d8a890e7db135c",
"type": "debug",
"z": "7a04b08e2eab1a33",
"name": "debug 8",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 280,
"wires": []
},
{
"type": "inject",
"z": "7a04b08e2eab1a33",
"name": "",
"props": [
{
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "pHSlope",
"x": 430,
"y": 300,
"wires": [
[
"c46a5c92f29f3709"
]
]
}
]
``````

That's how it works. I just went the wrong way to solve the task. Thanks to everyone who took the time to resolve this issue. I apologize that I was misunderstood earlier in the topic. I didn't mean to offend anyone in any way. Once again, I offer my apologies.

2 Likes