Hello, I want to store my temperature data in csv files, specifically for data logging purpose. Now, I have developed till having bulk data in a single csv file. The csv file containing bulk data is as below:--
I have been trying out the auto logger function from Auto Logger: log data in daily CSV files (flow) - Node-RED and also closely following the YouTube video related to it. But, I still can't manage to create a csv file for 1 day.
I suspect this issue may be caused by destination file path. The original author used raspian to do the auto logging, which is a little different when setting destination path for csv files to be created. I will also share my flow below, hope anyone can help me out with this. Thanks.
[
{
"id": "10ebb9340ed6672a",
"type": "tab",
"label": "CopyTest",
"disabled": false,
"info": "",
"env": []
},
{
"id": "82315f6ced6cb1f7",
"type": "C-Mode Command",
"z": "10ebb9340ed6672a",
"name": "CJ2M",
"plcSeries": "CSJP",
"hostNumber": 0,
"headerCode": "RD",
"p1": "1",
"p2": "12",
"p3": "",
"x": 290,
"y": 100,
"wires": [
[
"bbc2a4c482c2abeb"
]
]
},
{
"id": "01dd82772b927aa4",
"type": "C-Mode Response",
"z": "10ebb9340ed6672a",
"name": "",
"x": 630,
"y": 100,
"wires": [
[
"b73e2823222911f7"
]
]
},
{
"id": "9834ad26f4c14af8",
"type": "inject",
"z": "10ebb9340ed6672a",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 100,
"wires": [
[
"82315f6ced6cb1f7"
]
]
},
{
"id": "bbc2a4c482c2abeb",
"type": "serial request",
"z": "10ebb9340ed6672a",
"name": "",
"serial": "1888161b22bfcc1a",
"x": 430,
"y": 100,
"wires": [
[
"01dd82772b927aa4"
]
]
},
{
"id": "f0a4c6b149cf6893",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 1,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 16",
"format": "<font size=6>{{msg.payload.asInteger1[0]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 220,
"wires": []
},
{
"id": "4c18e5fa21894be7",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 2,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 51",
"format": "<font size=6>{{msg.payload.asInteger1[1]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 260,
"wires": []
},
{
"id": "3b6516f0aabeaaa9",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 3,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 50",
"format": "<font size=6>{{msg.payload.asInteger1[2]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 300,
"wires": []
},
{
"id": "1435cdec99e3e12d",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 4,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 49",
"format": "<font size=6>{{msg.payload.asInteger1[3]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 340,
"wires": []
},
{
"id": "6e427aabe484a390",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 5,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 52",
"format": "<font size=6>{{msg.payload.asInteger1[4]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 380,
"wires": []
},
{
"id": "28ecf406d4eb6696",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 6,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 44",
"format": "<font size=6>{{msg.payload.asInteger1[5]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 420,
"wires": []
},
{
"id": "6b991ebe0f2ee636",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 7,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 17",
"format": "<font size=6>{{msg.payload.asInteger1[6]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 460,
"wires": []
},
{
"id": "14d68d230c9b0b9f",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 8,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 46",
"format": "<font size=6>{{msg.payload.asInteger1[7]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 500,
"wires": []
},
{
"id": "11b5682dc498d13b",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 9,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 45",
"format": "<font size=6>N/A °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 540,
"wires": []
},
{
"id": "fc9503650488a150",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 10,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 47",
"format": "<font size=6>{{msg.payload.asInteger1[9]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 580,
"wires": []
},
{
"id": "a06f33e04a0a2246",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 11,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 43",
"format": "<font size=6>{{msg.payload.asInteger1[10]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 620,
"wires": []
},
{
"id": "cd996f876b16b6e9",
"type": "ui_text",
"z": "10ebb9340ed6672a",
"group": "efcc13e5a5b82fc5",
"order": 12,
"width": 3,
"height": 4,
"name": "",
"label": "<font size=7>Oven 42",
"format": "<font size=6>{{msg.payload.asInteger1[11]}} °C",
"layout": "col-center",
"className": "num1",
"x": 560,
"y": 660,
"wires": []
},
{
"id": "bc9a53146f78d174",
"type": "ui_template",
"z": "10ebb9340ed6672a",
"group": "",
"name": "",
"order": 1,
"width": 0,
"height": 0,
"format": "<style>\n.num1 {\nborder: 2px solid #666;\nbackground-color : #b0e0f5 !important;\n}\n\n</style>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "global",
"className": "",
"x": 720,
"y": 60,
"wires": [
[]
]
},
{
"id": "8f38c8065805b26e",
"type": "file",
"z": "10ebb9340ed6672a",
"name": "",
"filename": "C:\\Users\\user\\Desktop\\Oven3.csv",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "utf8",
"x": 1020,
"y": 700,
"wires": [
[]
]
},
{
"id": "b73e2823222911f7",
"type": "buffer-parser",
"z": "10ebb9340ed6672a",
"name": "",
"data": "payload.buffer",
"dataType": "msg",
"specification": "spec",
"specificationType": "ui",
"items": [
{
"type": "int16be",
"name": "asInteger1",
"offset": 0,
"length": 12,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "hex",
"name": "asHex1",
"offset": 0,
"length": 2,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "hex",
"name": "asHex2",
"offset": 0,
"length": 3,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "hex",
"name": "hex3",
"offset": 0,
"length": 4,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "hex",
"name": "hex4",
"offset": 0,
"length": 5,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "hex",
"name": "hex5",
"offset": 0,
"length": 6,
"offsetbit": 0,
"scale": "1",
"mask": ""
}
],
"swap1": "",
"swap2": "",
"swap3": "",
"swap1Type": "swap",
"swap2Type": "swap",
"swap3Type": "swap",
"msgProperty": "payload",
"msgPropertyType": "str",
"resultType": "keyvalue",
"resultTypeType": "return",
"multipleResult": false,
"fanOutMultipleResult": false,
"setTopic": true,
"outputs": 1,
"x": 890,
"y": 100,
"wires": [
[
"f0a4c6b149cf6893",
"4c18e5fa21894be7",
"3b6516f0aabeaaa9",
"1435cdec99e3e12d",
"6e427aabe484a390",
"28ecf406d4eb6696",
"6b991ebe0f2ee636",
"14d68d230c9b0b9f",
"11b5682dc498d13b",
"fc9503650488a150",
"a06f33e04a0a2246",
"cd996f876b16b6e9",
"f64d36fe81b3382f"
]
]
},
{
"id": "47ffcce3c170f0d0",
"type": "comment",
"z": "10ebb9340ed6672a",
"name": "Auto Logger",
"info": "",
"x": 190,
"y": 840,
"wires": []
},
{
"id": "348c985828bb2ff3",
"type": "function",
"z": "10ebb9340ed6672a",
"name": "Filename generator",
"func": "// Get the current time and convert it to text\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\n\n// Generate out file name pattern\nmsg.fname = \"\"+ dd + mm + yyyy + \".csv\";\n// Full filename with path for the file node later\nmsg.filename = \"C:\\\\Users\\\\user\\\\Desktop\\\\OvenData\\\\Temp\"+ msg.fname;\n\n// We save the current payload into a different place on the msg object\nmsg.filecontent = msg.payload;\n\n// We are passing the file name search pattern to fs node to tell us if the file exists or not\nmsg.payload = {\"pattern\":msg.fname};\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.fname});\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 190,
"y": 780,
"wires": [
[
"dae65afa5f5537d6"
]
]
},
{
"id": "7ffbe2a0d3991bea",
"type": "debug",
"z": "10ebb9340ed6672a",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 590,
"y": 820,
"wires": []
},
{
"id": "82fac3d413877343",
"type": "switch",
"z": "10ebb9340ed6672a",
"name": "",
"property": "$count(msg.payload)",
"propertyType": "jsonata",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 610,
"y": 780,
"wires": [
[
"3efc398531b373ba"
],
[
"4dc6e8778c7f0b2e"
]
]
},
{
"id": "320df14ef86ff3aa",
"type": "csv",
"z": "10ebb9340ed6672a",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "all",
"multi": "one",
"ret": "\\r\\n",
"temp": "DateTime,Oven16,Oven51,Oven50,Oven49,Oven52,Oven44,Oven17,Oven46,Oven47,Oven43,Oven42",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 950,
"y": 760,
"wires": [
[
"6a086d4e774cc6d4"
]
]
},
{
"id": "6a086d4e774cc6d4",
"type": "file",
"z": "10ebb9340ed6672a",
"name": "",
"filename": "filename",
"filenameType": "msg",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "none",
"x": 1110,
"y": 760,
"wires": [
[]
]
},
{
"id": "3287e3a972356844",
"type": "csv",
"z": "10ebb9340ed6672a",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "DateTime,Oven16,Oven51,Oven50,Oven49,Oven52,Oven44,Oven17,Oven46,Oven47,Oven43,Oven42",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 950,
"y": 800,
"wires": [
[
"6a086d4e774cc6d4"
]
]
},
{
"id": "3efc398531b373ba",
"type": "change",
"z": "10ebb9340ed6672a",
"name": "Get file content",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "filecontent",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 780,
"y": 760,
"wires": [
[
"320df14ef86ff3aa"
]
]
},
{
"id": "4dc6e8778c7f0b2e",
"type": "change",
"z": "10ebb9340ed6672a",
"name": "Get file content",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "filecontent",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 780,
"y": 800,
"wires": [
[
"3287e3a972356844"
]
]
},
{
"id": "dae65afa5f5537d6",
"type": "fs-file-lister",
"z": "10ebb9340ed6672a",
"name": "",
"start": "C:\\Users\\user\\Desktop\\OvenData\\Temp",
"pattern": "",
"folders": "*",
"hidden": true,
"lstype": "both",
"path": true,
"single": true,
"depth": 0,
"stat": true,
"showWarnings": false,
"x": 400,
"y": 780,
"wires": [
[
"7ffbe2a0d3991bea",
"82fac3d413877343"
]
]
},
{
"id": "f64d36fe81b3382f",
"type": "function",
"z": "10ebb9340ed6672a",
"name": "Temp log",
"func": "var d = new Date();\nvar date = d.getFullYear() + \"/\" + (d.getMonth() + 1) + \"/\" + d.getDate() + \" \" + d.getHours() + \":\" + d.getMinutes() + \":\" + d.getSeconds();\nvar ov1 = msg.payload.asInteger1[0];\nvar ov2 = msg.payload.asInteger1[1];\nvar ov3 = msg.payload.asInteger1[2];\nvar ov4 = msg.payload.asInteger1[3];\nvar ov5 = msg.payload.asInteger1[4];\nvar ov6 = msg.payload.asInteger1[5];\nvar ov7 = msg.payload.asInteger1[6];\nvar ov8 = msg.payload.asInteger1[7];\nvar ov9 = msg.payload.asInteger1[9];\nvar ov10 = msg.payload.asInteger1[10];\nvar ov11 = msg.payload.asInteger1[11];\nvar data = date + \",\" + ov1 + \",\" + ov2 + \",\" + ov3 + \",\" + ov4 + \",\" + ov5 + \",\" + ov6 + \",\" + ov7 + \",\" + ov8 + \",\" + ov9 + \",\" + ov10 + \",\" + ov11;\nmsg.payload = data;\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 700,
"wires": [
[
"8f38c8065805b26e",
"348c985828bb2ff3"
]
]
},
{
"id": "1888161b22bfcc1a",
"type": "serial-port",
"serialport": "COM7",
"serialbaud": "9600",
"databits": "7",
"parity": "even",
"stopbits": "2",
"waitfor": "",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "\\n",
"bin": "false",
"out": "char",
"addchar": "",
"responsetimeout": "3000"
},
{
"id": "efcc13e5a5b82fc5",
"type": "ui_group",
"name": "OVEN MONITORING DASHBOARD",
"tab": "8d9d162b9ddf43a5",
"order": 2,
"disp": true,
"width": "12",
"collapse": false,
"className": ""
},
{
"id": "8d9d162b9ddf43a5",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]
This is my destination path to store my csv files.