- Tue Sep 29, 2020 9:47 pm
#88953
As mentioned, almost every cloud broker has some sort of transform capability, so you can send in multiple formats and transform into a single format, or vice versa - send in one format and transform to multiple.
Even if you do it yourself, it's trivial to write a client that listens on one topic, transforms the messages and publishes on another. Then you just run that as a background app or even as a serverless function (another thing that all cloud providers have)
This is effectively what I do - I send my payloads in JSON like this:
event data
pwr {"V":"1.23","I":"347","ts":"1601432881"}
env {"T":"23.6","P":"101623","Rho":"34.55","ts":"1601432765"}
snd {"dBA":"48.9","ts":"1601432761"}
the MQTT client name is the sensor name, so I get that for free, and the events are the MQTT message types. The MQTT broker handles all connect, disconnect, heartbeats and health checks so it tells me if a sensor goes offline or doesn't check in within its promised time range.
The MQTT broker receives the events and timestamps them when they are received (which may be different from when the data was collected). Then I have a background task that takes the data, splits it and transforms it, and does some stats with it, then stores it in a NoSQL database with tables for each sensor category and a primary key made up of <sensor id>:<ts>, which makes it easy to query as a time series
It also publishes the processed data on another MQTT queue, where my web app listens for it and displays it if a user's connected.