Extract data from payload

Hi everybodies,

I am new in this field and tried to connect MQTT broker to the TTN network and extract the message.

In the next step I want to put this data into an influx db and visualize data in grafana.

The device measures gas, temperature, pressure and humidity.

How can I extract (temp, pressure, humidity and gas) from the payload?

Here is my payload msg:

{"end_device_ids":{"device_id":"eui-70b3d57ed004ae72","application_ids":{"application_id":"gps-tracker-giulio"},"dev_eui":"70B3D57ED004AE72","join_eui":"0000000000000000","dev_addr":"260BF022"},"correlation_ids":["as:up:01FV73VRZ62V82E6AG2D2T7NQR","gs:conn:01FV73GYZPBBSBPC5QWXMBKZN6","gs:up:host:01FV73GYZWTSWV21PFX8BJSNMW","gs:uplink:01FV73VRRH41SBMTJGR42YM2FM","ns:uplink:01FV73VRRNZM7BMBQ6M7C9Z0WJ","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FV73VRRNHXFDR0RJNZK82WPV","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FV73VRZ525XQ3CJDSP82WJBT"],"received_at":"2022-02-06T08:54:29.607148170Z","uplink_message":{"session_key_id":"AX7OPJCA3IZ8Mzsvs/8AKA==","f_port":2,"f_cnt":3,"frm_payload":"AQkEFBAAAY23AAAbuA==","decoded_payload":{" **GAS** ":7096," **HUM** ":51.36," **PRES** ":1018.15," **TEMP** ":23.08},"rx_metadata":[{"gateway_ids":{"gateway_id":"rak7243c","eui":"B827EBFFFE4C1D1A"},"timestamp":356658652,"rssi":-47,"channel_rssi":-47,"snr":13,"location":{"latitude":45.558211494500696,"longitude":11.56566059586112,"source":"...

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.




As a new user, here is some canned text to get you up to speed...

posting code

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

   code goes here 

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

recommended watching

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

1 Like

Make sure that in the the mqtt node you have the output set to parsed JSON. Then the node will parse the JSON string and output a JavaScript object.

1 Like

Thank you very much!
I set parsed JSON and now I have this message:

How can i "extract" the data?

Thank you for the information!

↑ exactly like i described ↓

If you are unsure what to do once you have copied the path then you likely need to run through the recommended videos to understand the basics of node-red.

Use a change node and set the payload to the copied path from the debug window.


1 Like

Or if, as I do, you find it more intuitive, use

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.