Is there a recommended method for running user defined code against IoT data streams?

48 Views Asked by At

I'm sending IoT data from an OPC UA server to a pub/sub topic. Each single message to the topic includes 15 minutes of minute-by-minute data for about ~100 sensors. Dataflow reads from this pub/sub topic and performs a few joins and writes the output to another pub/sub topic. This data is then written to Timescale DB by a cloud function for display in a visualization application.

Lets say we're getting sensor data for Ambient_Temperature and we know that its value is in Fahrenheit. I'd like to execute some user defined javascript code that would, for example, perform a celsius conversion on the Ambient_Temperature sensor value, and write a "new" sensor called Ambient_Temperature_Celsius into Timescale.

I can certainly write a microservice on my own that the cloud function mentioned above could call that will safely execute the user defined javascript code and produce an output - but being rather unfamiliar with IoT stuff in Google Cloud land, I want to ask if there is a better way to accomplish this?

It seems that it would be pretty common IoT software vendors to allow users to run some math on their IoT data to create entirely new timeseries data.

1

There are 1 best solutions below

0
Joevanie On
You can use Google Cloud IoT Core to securely connect and manage IoT devices. Then, use the Node.js client library to interact with the Cloud IoT Core API and execute user-defined code on your IoT data. You can then write a microservice that the cloud function mentioned above could call that will safely execute the user defined javascript code and produce an output. Write the output to Timescale DB for display in a visualization application. Then deploy your Node.js service to Cloud Run which is a fully managed serverless platform that automatically scales your stateless containers.