RPi: Building a ShakeMeter with Raspberry Shake and Node-Red


Build a real-time “Shakemeter” in the Node-Red Dashboard! The Shakemeter will take the real-time seismic data and convert it into a live measurement of the absolute amplitude and velocity at which the ground is shaking! Set it up in your classroom and see how powerfully you can jump, put in next to the court to see how hard a home crowd cheers for your basketball team, or set it up at a school assembly to see which class has the most spirit!




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. In order to separate the numerical data and to quantify the shaking, another function node is needed to process the data. Below is an example of a node we made to address this.

Using the data:

[{"id":"d5d2efbb.2600e","type":"function","z":"b308f371.c9fa","name":"Absolute Amplitude","func":"acc = 0;\nnum = 0;\nfor(const p of msg.payload.packets)\n{\n    acc += Math.abs(p);\n    num++;\n}\n\nacc /= num;\n\nmsg.payload = acc;\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":360,"wires":[["c8911fad.47f72"]]},{"id":"c8911fad.47f72","type":"smooth","z":"b308f371.c9fa","name":"","property":"payload","action":"mean","count":"25","round":"0","mult":"single","x":780,"y":360,"wires":[["6270e4ac.2138fc","64858a7e.ecae14"]]}]


You can copy and paste this code-block to import an ‘Absolute Amplitude’ function-node, it takes the raw data from the rshake parser node and turns it into a more easily usable integer which describes the amount of absolute vibration over the past couple of seconds. After it there is a “smooth” node to take the mean of the first numbers in order for the data to be processed more easily. *Note: photos show “average magnitude” in place of “absolute amplitude”

To import code-blocks like this, use the top right menu and select ‘import -> clipboard’ then a box will pop up allowing you to paste in the flow.


Your flow should now look similar to the photo above. The next step is to add the Dashboard “Gauge” Node, and attach it after the smooth node. Then, we have to configure the Gauge node. Make sure to Make the range from zero to at least 50000 (remember not to put a comma in 50000). If you have not yet, you will also have to create a Dashboard group, by pressing the edit button next to the “group” field, and then pressing it again next to the “tab” field.  Then click Update, then Done!


Now, we are ready to deploy!

Once deployed, open your local Node-Red Dashboard.  You can access this page by entering http://”yourIPaddress:1880/ui. For example:

Now, bang the table! Jump up and down! How can you apply the ShakeMeter to something relevant in your home, school, or community?

So go get Shakin!


image_pdfGenerate PDFimage_printPrint
Posted in Curriculum, Node-Red, Raspberry Pi.

Leave a Reply