Payload Encoding and Decoding Arduino LMIC LoRaAppServer

Hi guys,

i’m really sorry, but i’m a little lost here on how to properly decode data send by an LMIC arduino device with Dragino LoRa HAT.
In LMIC i’m using the following test string as a data:
static uint8_t mydata[] = “Hello, world!”;
To send the data the following command is used:
LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);

The Lora App Server receives the LoraWAN Frame and puts the “rx” onto mqtt with an output like follows:

application/1/device/00000000affe2803/rx {“applicationID”:“1”,“applicationName”:“testapp”,“deviceName”:“DraginoShieldTest”,“devEUI”:“00000000affe2803”,“rxInfo”:[{“gatewayID”:“b827ebfffe4c09b0”,“name”:“gateway03”,“rssi”:-63,“loRaSNR”:7.8,“location”:{“latitude”:0,“longitude”:0,“altitude”:0}}],“txInfo”:{“frequency”:868500000,“dr”:5},“adr”:true,“fCnt”:10,“fPort”:1,“data”:“B32JrzXFtP33PUuUsw==”}

If i simly use base64 decoding (e.g. paste the received data into then the outcome is garbage, not the string i expect.

In the Application Server Settings for the Application i tried “Payload Encoding: none” und “Cayenne LPP”, but this did not make any difference.
What piece in this puzzle am i missing? Are there some further settings i need to make?
Please give me a hint on how to properly decode that payload.

Thank you very much!

Did you check the disable frame counter validation ?

Yes, i disabled the frame counter validation under the application/device settings.

I just tried without disabled FCnt Setting for this device, but the result is not different:

application/1/device/00000000affe2803/rx {“applicationID”:“1”,“applicationName”:“testapp”,“deviceName”:“DraginoShieldTest”,“devEUI”:“00000000affe2803”,“rxInfo”:[{“gatewayID”:“b827ebfffe4c09b0”,“name”:“gateway03”,“rssi”:-57,“loRaSNR”:9.2,“location”:{“latitude”:0,“longitude”:0,“altitude”:0}}],“txInfo”:{“frequency”:868300000,“dr”:5},“adr”:true,“fCnt”:0,“fPort”:1,“data”:“u29YIXh3Dfg0njBTbQ==”}

With our without frame counter enabled, the decrypted but still encoded data payload seems to change for every packet. why is this?

I don’t really know why you have this behavior with the frame counter validation enabled. You are reading this JSON on MQTT, right ? What do you have in “Live event logs” tabs ?

However, keep the frame counter validation enabled. You won’t have anything if you have it disabled.

Are you using OTAA or ABP? In case of ABP, maybe you have mis-configured your AppSKey?

Hi all,

thank you very much. Brocaar, you were right, i had a typo in the AppSKey!

Now everything works. Perfect! Solved.

1 Like

Hi all,

I’m so new at this field, i am using a Arduino Nano with LMIC library in OTAA mode to send data to a gateway in a chirpstack server, i want to decode the data that i receive, for example “ABQAFA==” but i don’t have idea how to proceed.
I tried with this tool but i don’t have some answer with sense.

Thanks in advance

$ echo ABQAFA==|base64 -D|hexdump -C
00000000  00 14 00 14                                       |....|

That looks like a reasonable (decrypted) payload. What do the 0x00 and 0x14 bytes mean, did you program them yourself?

you’re right, 00 14 bytes mean an integer temperature in hex. In this case, i’m going to write a code to decode the original message in decimal on the chirpstack server in the Custom JavaScript codec functions, Does that idea make sense?.

Thanks for you reply

1 Like

Hello Brocaar,
Please I have a node that is connected to a voltage divider as voltage sensor and AC712 current sensor, I am trying to get an ABP arduino code to send my voltage, current and power data to the chirpstack server. and also send downlink to turn on or off two LEDs on the node. please your help will be appreciated…