I am a newbie and tried to connect with an MQTT broker to the TTN network and to extract data from my nodes in the TTN network. In the next step I want to put this data into an influx db. There are two sensors on this board which measures temperature, pressure and humidity. One is on the top (top) and the other on the bottom (bot). How can I extract these two pairs (temp, pressure, humidity) from both sensors ?
Here is my msg object:
If it has come from MQTT it's most likely to be a String type - and you really need it as JSON so pass it through a JSON node to format it up - then read this https://nodered.org/docs/user-guide/messages which should help you understand how to extract the pieces you want from that object (probably) using a change node.
Your payload is currently a JSON string. You need to parse it to an object before you can access is contents. The mqtt node provides an option to do that for you, or you can use a JSON node.
Output of MQTT node is configured as "auto-detect" - although none of other options helps. Output is indeed valid JSON file. If i try to be more precise: point is to get
Maybe i have to explain what is behind this problem. I believe this will be useful for someone else due to changes in way of capturing data from TTN. As we know there is no more support for "ttn message" node in last version of NodeRed. Instead we have to use NodeRed's standard MQTT client node to access data. So far so good, but this lead to different way of decoding TTN message. I mean, TTN decoder is out of function and we have to decode useful data from payload before we send them into database (influx, in my case).
This could be done - by my knowledge - with function node in NodeRed. But please let me know if there is any other better option.
OK, with the MQTT node correctly configured all the data are there and accessible. Do you need further help?
If you are not sure how to extract the data then have a read of this. https://nodered.org/docs/user-guide/messages
I find that surprising. What exactly are you doing with that data? You say you are sending it to an Influxdb, but that format it not what the standard Influxdb Out node expects.
What type of node is PMS DB? An Influx Out or an Influx Batch. I guess it is the Influx Out. In which case you have to look at the info tab to see how to format the data.