pH calibration, whats is wrong?

[
    {
        "id": "9bbec62db580ce90",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "952dcb48.6ad238",
        "type": "inject",
        "z": "9bbec62db580ce90",
        "name": "Start calibrating",
        "props": [
            {
                "p": "payload",
                "v": "",
                "vt": "str"
            },
            {
                "p": "topic",
                "v": "",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "",
        "payload": "",
        "payloadType": "none",
        "x": 420,
        "y": 200,
        "wires": [
            [
                "8b8be754.747418"
            ]
        ]
    },
    {
        "id": "8b8be754.747418",
        "type": "function",
        "z": "9bbec62db580ce90",
        "name": "Set pH Calibration Mode",
        "func": "context.global.pHCalibrationMode = 1;\nreturn {payload: 'Please place pH meter in ph7 solution and then click \"pH7\"'};\n",
        "outputs": 1,
        "x": 630,
        "y": 240,
        "wires": [
            [
                "16451420.e9baec"
            ]
        ]
    },
    {
        "id": "16451420.e9baec",
        "type": "debug",
        "z": "9bbec62db580ce90",
        "name": "",
        "active": true,
        "console": false,
        "complete": false,
        "x": 850,
        "y": 320,
        "wires": []
    },
    {
        "id": "79d7b6a.f862848",
        "type": "inject",
        "z": "9bbec62db580ce90",
        "name": "pH7",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "pH7",
        "payload": "",
        "payloadType": "date",
        "x": 410,
        "y": 243,
        "wires": [
            [
                "e4f249d4.1b0db8"
            ]
        ]
    },
    {
        "id": "e4f249d4.1b0db8",
        "type": "function",
        "z": "9bbec62db580ce90",
        "name": "Calibration Routine",
        "func": "if (!context.global.pHCalibrationMode) {\n\tif (msg.topic !== 'pHmV') {\n\t\treturn {payload: 'Start by clicking \"Start Calibration\"'};\n\t}\n\treturn null;\n}\nif (msg.topic !== 'pHmV') {\n\t// user has clicked pH7 or pH4.\n\tif (msg.topic === 'pH4' && !context.pH7) {\n\t\tif (context.calSol === 'pH7') {\n\t\t\treturn {payload: 'Please allow pH7 calibration to finish'};\n\t\t}\n\t\treturn {payload: 'Please calibrate for pH7 first'};\n\t}\n\tcontext.calSol = msg.topic;\n\tcontext.readings = [];\n\treturn {payload: 'Calibrating for '+context.calSol+' buffer. This will take a few minutes'};\n}\n// at this point we know that we are in calibration\n// mode and that the topic is pHmV\nif (context.calSol) {\n\t// we are calibrating for a particular buffer\n\tif (context.readings.length < 4) {\n\t\tcontext.readings.push(parseFloat(msg.payload));\n\t\tif (context.readings.length < 4) {\n\t\t\treturn {payload: 'Still calibrating ...'};\n\t\t}\n\t}\n\t// we have 4 readings - ignore first and average\n\tvar sum = context.readings[1] + context.readings[2] + context.readings[3];\n\tvar avg = (sum/3).toFixed(1);\n\tif (context.calSol === 'pH7') {\n\t\t// save value and prompt for next action\n\t\tcontext.pH7 = avg;\n\t\tcontext.calSol = null;\n\t\treturn {payload: 'Reading for pH7 is '+avg+'mV. Please place probe in pH4 buffer and click \"pH4\"'};\n\t}\t\n\tif (context.calSol === 'pH4') {\n\t\t// calculate the slope and save to DB\n\t\tcontext.pH4 = avg;\n\t\tcontext.calSol = null;\n\t\tvar pHSlope = (context.pH7 - context.pH4)/3;\n\t\tvar pH7Cal = context.pH7;\n\t\t// prompt for user\n\t\tvar payload1 = 'Reading for pH4 is '+avg+'mV. Please put probe back in tank and click \"Stop calibration\"';\n\t\t// save the data in global and also send to server to store\n\t\tcontext.global.config.pHSlope = pHSlope;\n\t\tcontext.global.config.pH7Cal = pH7Cal;\n\t\tvar payload2 = {'pH7Cal': pH7Cal, 'pHSlope': pHSlope};\n\t\treturn [{payload: payload1}, {payload: payload2}];\n\t}\n}",
        "outputs": "2",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 300,
        "wires": [
            [
                "16451420.e9baec"
            ],
            [
                "d75eabd65c96cfe0"
            ]
        ]
    },
    {
        "id": "91108d92.6eef7",
        "type": "mqtt in",
        "z": "9bbec62db580ce90",
        "name": "",
        "topic": "pHmV",
        "qos": "2",
        "datatype": "auto",
        "broker": "db8d87b45baa46fd",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 950,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "9825da87.67da28",
        "type": "inject",
        "z": "9bbec62db580ce90",
        "name": "pH4",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "pH4",
        "payload": "",
        "payloadType": "date",
        "x": 410,
        "y": 340,
        "wires": [
            [
                "e4f249d4.1b0db8"
            ]
        ]
    },
    {
        "id": "f0e08555.0f1f78",
        "type": "comment",
        "z": "9bbec62db580ce90",
        "name": "Click BEFORE taking probe out of tank",
        "info": "",
        "x": 430,
        "y": 146,
        "wires": []
    },
    {
        "id": "c3a09708.3c5f68",
        "type": "inject",
        "z": "9bbec62db580ce90",
        "name": "Stop calibrating",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 423,
        "y": 488,
        "wires": [
            [
                "a991a199.566e6"
            ]
        ]
    },
    {
        "id": "a991a199.566e6",
        "type": "function",
        "z": "9bbec62db580ce90",
        "name": "Unset pH Calibration Mode",
        "func": "context.global.pHCalibrationMode = 0;\nreturn {payload: 'Business as usual!'};\n",
        "outputs": 1,
        "x": 681,
        "y": 489,
        "wires": [
            [
                "16451420.e9baec"
            ]
        ]
    },
    {
        "id": "7b0be4bf.84f41c",
        "type": "comment",
        "z": "9bbec62db580ce90",
        "name": "Click AFTER placing probe back in tank",
        "info": "",
        "x": 429,
        "y": 447,
        "wires": []
    },
    {
        "id": "1e8ab965.e17547",
        "type": "mqtt out",
        "z": "9bbec62db580ce90",
        "name": "",
        "topic": "save config",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "db8d87b45baa46fd",
        "x": 1090,
        "y": 420,
        "wires": []
    },
    {
        "id": "4baf3acfa1a1cf50",
        "type": "inject",
        "z": "9bbec62db580ce90",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "pHmV",
        "payload": "10",
        "payloadType": "num",
        "x": 420,
        "y": 280,
        "wires": [
            [
                "e4f249d4.1b0db8"
            ]
        ]
    },
    {
        "id": "5bd8fa2fc401bec6",
        "type": "inject",
        "z": "9bbec62db580ce90",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "pHmV",
        "payload": "180",
        "payloadType": "num",
        "x": 420,
        "y": 380,
        "wires": [
            [
                "e4f249d4.1b0db8"
            ]
        ]
    },
    {
        "id": "d75eabd65c96cfe0",
        "type": "debug",
        "z": "9bbec62db580ce90",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 400,
        "wires": []
    },
    {
        "id": "db8d87b45baa46fd",
        "type": "mqtt-broker",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

I found this flow to calibrate the pH electrode in Github but something is wrong. To simulate calibration press Start calibrating, then pH7, then pHmV10 four times, then ph4,
then pHmV180 four times, after which the error occurs. what is wrong? Thanks.

Maybe you should ask the author of the repository where you got it from.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.