Extract data from an MQTT payload

#1

Hi all,

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:

"{"app_id":"isyboard",
"dev_id":"isyboard-2106",
"hardware_serial":"0004A30B002821A6",
"port":98,
"counter":17773,
"payload_raw":"DhYAALREJh8BALNAJiQ=",
"payload_fields":{"bat":3.61,
"bot":{"humi":32,"pres":976.4,"temp":17.9},

  • "top":{"humi":32,"pres":976.4,"temp":17.9}},*
    "metadata":{"time":"2019-03-10T13:11:03.407677436Z","frequency":867.7,"modulation":"LORA","data_rate":"SF7BW125","airtime":66816000,"coding_rate":"4/5","gateways":[{"gtw_id":"eui-b827ebfffe86efb6","timestamp":2114939276,"time":"2019-03-10T13:11:03.388643Z","channel":6,"rssi":-59,"snr":9,"rf_chain":0,"latitude":50.073685,"longitude":14.416852,"altitude":15,"location_source":"registry"},{"gtw_id":"eui-b827ebfffe4d6081","timestamp":2123351012,"time":"2019-03-10T13:11:03.389984Z","channel":6,"rssi":-100,"snr":9,"rf_chain":0,"latitude":50.07374,"longitude":14.416893,"altitude":15,"location_source":"registry"}]}}"

Many thanks in advance !
Peter

0 Likes

#2

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.

Don't hesitate to come back when you get stuck.

0 Likes

#3

I will try !
Thanks so far for your help.
Br Peter

0 Likes