Hi, I'm brand new to NodeRed, MQTT, InfluxDB and Grafana
I'm trying to visualize Data form a ESP8266. Onto the dashboard the data come in. But I've got an issue to transform the MQTT data into an proper format for InfluxDB. NodeRed time series graphs work fine, but I can't visualize the MQTT sensor data in Grafana.
What should I do? A transformation with the json block, and a custom function. But what shoult the function looks like? Everything I tried doesn't work.
I prefer to use the influx batch node over the single influxdb node because it works a bit more efficiently for large quantities of data. It likes data to be an array of objects. Here's an example of the format it likes:
var field1Data = 10
var field2Data = 12
var field3Data = 15
var tag1Data = "what is this?"
var tag2Data = "I'm a tag!"
var payload=(
{measurement: "measurementName",
fields: {
field1: field1Data,
field2: field2Data,
field3: field3Data
},
tags: {
tag1: tag1Data,
tag2: tag2Data
},
timestamp: new Date()
})
node.send({payload})
You would of course want to grab parts of your inbound message to populate your fields and tags as per your use case. This is set up in a way that you can use a join node at the end of the flow to combine a predetermined number of payloads into an array to send through influx batch.
...so, I've got 4 sensors, and the 'if' condition only runs the function if the incoming flow contains msg.node == 18 device:"th18" is the tag msg.measurement = "iot" is the measurement