Gooday, I have a SenseCAP LoRa barometer connected to The Things Network and trying to extract the payload delivered by a MQTT node. The payload(one big object) is as follows:
22/09/2021, 19:29:38[node: c820ff3f.fc1bf](http://192.168.1.160:1880/#)v3/barosense01@ttn/devices/eui-2cf7f127325000de/up : msg.payload : string[1783]
"{"end_device_ids":{"device_id":"eui-2cf7f127325000de","application_ids":{"application_id":"barosense01"},"dev_eui":"2CF7F127325000DE","join_eui":"8000000000000009","dev_addr":"260DBDE5"},"correlation_ids":["as:up:01FG6DDK92YFRZ9J62YMXPWA66","gs:conn:01FG16B14S42TWEKV9YYR111RC","gs:up:host:01FG16B2KR9NTJ1MGNC387YA6A","gs:uplink:01FG6DDK1CG1EJ7KFXM36YAPMF","ns:uplink:01FG6DDK1EV1ACVHG8Q4TYTBJ1","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FG6DDK1E8WQNYYGGV4SB0GMK","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FG6DDK925CQ8F2VJPRH2AGCK"],"received_at":"2021-09-22T09:29:36.291418585Z","uplink_message":{"session_key_id":"AXvxx05t+WEkWnl/zQvOEg==","f_port":2,"f_cnt":272,"frm_payload":"AQUQ6BIYBgpg","decoded_payload":{"err":0,"messages":[{"measurementId":4101,"measurementValue":102241,"type":"report_telemetry"}],"payload":"010510E81218060A60","valid":true},"rx_metadata":[{"gateway_ids":{"gateway_id":"gladesville-gateway1","eui":"A84041FFFF1EDFB8"},"time":"2021-09-22T09:29:36.044922Z","timestamp":121195..."
The part I wish to extract and insert into MariadB is the 102241 part of "measurementValue":102241. I have a function node which contains the following:
msg.baro = msg.payload.measurementValue;
msg.topic = "INSERT INTO TTNsensors(barometrics) VALUES('"+msg.baro + "');"
return msg;
Following the mysql node, I get following debug message and nothing is inserted into the database.
22/09/2021, 19:29:40[node: e347f173.4d1de](http://192.168.1.160:1880/#)INSERT INTO TTNsensors(barometrics) VALUES('undefined'); : msg : Object
object
topic: "INSERT INTO TTNsensors(barometrics) VALUES('undefined');"
payload: object
qos: 0
retain: false
_msgid: "ef678dbd.24a44"
baro: undefined
I am guessing the problem lies in the payload extraction function node. Can I get some guidance in what I need to change to make this work.
Cheers.