Unable to see data in MQTT JSON

Hi ,
Im new here ,
I was able to subscribe and receive data from TTN MQTT to my app. I am able to see
Device location / rssi etc , but temperature / humidity data is missing ,
Will appreciate any tips to sort this issue.

Example message i receive via MQTT

{
  "end_device_ids": {
    "device_id": "eui-a8404100xxxxxxx",
    "application_ids": {
      "application_id": "xxxxxxxxxxxxxx"
    },
    "dev_eui": "A840410001xxxxxx",
    "join_eui": "A000000000000100",
    "dev_addr": "260B004B"
  },
  "correlation_ids": [
    "as:up:01FZWBP2VWNKB1TQSW3ZQC9918",
    "gs:conn:01FZT7EE3TV510BB6FBZ4F6WYK",
    "gs:up:host:01FZT7EE65FWST39JG6NV7QT2V",
    "gs:uplink:01FZWBP2NBW0HGSFN4DVK1RV0B",
    "ns:uplink:01FZWBP2NC9M2C1DVJFM3FXA09",
    "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FZWBP2NC5R9JD2PD6YAVY4PK",
    "rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FZWBP2VWCAVEKGV076E461FK"
  ],
  "received_at": "2022-04-05T07:58:02.108939792Z",
  "uplink_message": {
    "session_key_id": "AX/Q0acXiEbjtOI1ku/qkg==",
    "f_port": 2,
    "f_cnt": 558,
    "frm_payload": "y+cIXwE4AQfcf/8=",
    "rx_metadata": [
      {
        "gateway_ids": {
          "gateway_id": "xxxxxxxx",
          "eui": "60C5A8FFxxxxxxxx"
        },
        "time": "2022-04-05T07:58:01.842226982Z",
        "timestamp": 2832860276,
        "rssi": -62,
        "channel_rssi": -62,
        "snr": 10,
        "location": {
          "latitude": 53.64696457749792,
          "longitude": 10.036027488968104,
          "altitude": 15,
          "source": "SOURCE_REGISTRY"
        },
        "uplink_token": "ChkKFwoLaGlsbHRyb25pYzESCGDFqP/+dg+XXXXXXXXXXXXXXXXXXXXXXXXXX"
      }
    ],
    "settings": {
      "data_rate": {
        "lora": {
          "bandwidth": 125000,
          "spreading_factor": 7
        }
      },
      "coding_rate": "4/5",
      "frequency": "867700000",
      "timestamp": 2832860276,
      "time": "2022-04-05T07:58:01.842226982Z"
    },
    "received_at": "2022-04-05T07:58:01.900707183Z",
    "consumed_airtime": "0.061696s",
    "network_ids": {
      "net_id": "000013",
      "tenant_id": "ttn",
      "cluster_id": "ttn-eu1"
    }
  }
}

This line is your data in Base64 format - when you decode it you will have the byte array that your device sent. TTS can’t automagically do this because what you send is coded by you but you can tell it what the format is & decode it with a payload formatter.

Check out the documentation (link bottom right of every console page), particularly https://www.thethingsindustries.com/docs/reference/data-formats/#uplink-messages and https://www.thethingsindustries.com/docs/integrations/payload-formatters/ plus this older info which is still relevant https://www.thethingsnetwork.org/docs/devices/bytes/

I’ve moved your post from a topic unrelated to MQTT & JSON to a new one - and formatted your post using the </> tool on the toolbar - please see formatting guidelines

1 Like

Thank you.
Will read and try to decode the sensor information.
Thanks again.

What device/ node are you using? Self made or off the shelf?

If off the shelf the manufacturer shoul be ablel to supply you a decoder.

I self made, then read documents as suggested dy @descartes

Hi Johan ,
Thank for your reply and sorry for late response ,
We test with "lht65 " device ,
After applying the data formatter , Im able to get the decoded_payload.

“decoded_payload”: {
“BatV”: 2.973,
“Hum_SHT”: “36.3”,
“TempC_DS”: “21.87”,
“TempC_SHT”: “22.46”
Now I want to see the possibility to take off " " from sensor values ,I assume decoder can be modified to do this ? any thoughts ?

You decoder are changing the int to a string.

thanks , will see how I can change it to integer

Hello ,
Modified the decoder and we get the sensor values as integer

thanks for your support.

but the vales are actually floats …

@weradis
thanks , I will check.

Hi Ysv,
I am also implementing an MQTT protocol in JSON to get data from TTN, but I failed. Could you please give me your MQTT program in JSON?

Json is a data format, not a programming language. Do you mean JavaScript?

My apologies, Kersing. I am a newbie. Could you please give me a template program in Javascript to implement an MQTT to receive messages from TTN?
It is better if you could give me a document about how to implement it. I really appreciate your help!

Google helps: MQTT.js tutorial | EMQ

And for the TTN specifics MQTT Server | The Things Stack for LoRaWAN

Thank you so much for your support. I already wrote an MQTT protocol in Python and It works.