Vibration_sensor

I want to plot a line chart of vibration sensor Data. Following is my flow. How can i plot a real time line chat using node red where x-axis will be frequency and y-axis will be amplitude.

[{"id":"5c0f3e4b.7b304","type":"tab","label":"Vibration_Dashboard","disabled":false,"info":""},{"id":"b6aa9d6f.49572","type":"debug","z":"5c0f3e4b.7b304","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":340,"wires":},{"id":"99cd2832.db55f8","type":"inject","z":"5c0f3e4b.7b304","name":"","props":[{"p":"payload"},{"p":"object","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{'x':'23','y':4}]","payloadType":"str","x":90,"y":260,"wires":[["259e195b.bcdd76"]]},{"id":"d8f752e4.11982","type":"function","z":"5c0f3e4b.7b304","name":"","func":"var msg1={}\nvar msg2={}\nvar buffer=msg.payload.split(",");\nmsg1.payload=parseInt(buffer[0]);\nmsg2.payload=parseInt(buffer[1]);\n\n\nconst dTrig = (trigFunc, angle) => trigFunc(angle * Math.PI / 180);\nvar values= ;\n\nfor(let i=0; i<values.length; i++){\n values[i] = parseInt(buffer[0]);\n //dTrig(Math.sin, i*360/values.length);\n}\n\nmsg.payload={\n data: values\n };\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":60,"wires":[["b6aa9d6f.49572","7fa64770.c07018"]]},{"id":"259e195b.bcdd76","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":200,"wires":[["e567e5f8.0a5048"]]},{"id":"e567e5f8.0a5048","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"{","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"}","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":240,"wires":[["893f85f1.204518"]]},{"id":"893f85f1.204518","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"'x'","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":":","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":280,"wires":[["d9406f80.3dc26"]]},{"id":"d9406f80.3dc26","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"'y'","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":320,"wires":[["8c742b93.9e3798"]]},{"id":"8c742b93.9e3798","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"'","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"'","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":380,"wires":[["d8f752e4.11982"]]},{"id":"7fa64770.c07018","type":"ui_template","z":"5c0f3e4b.7b304","group":"95c16e78.88cee","name":"HiChart","order":0,"width":0,"height":0,"format":"\n\n<script src="https://code.highcharts.com/highcharts.src.js">\n\n\n<div id="graph" style="min-width: 600px; height: 300px; margin: 0 auto">\n\n\n\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":640,"y":180,"wires":[]},{"id":"95c16e78.88cee","type":"ui_group","name":"Group 1","tab":"e1f4390.2c4a7c8","order":1,"disp":true,"width":6},{"id":"e1f4390.2c4a7c8","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Welcome to the forum.

Could you please:

  • export your flow again (copy)
  • edit your post
  • put the code between backticks like:

```
your flow code
```

Thanks for the reply. I am new to node red.

My flow

[{"id":"5c0f3e4b.7b304","type":"tab","label":"Vibration_Dashboard","disabled":false,"info":""},{"id":"b6aa9d6f.49572","type":"debug","z":"5c0f3e4b.7b304","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":340,"wires":[]},{"id":"99cd2832.db55f8","type":"inject","z":"5c0f3e4b.7b304","name":"","props":[{"p":"payload"},{"p":"object","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{'x':'23','y':4}]","payloadType":"str","x":90,"y":260,"wires":[["259e195b.bcdd76"]]},{"id":"d8f752e4.11982","type":"function","z":"5c0f3e4b.7b304","name":"","func":"var msg1={}\nvar msg2={}\nvar ran={}\nvar buffer=msg.payload.split(\",\");\nmsg1.payload=parseInt(buffer[0]);\nmsg2.payload=parseInt(buffer[1]);\n\n\nconst dTrig = (trigFunc, angle) => trigFunc(angle * Math.PI / 180);\nvar values= [];\n\nfor(let i=0; i<values.length; i++){\n    values[i] = parseInt(buffer[0]);\n    //dTrig(Math.sin, i*360/values.length);\n}\n\nmsg.payload=\n{\n    data:values\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":60,"wires":[["b6aa9d6f.49572","7fa64770.c07018"]]},{"id":"259e195b.bcdd76","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":200,"wires":[["e567e5f8.0a5048"]]},{"id":"e567e5f8.0a5048","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"{","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"}","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":240,"wires":[["893f85f1.204518"]]},{"id":"893f85f1.204518","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"'x'","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":":","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":280,"wires":[["d9406f80.3dc26"]]},{"id":"d9406f80.3dc26","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"'y'","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":320,"wires":[["8c742b93.9e3798"]]},{"id":"8c742b93.9e3798","type":"change","z":"5c0f3e4b.7b304","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"'","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"'","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":380,"wires":[["d8f752e4.11982"]]},{"id":"7fa64770.c07018","type":"ui_template","z":"5c0f3e4b.7b304","group":"95c16e78.88cee","name":"HiChart","order":0,"width":0,"height":0,"format":"<!--\n<script src=\"/scripts/highcharts/highcharts.js\"></script>\n<script src=\"/scripts/highcharts/modules/exporting.js\"></script>\n<script src=\"/scripts/highcharts/modules/no-data-to-display.js\"></script>\n<script src=\"/scripts/site/chart.js\"></script>\n\n<script src=\"https://code.highcharts.com/modules/exporting.src.js\"></script>\n<script src=\"https://code.highcharts.com/modules/no-data-to-display.src.js\"></script>\n-->\n\n<script src=\"https://code.highcharts.com/highcharts.src.js\"></script>\n\n\n<div id=\"graph\" style=\"min-width: 600px; height: 300px; margin: 0 auto\"></div>\n\n<script>\n(function(scope){\n    var timer = setInterval(function(){\n        if (!window.Highcharts) return;\n        //debugger;\n        clearInterval(timer);\n        \n\n        function getChartOptions(renderToElement) {\n        \treturn {\n        \t\tchart: {\n        \t\t\trenderTo: renderToElement,\n        \t\t\ttype: 'line',\n        \t\t\tzoomType: 'x'\n        \t\t},\n                plotOptions: {\n                    series: {\n                        type: 'line',\n                        connectEnds: false,\n                        connectNulls: true,\n\t\t\t            threshold: 0\n                    },\n                    line: {\n\t\t\t            color: 'red',\n\t\t\t            lineWidth: 1,\n\t\t\t            threshold: 0\n\t\t            }\n                },\n        \t\tseries: [{\n        \t\t\tname: 'Forward',\n        \t\t\tlineWidth: 1,\n        \t\t\ttype: 'line',\n        \t\t\tdashStyle: 'longdash',\n        \t\t\tconnectEnds: false,\n                    connectNulls: true,\n\t\t            threshold: 0\n        \t\t}]\n        \t};\n        }\n    \n        var ch = new Highcharts.chart(getChartOptions('graph'));\n        var pForward = ch.series[0];\n\n        scope.$watch('msg', function(msg) {\n                    pForward.setData(msg.payload.data, true, false, true);\n\n            }\n        });\n\n    }, 100);\n})(scope);\n\n//(function(scope){\n//    scope.$watch('msg', function(msg) {\n//        switch (msg.topic){\n//            case 'forward':\n//                pForward.setData(msg.payload.data, true, false, true);\n//                break;\n//                case 'reflected':\n//                    pReflected.setData(msg.payload.data, true, false, true);\n//                    break;\n//            default:\n//                break;\n//        }\n//    });\n//})(scope);\n\n</script>\n\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":640,"y":180,"wires":[[]]},{"id":"95c16e78.88cee","type":"ui_group","name":"Group 1","tab":"e1f4390.2c4a7c8","order":1,"disp":true,"width":6},{"id":"e1f4390.2c4a7c8","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I would recommend that you start from plotting the time as xaxis and vibration amplitude as yaxis for the first step. Node Red Dashboard line chart is great for this case. There are usually three axes for a vibration sensor.

After this, then you need to look into FFT and power spectrum density (PSD) that can plot the frequency as the xaxis and energy amplitude as the yaxis. There is a Node Red Node called "node-red-contrib-fft", which might be helpful (I have not used this node personally).

You could plot freq and amplitude over real time using two lines in the ui:chart

What would be the manufacturer and model of the sensor ?

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