Decoding the data from TTN upload message in Node-red

Hi Guys,

I’m new to LoraWan and TTN and now I am building a Lora network with some sensor nodes and LoraWan gateway.
Now I manage to connect my node to the gateway and through TTN, data can be received by my Node-Red. However, the data cannot be decoded properly.
I have studied several websites and finally come to the current situation:
I can decode my manually-built Base64 test data. However, for the actual data, I always receive the error in Node-red: “SyntaxError: Unexpected token o in JSON at position 1”. I know it is due to the fact that the message/data is not in JSON. However, it still cannot find out how to change to JSON format so that I can decode my text. My text inside the payload is “hello”.
Attached is my node-red flow and data packet. Could anyone can provide a solution?

test_flow.json (4.4 KB)
Whole_msg.txt (949 Bytes)

This is frowned on in LORaWAN, it is very heavy on air time and thus you battery to send TEXT. Remember the FUP you need to comply to. 30sec per day total uplink time.

How did you configure your MQTT node?

What is the output set to?

Do you mean my TTN MQTT setting? Please find attached.
Then my node-red flow just read the data from the MQTT server accordingly. You can check my node-red flow.
Thanks!!

Have you checked the incoming message actually matches your expectation?

Yes, the data payload are received and are encoded using Base64. I can copy & paste into my injection node and decoded successfully. However, I cannot decode from my MQTT node-red node directly.

Did you link the output from the MQTT node to a debug node to compare the data structure you are receiving from that node?

BTW, to translate the output from the MQTT node to JSON include a JSON node after MQTT and before the next node.

You are asking about Node-Red, if you don’t answer the questions, we can’t guide you.

Hi Johan,
If you are asking my node-red MQTT setting, you can download my flow and find out.
Is that what you need to do analysis? If not, please clarify. Thank you!!

Why do you think I asked you? If I blindly fix all your mistakes, you are going to learn nothing.

Sorry, I can get your point. Could you please clarify what you need?

What is the settings on your MQTT node?

image

Please look and tell me what it is set as and the option available?

Please find attached the setting.

As you said

image

So let me do it for you then.

The output of the MQTT node needs to be.

image

Would you like me to build the application for you?

Yes, please! Thank you!!

1 Like

Can you let me know how much he charges you so I can add it to the price comparison site.

£ 100 000 000 000.00

dr-austin