I am new to this soI apologize in advance. I have created a dashboard with 3 sensors from a pico to dashboard on a pi. I setup 3 Gauges that correctly display the data every 1 minute. I tried to add 3 charts for historical data every 15 minutes. There is no chart displayed only the label for it. I consitantly receive a bad data inject message. any help is appreciated.
Hard to help when we can not see what you have tried.
Best to show data and a minimal export of your flow.
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.
In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```
)
```
code goes here
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json
I have also changed your category as this is not about developing a node, it is about creating a flow.
thank you for your help here is my flow.
[
{
"id": "8266aff9af20d5cd",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c7c2020d76f4dc61",
"type": "serial in",
"z": "8266aff9af20d5cd",
"name": "PicoUSB",
"serial": "d316f3575b5a384a",
"x": 260,
"y": 360,
"wires": [
[
"92aee2f578e49df6",
"5f1ab1d74b81dbec"
]
]
},
{
"id": "92aee2f578e49df6",
"type": "debug",
"z": "8266aff9af20d5cd",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 360,
"y": 460,
"wires": []
},
{
"id": "1aa37e9c314c7eb9",
"type": "ui_gauge",
"z": "8266aff9af20d5cd",
"name": "",
"group": "31b7bf6762bf2608",
"order": 5,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "DS18B20 Temperature Bottom of Tank",
"label": "Fahrenheit",
"format": "{{msg.payload[0].payload}} °F",
"min": "60",
"max": "80",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "75",
"seg2": "76",
"diff": false,
"className": "",
"x": 810,
"y": 60,
"wires": []
},
{
"id": "605ffd7b41ce670f",
"type": "function",
"z": "8266aff9af20d5cd",
"name": "function 1",
"func": "// Parse JSON data from the Pico\nvar sensorData = JSON.parse(msg.payload);\n\n// Set the payload for the dashboard\nmsg.payload = [\n { topic: 'DS18B20 Temperature', payload: sensorData.temperature_ds18b20 },\n { topic: 'DHT11 Temperature', payload: sensorData.temperature_dht11 },\n { topic: 'DHT11 Humidity', payload: sensorData.humidity_dht11 },\n];\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 500,
"y": 160,
"wires": [
[
"1aa37e9c314c7eb9",
"141cc79c43fb618a",
"bc4d48857a5a183d",
"36b581dc298762a4"
]
]
},
{
"id": "141cc79c43fb618a",
"type": "ui_gauge",
"z": "8266aff9af20d5cd",
"name": "",
"group": "31b7bf6762bf2608",
"order": 1,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "DHT11 Temperature",
"label": "Fahrenheit",
"format": "{{msg.payload[1].payload}} °F",
"min": "60",
"max": "80",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "75",
"seg2": "76",
"diff": false,
"className": "",
"x": 1000,
"y": 200,
"wires": []
},
{
"id": "bc4d48857a5a183d",
"type": "ui_gauge",
"z": "8266aff9af20d5cd",
"name": "",
"group": "31b7bf6762bf2608",
"order": 3,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "DHT11 Humidity",
"label": "Percentage",
"format": "{{msg.payload[2].payload}} %",
"min": "40",
"max": "90",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "60",
"seg2": "80",
"diff": false,
"className": "",
"x": 1120,
"y": 60,
"wires": []
},
{
"id": "5f1ab1d74b81dbec",
"type": "function",
"z": "8266aff9af20d5cd",
"name": "Initialize Historical Data",
"func": "// Initialize historical data variables if not already defined\nvar historicalDataDS18B20 = flow.get(\"historicalDataDS18B20\") || { labels: [], values: [] };\nvar historicalDataDHT11Temp = flow.get(\"historicalDataDHT11Temp\") || { labels: [], values: [] };\nvar historicalDataDHT11Humidity = flow.get(\"historicalDataDHT11Humidity\") || { labels: [], values: [] };\n\n// Save the historical data back to flow context\nflow.set(\"historicalDataDS18B20\", historicalDataDS18B20);\nflow.set(\"historicalDataDHT11Temp\", historicalDataDHT11Temp);\nflow.set(\"historicalDataDHT11Humidity\", historicalDataDHT11Humidity);\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 190,
"y": 160,
"wires": [
[
"605ffd7b41ce670f",
"36b581dc298762a4"
]
]
},
{
"id": "88a545613624e5ae",
"type": "ui_chart",
"z": "8266aff9af20d5cd",
"name": "",
"group": "31b7bf6762bf2608",
"order": 3,
"width": 0,
"height": 0,
"label": "historicalDataDS18B20",
"chartType": "line",
"legend": "false",
"xformat": "auto",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": "1",
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 930,
"y": 500,
"wires": [
[]
]
},
{
"id": "36b581dc298762a4",
"type": "function",
"z": "8266aff9af20d5cd",
"name": "Historical Chart",
"func": "// Replace these with the actual IDs or topics of your chart nodes\nvar ds18b20ChartNodeId = \"88a545613624e5ae\";\nvar dht11TempChartNodeId = \"d95163d2df37ca62\";\nvar dht11HumidityChartNodeId = \"5a3f24530de6c96d\";\n\n// Get data from existing gauge nodes\nvar ds18b20Value = flow.get(\"historicalDataDS18B20\").values.slice(-1)[0] || 0;\nvar dht11TempValue = flow.get(\"historicalDataDHT11Temp\").values.slice(-1)[0] || 0;\nvar dht11HumidityValue = flow.get(\"historicalDataDHT11Humidity\").values.slice(-1)[0] || 0;\n\n// Create or update msg.payload with historical data\nmsg.payload = [\n { topic: 'DS18B20 Temperature', payload: `${ds18b20Value} °F` },\n { topic: 'DHT11 Temperature', payload: `${dht11TempValue} °F` },\n { topic: 'DHT11 Humidity', payload: `${dht11HumidityValue} %` }\n];\n\n// Send data to chart nodes\nmsg.ui_control = {\n \"group\": \"31b7bf6762bf2608\",\n \"chart\": {\n [ds18b20ChartNodeId]: {\n \"data\": [{ x: new Date(), y: ds18b20Value }],\n \"labels\": [new Date()],\n },\n [dht11TempChartNodeId]: {\n \"data\": [{ x: new Date(), y: dht11TempValue }],\n \"labels\": [new Date()],\n },\n [dht11HumidityChartNodeId]: {\n \"data\": [{ x: new Date(), y: dht11HumidityValue }],\n \"labels\": [new Date()],\n }\n }\n};\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 500,
"wires": [
[
"88a545613624e5ae",
"d95163d2df37ca62",
"5a3f24530de6c96d",
"fdcbf173a71c9aee"
]
]
},
{
"id": "d95163d2df37ca62",
"type": "ui_chart",
"z": "8266aff9af20d5cd",
"name": "",
"group": "31b7bf6762bf2608",
"order": 4,
"width": 0,
"height": 0,
"label": "historicalDataDHT11Temp",
"chartType": "line",
"legend": "false",
"xformat": "auto",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": "1",
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 910,
"y": 580,
"wires": [
[]
]
},
{
"id": "5a3f24530de6c96d",
"type": "ui_chart",
"z": "8266aff9af20d5cd",
"name": "",
"group": "31b7bf6762bf2608",
"order": 5,
"width": 0,
"height": 0,
"label": "historicalDataDHT11Humidity",
"chartType": "line",
"legend": "false",
"xformat": "auto",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": "1",
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 900,
"y": 660,
"wires": [
[]
]
},
{
"id": "fdcbf173a71c9aee",
"type": "debug",
"z": "8266aff9af20d5cd",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 980,
"y": 360,
"wires": []
},
{
"id": "d316f3575b5a384a",
"type": "serial-port",
"name": "PicoUSBPi",
"serialport": "/dev/ttyACM0",
"serialbaud": "9600",
"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": "31b7bf6762bf2608",
"type": "ui_group",
"name": "Dougie's Temp and Humidity",
"tab": "6d10beb5c3a6b93b",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "6d10beb5c3a6b93b",
"type": "ui_tab",
"name": "Douglas's Tank Metrics",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]
With out seeing the data i am guessing. Use the debug sidebar to capture, as shown in previous post from me. add to inject node to simulate input.
Something like this should work all the lines will be displayed on one chart, if you want separate charts use a switch node to direct using msg.topic.
[{"id":"7fb8c28925f1262f","type":"inject","z":"8266aff9af20d5cd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":160,"wires":[["605ffd7b41ce670f"]]},{"id":"605ffd7b41ce670f","type":"function","z":"8266aff9af20d5cd","name":"function 1","func":"// Parse JSON data from the Pico\nvar sensorData = JSON.parse(msg.payload);\n\n// Set the payload for the dashboard\nmsg.payload = {\n 'DS18B20 Temperature': sensorData.temperature_ds18b20 ,\n 'DHT11 Temperature': sensorData.temperature_dht11 ,\n 'DHT11 Humidity': sensorData.humidity_dht11 ,\n};\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":160,"wires":[["1aa37e9c314c7eb9","141cc79c43fb618a","bc4d48857a5a183d","95d0e3b97b3b42a0"]]},{"id":"1aa37e9c314c7eb9","type":"ui_gauge","z":"8266aff9af20d5cd","name":"","group":"31b7bf6762bf2608","order":5,"width":0,"height":0,"gtype":"gage","title":"DS18B20 Temperature Bottom of Tank","label":"Fahrenheit","format":"{{msg.payloa[.'DS18B20 Temperature'\"]}} °F","min":"60","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"75","seg2":"76","diff":false,"className":"","x":810,"y":60,"wires":[]},{"id":"141cc79c43fb618a","type":"ui_gauge","z":"8266aff9af20d5cd","name":"","group":"31b7bf6762bf2608","order":1,"width":0,"height":0,"gtype":"gage","title":"DHT11 Temperature","label":"Fahrenheit","format":"{{msg.payload[\"''DHT11 Temperature'\"]}} °F","min":"60","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"75","seg2":"76","diff":false,"className":"","x":760,"y":140,"wires":[]},{"id":"bc4d48857a5a183d","type":"ui_gauge","z":"8266aff9af20d5cd","name":"","group":"31b7bf6762bf2608","order":3,"width":0,"height":0,"gtype":"gage","title":"DHT11 Humidity","label":"Percentage","format":"{{msg.payload[\"'DHT11 Humidity\"]}} %","min":"40","max":"90","colors":["#00b500","#e6e600","#ca3838"],"seg1":"60","seg2":"80","diff":false,"className":"","x":740,"y":100,"wires":[]},{"id":"95d0e3b97b3b42a0","type":"split","z":"8266aff9af20d5cd","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":610,"y":260,"wires":[["5a3f24530de6c96d"]]},{"id":"5a3f24530de6c96d","type":"ui_chart","z":"8266aff9af20d5cd","name":"","group":"31b7bf6762bf2608","order":5,"width":0,"height":0,"label":"historicalDataDHT11Humidity","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":830,"y":260,"wires":[[]]},{"id":"31b7bf6762bf2608","type":"ui_group","name":"Dougie's Temp and Humidity","tab":"6d10beb5c3a6b93b","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"6d10beb5c3a6b93b","type":"ui_tab","name":"Douglas's Tank Metrics","icon":"dashboard","disabled":false,"hidden":false}]
May be typo's as untested without data.
The chart also outputs the historical data that is displayed , so you can save that as historical chart, if data is ever lost.
here is what the data looks like in the debug
Again, use the debug node and copy value as described in my first post, i and others can not copy a image. I did say add it to an inject node.
Where is this data in the image you posted coming from? i wanted to see the data coming from the serial in, as we do not have access to that.
sorry got it
here is the function that parses the data from the PICO
// Parse JSON data from the Pico
var sensorData = JSON.parse(msg.payload);
// Set the payload for the dashboard
msg.payload = [
{ topic: 'DS18B20 Temperature', payload: sensorData.temperature_ds18b20 },
{ topic: 'DHT11 Temperature', payload: sensorData.temperature_dht11 },
{ topic: 'DHT11 Humidity', payload: sensorData.humidity_dht11 },
];
return msg;
Here is the debug message
[{"topic":"DS18B20 Temperature","payload":66.9875},{"topic":"DHT11 Temperature","payload":68},{"topic":"DHT11 Humidity","payload":49}]
payload
{"topic":"DS18B20 Temperature","payload":66.9875}
payload[0]
DS18B20 Temperature
payload[0].topic
66.9875
payload[0].payload
{"topic":"DHT11 Temperature","payload":68}
payload[1]
66.9875
payload[0].payload
{"topic":"DHT11 Humidity","payload":49}
payload[1]
DHT11 Humidity
payload[2].topic
49
payload[2].payload
No you have not got it.
This is the last time i will ask.
I want to see the data coming from the serial in node, use the copy value button described here
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.
I added a debug node to the pico and copied the performed the steps described
this is from copy value - {"temperature_ds18b20": 66.9875, "sensor_type": "sensor_data", "temperature_dht11": 68.0, "humidity_dht11": 48, "timestamp": "2021-01-04 02:06:26"}
this is from copy path - payload
Not sure if that is a JSON string or a JS object, so i have shown both.
This should work
[{"id":"1b8d20ef646f7cb1","type":"debug","z":"d1395164b4eec73e","name":"debug 2480","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":290,"y":5900,"wires":[]},{"id":"605ffd7b41ce670f","type":"function","z":"d1395164b4eec73e","name":"function 1","func":"// Set the payload for the dashboard\nmsg.payload = {\n 'DS18B20 Temperature': msg.payload.temperature_ds18b20 ,\n 'DHT11 Temperature': msg.payload.temperature_dht11,\n 'DHT11 Humidity': msg.payload.humidity_dht11\n};\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":6000,"wires":[["1aa37e9c314c7eb9","141cc79c43fb618a","bc4d48857a5a183d","95d0e3b97b3b42a0","1b8d20ef646f7cb1"]]},{"id":"802cd4bd9660557c","type":"inject","z":"d1395164b4eec73e","name":"pico input js object","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"temperature_ds18b20\": 66.9875, \"sensor_type\": \"sensor_data\", \"temperature_dht11\": 68.0, \"humidity_dht11\": 48, \"timestamp\": \"2021-01-04 02:06:26\"}","payloadType":"json","x":170,"y":6000,"wires":[["605ffd7b41ce670f"]]},{"id":"77825a88417f053a","type":"json","z":"d1395164b4eec73e","name":"","property":"payload","action":"","pretty":false,"x":330,"y":6060,"wires":[["605ffd7b41ce670f"]]},{"id":"1aa37e9c314c7eb9","type":"ui_gauge","z":"d1395164b4eec73e","name":"","group":"31b7bf6762bf2608","order":5,"width":0,"height":0,"gtype":"gage","title":"DS18B20 Temperature Bottom of Tank","label":"Fahrenheit","format":"{{msg.payload[\"DS18B20 Temperature\"] | number : 2}} °F","min":"60","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"75","seg2":"76","diff":false,"className":"","x":750,"y":5900,"wires":[]},{"id":"141cc79c43fb618a","type":"ui_gauge","z":"d1395164b4eec73e","name":"","group":"31b7bf6762bf2608","order":1,"width":0,"height":0,"gtype":"gage","title":"DHT11 Temperature","label":"Fahrenheit","format":"{{msg.payload[\"DHT11 Temperature\"] | number : 0}} °F","min":"60","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"75","seg2":"76","diff":false,"className":"","x":700,"y":5980,"wires":[]},{"id":"bc4d48857a5a183d","type":"ui_gauge","z":"d1395164b4eec73e","name":"","group":"31b7bf6762bf2608","order":3,"width":0,"height":0,"gtype":"gage","title":"DHT11 Humidity","label":"Percent","format":"{{msg.payload[\"DHT11 Humidity\"] | number : 0}} %","min":"40","max":"90","colors":["#00b500","#e6e600","#ca3838"],"seg1":"60","seg2":"80","diff":false,"className":"","x":680,"y":5940,"wires":[]},{"id":"95d0e3b97b3b42a0","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":550,"y":6100,"wires":[["5a3f24530de6c96d"]]},{"id":"a1a0cbe8812e114a","type":"inject","z":"d1395164b4eec73e","name":"pico input json string","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"temperature_ds18b20\": 66.9875, \"sensor_type\": \"sensor_data\", \"temperature_dht11\": 68.0, \"humidity_dht11\": 48, \"timestamp\": \"2021-01-04 02:06:26\"}","payloadType":"str","x":170,"y":6060,"wires":[["77825a88417f053a"]]},{"id":"5a3f24530de6c96d","type":"ui_chart","z":"d1395164b4eec73e","name":"","group":"31b7bf6762bf2608","order":5,"width":0,"height":0,"label":"historical Data","chartType":"line","legend":"true","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":720,"y":6100,"wires":[["d982a6320b91f6fc"]]},{"id":"d982a6320b91f6fc","type":"debug","z":"d1395164b4eec73e","name":"chart data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":6040,"wires":[]},{"id":"31b7bf6762bf2608","type":"ui_group","name":"Dougie's Temp and Humidity","tab":"6d10beb5c3a6b93b","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"6d10beb5c3a6b93b","type":"ui_tab","name":"Douglas's Tank Metrics","icon":"dashboard","disabled":false,"hidden":false}]
Click legend to remove and add lines in chart.
It worked thank you so much for your help. Now I can continue this was a huge help!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.