Hello everybody!
I'm new to Node-Red so please go easy on me
I am trying to populate sensor data collected from an Arduino on to google sheets using Node-Red. However, the sensor data comes out as NaN all the time.
I've made sure to have my Arduino data come out in JSON format.
Please tell me where i went wrong
[
{
"id": "3a5ea13849faccec",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "ed5bdc1bbfa436e9",
"type": "serial in",
"z": "3a5ea13849faccec",
"name": "ghARD",
"serial": "fc4c36463f1c3b45",
"x": 210,
"y": 140,
"wires": [
[
"59c9a7d0c6cbb8dd"
]
]
},
{
"id": "59c9a7d0c6cbb8dd",
"type": "json",
"z": "3a5ea13849faccec",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 370,
"y": 140,
"wires": [
[
"fa4e033682da9e8a",
"4664a32c8bf03024",
"08307f51761c60e7"
]
]
},
{
"id": "c3b261b41476b5ea",
"type": "inject",
"z": "3a5ea13849faccec",
"name": "2s Counter",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "2",
"crontab": "",
"once": true,
"onceDelay": "2",
"topic": "",
"payloadType": "date",
"x": 270,
"y": 400,
"wires": [
[
"6657077ae35e3eb7"
]
]
},
{
"id": "6657077ae35e3eb7",
"type": "function",
"z": "3a5ea13849faccec",
"name": "",
"func": "var ghARD = flow.get('ghARD')||{\"MoistureValue\":0, \"hum\":0, \"temp\":0, \"phValue\":0,\"light_intentsity\":0, \"count\":0};\n\nvar output = new Array(6);\n\noutput[0] = new Date();\noutput[0].setHours(output[0].getHours()+8);\noutput[1] = Math.round(ghARD.MoistureValue/ghARD.count);\noutput[2] = Math.round(ghARD.hum/ghARD.count);\noutput[3] = Math.round(ghARD.temp/ghARD.count);\noutput[4] = Math.round(ghARD.phValue/ghARD.count);\noutput[5] = Math.round(ghARD.light_intensity/ghARD.count);\n\nflow.set('ghARD',{\"MoistureValue\":0, \"hum\":0, \"temp\":0, \"phValue\":0,\"light_intentsity\":0, \"count\":0});\n\nmsg.payload = output;\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 400,
"wires": [
[]
]
},
{
"id": "5091f180495e94f8",
"type": "GSheet",
"z": "3a5ea13849faccec",
"creds": "34b64851ad69da8f",
"method": "append",
"action": "",
"sheet": "1WQDeAQET3ZA-nVZ89tmNycOpvItl7_k8CSzZJUtUU80",
"cells": "Datasheet!A:Z",
"flatten": false,
"name": "",
"x": 1130,
"y": 240,
"wires": [
[]
]
},
{
"id": "fa4e033682da9e8a",
"type": "mqtt out",
"z": "3a5ea13849faccec",
"name": "",
"topic": "ghARD",
"qos": "2",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "ca2321cc.9faff",
"x": 680,
"y": 180,
"wires": []
},
{
"id": "4664a32c8bf03024",
"type": "debug",
"z": "3a5ea13849faccec",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 100,
"wires": []
},
{
"id": "08307f51761c60e7",
"type": "function",
"z": "3a5ea13849faccec",
"name": "",
"func": "var ghARD = flow.get('ghARD')||{\"MoistureValue\":0, \"hum\":0, \"temp\":0, \"phValue\":0, \"light_intensity\":0, \"count\":0};\n\nghARD.MoistureValue += msg.payload.MoistureValue;\nghARD.hum += msg.payload.hum;\nghARD.temp += msg.payload.temp;\nghARD.phValue += light_intensity;\nghARD.count += 1;\nflow.set('ghARD',ghARD);\n\nreturn ghARD;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 690,
"y": 260,
"wires": [
[]
]
},
{
"id": "93204e69d7aea425",
"type": "debug",
"z": "3a5ea13849faccec",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 400,
"wires": []
},
{
"id": "fc4c36463f1c3b45",
"type": "serial-port",
"serialport": "COM9",
"serialbaud": "57600",
"databits": "8",
"parity": "none",
"stopbits": "1",
"waitfor": "",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "\\n",
"bin": "false",
"out": "char",
"addchar": "",
"responsetimeout": "10000"
},
{
"id": "34b64851ad69da8f",
"type": "gauth",
"name": "greenhouse@green-house-340803.iam.gserviceaccount.com"
},
{
"id": "ca2321cc.9faff",
"type": "mqtt-broker",
"name": "",
"broker": "tcp://broker.hivemq.com",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]