Need help with read multi msg of capteurs

when i read data from one capteur i get data
but when i plugin multi to request i get code only of one of them

{i m working with io-link ifm profinet }
and thanks

[
    {
        "id": "555b4dbf57792b4b",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "PORT 05 flow SM8100",
        "func": "msg.payload = {\n  \"code\": \"request\",\n  \"cid\": 105,\n  \"adr\": \"/iolinkmaster/port[5]/iolinkdevice/pdin/getdata\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 480,
        "wires": [
            [
                "4175b53f8902b927"
            ]
        ]
    },
    {
        "id": "f1cc96d1fd963ccb",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "PORT 1 conductivity",
        "func": "msg.payload = {\n  \"code\": \"request\",\n  \"cid\": 101,\n  \"adr\": \"/iolinkmaster/port[1]/iolinkdevice/pdin/getdata\"\n}\nconst port=1\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "b59aa875bd4791e4",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "",
        "func": "var str = msg.payload.data.value;\nvar part1 = str.substr(0, 8);\nvar part2 = str.substr(16, 4);\nvar part3 = str.substr(16, 4);\nvar level = parseInt(part3, 16);\nvar conduct=parseInt(part1,16);\nvar Temp=parseInt(part2,16)/10;\nvar now = new Date();\n\n\n   // now.setTime(now.getTime() - 1000*60*60*24*i);\n    let yyyy = now.getFullYear();\n    let mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\n    let dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\n    let hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\n    let mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\n    let ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\n\ntime_jour = yyyy+\"/\"+mm+\"/\"+dd\ntime_heure = hh+\":\"+mmm+\":\"+ss\n\nmsg.payload = {\"jour\":time_jour,\"heure\":time_heure,\"capteur\":msg.payload.cid,\"conductivity\":conduct,\"Temperature_C\":Temp,\"level1\":level};\nmsg.topic = {};\nmsg.topic.temp = Temp;\n//let output = [];\n//let newfile = {\"filename\":\"\",\"pattern\":\"\"};\n    // Generate out file name pattern\n//CC = \"AWS_D05E40\"+ yyyy + mm + dd + \".csv\";\n    // Full filename with path \n//fname = \"E:\\DATAS\\AWS_D05E40\\\"+CC;\n// Shell script only needs the filename without the path\n//  newfile.payload = newfile.fname;\n //output.push(fname);\n// return output;\n return msg;\n\n\n",
        "outputs": 1,
        "noerr": 4,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 460,
        "wires": [
            [
                "d8133f527cbdd252",
                "77b8437b07358c47"
            ]
        ]
    },
    {
        "id": "8e97d50d9d091a75",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "PORT 3 PRESSION PV7023",
        "func": "msg.payload = {\n  \"code\": \"request\",\n  \"cid\": 103,\n  \"adr\": \"/iolinkmaster/port[3]/iolinkdevice/pdin/getdata\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 520,
        "wires": [
            [
                "4175b53f8902b927"
            ]
        ]
    },
    {
        "id": "d8133f527cbdd252",
        "type": "csv",
        "z": "2d3171600182df85",
        "name": "Data en csv",
        "sep": ";",
        "hdrin": true,
        "hdrout": "none",
        "multi": "one",
        "ret": "\\r\\n",
        "temp": "jour,heure, capteur, conductivity, Temperature_C",
        "skip": "0",
        "strings": true,
        "include_empty_strings": "",
        "include_null_values": "",
        "x": 870,
        "y": 520,
        "wires": [
            [
                "0c0e871d130c48c2"
            ]
        ]
    },
    {
        "id": "1b7b58df11f62e2d",
        "type": "debug",
        "z": "2d3171600182df85",
        "name": "request info",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 320,
        "wires": []
    },
    {
        "id": "ac0ee1c732dd9340",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "PORT 1 NIVEAU LMT121",
        "func": "msg.payload = {\n  \"code\": \"request\",\n  \"cid\": 101,\n  \"adr\": \"/iolinkmaster/port[1]/iolinkdevice/pdin/getdata\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 380,
        "wires": [
            [
                "4175b53f8902b927"
            ]
        ]
    },
    {
        "id": "9f6c64401ff3f09c",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "PORT 6 conductivity LDL100",
        "func": "msg.payload = {\n  \"code\": \"request\",\n  \"cid\": 106,\n  \"adr\": \"/iolinkmaster/port[6]/iolinkdevice/pdin/getdata\"\n}\nmsg.topic = \"6\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 440,
        "wires": [
            [
                "4175b53f8902b927"
            ]
        ]
    },
    {
        "id": "12364aca06f77459",
        "type": "debug",
        "z": "2d3171600182df85",
        "name": "read saved",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1170,
        "y": 520,
        "wires": []
    },
    {
        "id": "0c0e871d130c48c2",
        "type": "file",
        "z": "2d3171600182df85",
        "name": "aws",
        "filename": "C:\\Users\\issam\\Desktop\\Nouveau dossier\\node-red\\DATA6.csv",
        "filenameType": "str",
        "appendNewline": false,
        "createDir": true,
        "overwriteFile": "false",
        "encoding": "none",
        "x": 1010,
        "y": 520,
        "wires": [
            [
                "12364aca06f77459"
            ]
        ]
    },
    {
        "id": "4175b53f8902b927",
        "type": "www-request",
        "z": "2d3171600182df85",
        "name": "",
        "method": "POST",
        "ret": "obj",
        "url": "169.254.139.233",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 650,
        "y": 400,
        "wires": [
            [
                "b59aa875bd4791e4",
                "5bd1b566d472b142",
                "b8989878a906723b",
                "1b7b58df11f62e2d"
            ]
        ]
    },
    {
        "id": "77b8437b07358c47",
        "type": "debug",
        "z": "2d3171600182df85",
        "name": "function stat",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 990,
        "y": 460,
        "wires": []
    },
    {
        "id": "53a9f66d05006c69",
        "type": "ui_gauge",
        "z": "2d3171600182df85",
        "name": "",
        "group": "2ff6d882991dde75",
        "order": 7,
        "width": 5,
        "height": 5,
        "gtype": "gage",
        "title": "conductivity",
        "label": "units",
        "format": "{{value}}",
        "min": 0,
        "max": "1500",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 1390,
        "y": 360,
        "wires": []
    },
    {
        "id": "9b0a7d2137c16023",
        "type": "debug",
        "z": "2d3171600182df85",
        "name": "ifo of gagugs",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1370,
        "y": 400,
        "wires": []
    },
    {
        "id": "5bd1b566d472b142",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "function 35",
        "func": "\nvar str = msg.payload.data.value;\nvar part1 = str.substr(0, 8);\nvar part2 = str.substr(16, 4);\nvar conduct = parseInt(part1, 16);\nmsg.payload =  conduct ;\n\n//let output = [];\n//let newfile = {\"filename\":\"\",\"pattern\":\"\"};\n// Generate out file name pattern\n//CC = \"AWS_D05E40\"+ yyyy + mm + dd + \".csv\";\n// Full filename with path \n//fname = \"E:\\DATAS\\AWS_D05E40\\\"+CC;\n// Shell script only needs the filename without the path\n//  newfile.payload = newfile.fname;\n//output.push(fname);\n// return output;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1170,
        "y": 380,
        "wires": [
            [
                "53a9f66d05006c69",
                "9b0a7d2137c16023"
            ]
        ]
    },
    {
        "id": "b8989878a906723b",
        "type": "function",
        "z": "2d3171600182df85",
        "name": "function 36",
        "func": "\nvar str = msg.payload.data.value;\nvar part1 = str.substr(0, 8);\nvar part2 = str.substr(16, 4);\n\nvar Temp = parseInt(part2, 16) / 10;\nmsg.payload = Temp ;\n\n//let output = [];\n//let newfile = {\"filename\":\"\",\"pattern\":\"\"};\n// Generate out file name pattern\n//CC = \"AWS_D05E40\"+ yyyy + mm + dd + \".csv\";\n// Full filename with path \n//fname = \"E:\\DATAS\\AWS_D05E40\\\"+CC;\n// Shell script only needs the filename without the path\n//  newfile.payload = newfile.fname;\n//output.push(fname);\n// return output;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1150,
        "y": 420,
        "wires": [
            [
                "9b0a7d2137c16023",
                "55b5fb0e943e352e"
            ]
        ]
    },
    {
        "id": "55b5fb0e943e352e",
        "type": "ui_gauge",
        "z": "2d3171600182df85",
        "name": "Temperature",
        "group": "2ff6d882991dde75",
        "order": 18,
        "width": "5",
        "height": "5",
        "gtype": "gage",
        "title": "gauge",
        "label": "°C",
        "format": "{{value}}",
        "min": 0,
        "max": "50",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 1390,
        "y": 440,
        "wires": []
    },
    {
        "id": "9721c9d82ccacaf3",
        "type": "inject",
        "z": "2d3171600182df85",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 190,
        "y": 460,
        "wires": [
            [
                "8e97d50d9d091a75",
                "ac0ee1c732dd9340",
                "555b4dbf57792b4b",
                "9f6c64401ff3f09c"
            ]
        ]
    },
    {
        "id": "2ff6d882991dde75",
        "type": "ui_group",
        "name": "IFM GAUG",
        "tab": "93381f49ce8bc0b1",
        "order": 2,
        "disp": true,
        "width": "10",
        "collapse": true,
        "className": ""
    },
    {
        "id": "93381f49ce8bc0b1",
        "type": "ui_tab",
        "name": "IFM DASHBOARD",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

A couple things:

  1. It looks like you are using node-red-contrib-http-request That node hasn't been updated in over 3 years and is deprecated. If you are using a different node, please give the full name of the node.

  2. your function node has some errors since you have defined two variables:


    Youshould change those two lines to:

let time_jour = yyyy+"/"+mm+"/"+dd
let time_heure = hh+":"+mmm+":"+ss
  1. does the word capteur mean sensor?

  2. You say

when i plugin multi to request i get code only of one of them

Your flow has many function nodes that get triggered from one inject node, which one is causing a problem?

To debug this, you should change the inject node to only trigger when you press it and add a separate inject node for each function node. That way you can determine which one is causing your issue.

  • What device and OS is NR running on?
  • what version of NR and node.js is running (you can get this from the startup log)
1 Like

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