openeew-nodered icon indicating copy to clipboard operation
openeew-nodered copied to clipboard

Create simulated sensor node using real accelerations

Open andygrillo opened this issue 3 years ago • 7 comments

To help with testing it would be great to have a simple node that reads from a local file that contains sensor readings from a real earthquake, eg https://github.com/openeew/openeew-detection/tree/master/input/2018_7.2, and send them into the flow.

FYI, each of these files is a JSONL file, belonging to a unique sensor, where every line is one seconds worth of data in x,y and z. Therefore we need to send one line per second to simulate a live sensor.

andygrillo avatar Sep 02 '20 14:09 andygrillo

One of my initial Node-RED experiments read in a JSONL file. I practiced on a JSONL file as I learned how to parse the data. It was a windy journey the first time but I could recreate that easily now.

I could play that directly into a simple dashboard similar to the Node-RED example #2 ?

This would be a flow. Easily modified. You might be asking for a specific Node-RED node. That's quite a bit more work and less flexible.

johnwalicki avatar Sep 02 '20 20:09 johnwalicki

I would potentially not do this with Node-RED. A python script that starts a MQTT broker, and then loops through the file and publishes the earthquake data, would be interesting. Then ANY dashboard solution could listen in could subscribe to it.

Its still a bunch of work.... Would be just as easy to point a dashboard via http get to https://s3.amazonaws.com/grillo-openeew/index.html#records/country_code=mx/device_id=006/year=2018/month=02/day=16/hour=23/

johnwalicki avatar Sep 02 '20 20:09 johnwalicki

A python script that starts a MQTT broker, and then loops through the file and publishes the earthquake data, would be interesting. Then ANY dashboard solution could listen in could subscribe to it.

The Docker detection project pretty much does this: https://github.com/openeew/openeew-detection#simulate-sensor-data

This simulator runs against the local (Docker) or remote (Kubernetes) MQTT node

krook avatar Sep 02 '20 20:09 krook

To be honest, if you just need a simulator, there's a full date picker solution in Example #3 of the Node-RED repo here. You can pick your dataset and view it.

I think it would be a simple modification to play the data as a simulator.

johnwalicki avatar Sep 02 '20 20:09 johnwalicki

Maybe I have another idea for this issue. I think the idea of a bespoke Node-RED node that is an OpenEEW real data playback simulator has some merit.

Strip away the MQTT broker, strip away the dashboard widgets.

What if all the date picker dashboard widgets moved into a Node-RED edit dialog. The user picks the sensor, date, time, duration of playback. Behind the scene, the node builds the AWS bucket URL, retrieves all the historic data, and then emits the subsecond x/y/z acceleration data as if it was coming from a live MQTT feed.....

The user clicks the "Inject" tab and the data plays into the rest of the Node-RED flow.

johnwalicki avatar Sep 02 '20 22:09 johnwalicki

As a first iteration, the Node-RED edit properties dialog asks for a file path to a JSONL file that you've already downloaded. It reads the JSONL file and plays the data into the rest of the Node-RED flow. That would satisfy the initial request?

johnwalicki avatar Sep 02 '20 22:09 johnwalicki

Yes, I believe that would satisfy the folk in #node-red who asked for live data

andygrillo avatar Sep 02 '20 22:09 andygrillo