Build a Earthquake Early Warning Alert Map Node-RED Dashboard using OpenEEW data
Learn how to build an Earthquake Early Warning system using live OpenEEW sensor data and visualize historical seismic datasets in Node-RED Dashboards.
These example flows and Node-RED Dashboards might be useful as part of an Earthquake Early Warning system. Join the Call for Code challenge and contribute to open source projects.
Add the following nodes to your Node-RED palette
npm install node-red-dashboard node-red-contrib-web-worldmap node-red-node-twilio node-red-node-ui-table
"node-red-dashboard":"2.x",
"node-red-contrib-web-worldmap":"2.x",
"node-red-node-twilio":"0.x",
"node-red-node-ui-table":"0.x",
One simplistic approach to detecting seismic activity is to measure large accelerations from the openeew accelerometer sensors, based on a set threshold that is above the typical noise floor of the accelerometer. Wikipedia defines a gal (unit) as a unit of acceleration used extensively in the science of gravimetry. The gal is defined as 1 centimeter per second squared (1 cm/s2). Seismic activity of interest might exceed 3 gals (3 cm/sec2).
These Node-RED flows observe the real-time openeew accelerometer data and calculate if the sensor might be experiencing seismic activity using the following algorithm. Each second this function receives x/y/z arrays of subsecond vibration data. The data arrays are passed into the function inside msg.payload.traces[0]
The javascript function loops through the vibration data looking for acceleration exceeding 3 cm/sec2
// The simplest way to detect changes :
// "not earthquake" vs "possible earthquake"
// For each tuple x,y,z take the
// square root of sum of the squared of each components:
// (x**2 + y**2 + z**2)**(1/2)
// square rooting gives back positive values
// Loop through all of the subsecond arrays of data
// Most of this is noise
// 1 cm/sec2 == 1 gal
// +/- 0.3 gals is jitter
var alert = false;
var gals = 0.0;
var x,y,z;
for( i=0; i<msg.payload.traces[0].x.length;i++){
x = msg.payload.traces[0].x[i];
y = msg.payload.traces[0].y[i];
z = msg.payload.traces[0].z[i];
gals = Math.sqrt( Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) );
if( gals > 3 ) {
// whoa - maybe an earthquake
alert = true
}
}
if( alert ) {
return msg;
} else {
return null ;
}
Learn how to implement OpenEEW Node-RED dashboards using these example flows.
Four examples are provided in the flows folder.
This flow plots the OpenEEW sensors on a map of Mexico and displays their seismic activity status. The flow subscribes to the live data feed of the sensors using MQTT. If any of the sensors have not checked in for 30 seconds mark the sensor offline. If the seismic algorithm detects shaking, mark the sensor in red and send a Twilio SMS alert to warn residents to seek safety.
Get the Code: Node-RED flow for OpenEEW Alerts
This flow has four sections:
This flow subscribes to the live data feed (available via MQTT) of a selected sensor and plots the seismic activity in a set of X / Y / Z graphs.
Get the Code: Node-RED flow for OpenEEW Sensor graphs
This flow has three sections:
This flow displays a Node-RED dashboard which presents the investigator / seismologist with a calendar, time interval options and a list of OpenEEW sensors. The investigator selects an interesting sensor and time period to study and queries the OpenEEW dataset. The flow then plots the historical sensor data in a set of graphs.
The flow constructs a URL for the selected sensor and time interval and retrieves the historical sensor data from the OpenEEW dataset and plays it back into a graph in a Node-RED Dashboard.
The "Next" button in the Historical Quake Playback Node-RED dashboard is incredibly insightful. The focus is often on the big earthquakes, and their specific timestamp / dataset. The "Next" button lets the investigator explore the numerous aftershocks. Start with the Mexico 7.2 magnitude earthquake on Feb 16 2018 23:35 and its data set and then click the Next button to watch (in 5 minute increments) the aftershocks that occurred over the next several hours. Watch the animated gif of the earthquake and aftershock activity.
You can also observe the seismic activity by using the AutoPlay feature. Turn on the AutoPlay switch and select the number of minutes of playback.
The screenshot is of a magnitude 7.2 earthquake in Mexico on 2018-02-16 23:43:00.
Here is another screenshot of a magnitude 4.1 earthquake in Puerto Rico on 2020-06-01 12:05:51
Get the Code: Node-RED flow for OpenEEW Historical Playback
This flow has six sections:
I created many Node-RED flows during my OpenEEW seismic graphing learning journey. Here is one of my beginning / simplistic iterations. This flow reads a file from a bucket of historical sensor data from the OpenEEW dataset using an AWS cloud object storage node (you would need credentials to reproduce it). The Node-RED flow plays the data back into a graph in a Node-RED Dashboard. The screenshot is of a magnitude 7.2 earthquake in Mexico on 2018-02-16 23:43:00.
Now that you have completed these examples, you are ready to modify these example flows and your own Node-RED Dashboard to build an OpenEEW Earthquake Early Warning data visualization solution. There are several OpenEEW GitHub project repositories that you can contribute to.
Join the cutting-edge community and build open source projects to fight back against the most pressing issues of our time. See your code deployed to help those in need.
Get free access to the IBM Cloud
Brush up on your cloud skills while making a real difference and get involved with these open source projects supported by the Linux Foundation.
Enjoy! Give us feedback if you have suggestions on how to improve this tutorial.
The community welcomes your involvement and contributions to this project. Please read the OpenEEW contributing document for details on our code of conduct, and the process for submitting pull requests to the community.
This tutorial is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.