I started about a year ago with a Raspberry Pi collecting some temperature readings, sending to a function node to define it as a field for Influx, then reading / querying Influx using Grafana.
Today I have about a dozen Pi's and several units from Opto22 that run Node-RED, and am collecting modbus data (both RTU via RS485 and TCP) as well as various other sensor data besides temperature (feedrate, rotational speed, etc.). The whole thing has become a huge mess (although everything works). I never structured my Influx time series data to use tags, and even though a certain piece of equipment may have 5 sensors (temperature, pressure, etc.), I am sending it to Influx as separate measurements with 5 different timestamps, which should not be necessary in my case. And oh yeah, along the way I discovered MQTT and see huge advantages in using that (in addition to Influx).
So I have decided to take a clean sheet approach and start over fresh. I watched the Influx schema design webinar and brought myself up to speed on Influx 2.0 and some of the Flux langauge, and organized (on paper) the various tags and fields that make sense. Here is a summary of the tags:
Tags | Examples |
---|---|
EquipType | furnace, prewash, tank |
EquipNumber | 314, 6 |
EquipElement | zone1, zone2, elevator, pump, feeder |
MeasType | actual, setpoint |
and here is a summary of the fields:
Fields | Type |
---|---|
temperature | integer |
feedrate | integer |
rotational_speed | float |
position | boolean |
pressure | float |
level | integer |
humidity | float |
Here is one way I envision this whole thing coming together:
In the above, the top block of nodes represents the data collected by the Opto22 device on a given piece of equipment (e.g. Furnace 6). Each sensor is collecting different things such as temperature, feedrate, elevator position, pump rotational speed, etc.). Instead of sending each sensor reading to Influx with it's own timestamp, my plan is to consolidate (via the Join node?) and then feed the tag and field measurement data to the MQTT node (is JSON format the right approach?). I would definitely have to manipulate the data using function nodes and the buffer-parser nodes (as I presently do). The Raspberry pi, which may be on the same machine but, say, at the other end with it's own ethernet connection, may be collecting temperature data from a different section (let's say zone 2 temperature). Again, I would have to manipulate the data before sending to MQTT and Influx.
Finally, my thought was to have a separate PC (probably the same one running Grafana) that hosts the Influx DB.
I am not experienced with MQTT, but I believe the payload & topic would correspond to the field & tag, respectively. I believe that using JSON format would allow me to send all the readings and all the tags in one expression. For example, all of the sensor readings below would be sent to Influx with the same timestamp. The Influx tag descriptions below (x/y/z) should also be mirrored in the MQTT topics, correct?
- 627 = furnace / 6 / zone1 / actual (this means the temperature controller on furnace 6 in zone 1 is reading 627 C)
- 625 = furnace / 6 / zone1 / setpoint (this means the temperature controller's setpoint for zone 1 is 625 C)
- 97.8 = furnace / 6 / pump / actual (this means the pump on furnace 6 is reading 97.8 Hz)
- 100.0 = furnace / 6 / pump / setpoint (this means the pump on furnace 6 has a setpoint of 100.0 Hz)
- TRUE = furnace / 6 / elevator (this means the elevator status on furnace 6 is UP)