skip to Main Content

RPi: Building a Raspberry Shake seismogram on the Node-Red Dashboard


Set up a real time Seismogram on the Node-Red Dashboard.




After following the first tutorial on connecting  Shake to Node Red, now we can start to use Node-Red to process and visualize the seismic data that is being streamed through the UDP port.

Getting Started:

Before starting this tutorial, make sure you have already completed the “Streaming Raspberry Shake Data to Node-Red” tutorial. Your flow should look like this:


Make sure that there is UDP data being received by checking the debug tab. As you can see, the data coming through the Rshake Parser is still in object form, consisting of multiple types of information. For building the siesmogram graph, we just want the numerical data.

First, we have to add a switch node that discriminates the the channel of the data. If we are using a Shake 1D, it will be the channel EHZ. So, we must add a switch node after the parser, and format it to be listening for the property “” and underneath we can add the rule as: == “string” EHZ. This separates the data that we want.

The data is still not in a format useable for graphing, so we have to create a custom function node to separate the numerical data. Raspberry shake has created a code just for this purpose.

Go to the menu and choose import>clipboard, and paste this code and import the node.

[{"id":"299110c.a2af7f","type":"function","z":"d328b37.176a45","name":"format plot values","func":"\nvar EVERY_N_PACKET = 20; // max = 24\nvar POINTS_PER_SECOND = 100 / EVERY_N_PACKET;\nvar KEEP_SECONDS = 60;\nvar KEY=\"f2_all_points\";\n\nvar MAX_POINTS = POINTS_PER_SECOND * KEEP_SECONDS;\n\nvar input = msg.payload;\n\nvar data = [{series:[\"P\"],\n    data:[],\n    labels:[\"Points\"]\n}];\n\nvar allPoints = flow.get(KEY);\nif(allPoints == undefined)\n    allPoints = [];\n\n\nfor(var i=0, step=EVERY_N_PACKET; i + step < input.packets.length; i += step) {\n    var o = {x: input.ts + i*10,\n             y: input.packets[i]};\n    allPoints.push(o);\n}\n\nif(allPoints.length > MAX_POINTS)\n    allPoints = allPoints.slice(\n        allPoints.length - MAX_POINTS, \n        allPoints.length\n    );\n\nflow.set(KEY, allPoints);\n\ndata[0].data.push(allPoints);\n\n\nmsg.payload = data;\n\nreturn msg;","outputs":1,"noerr":0,"x":877,"y":171,"wires":[["73bf48a9.3fc398"]]}]

Connect the ‘format plot values” node to the switch node. Now, to finish we connect a Dashboard chart. Your flow should look similar to this:

Then, configure the chart in the way that you would like, and Deploy!

Now, open your local Node-Red Dashboard! You can access this page by entering your Node-Red address /ui. For example:

Now, bang the table! Jump up and down! See what happens to the graph!


To continue working with the Shake Data in Node-Red, go to the next Tutorial!

Making a Shakemeter:



Back To Top