Payload decoder Javascript

Hello everyone,

I receive some data from my sensor :
This is the payload that I’m expected, but when I’m checking in “Event” at data it shows me this :
Which for me is an issue because when I put some java to decode the payload I get something like this :

My goal is to send those data to InfluxDB, so first I need to decode this payload image, but I can’t If I’m not able to retrieve the data into a variable.

Thank you very much!

Sounds like you’re decoding it wrong. The data field in the uplink is shown in Base64 encoding, you’ll want to do a base64 to hex conversion.
If you paste your data into here: you get your expected bytes in hex.

1 Like

Hi Ritch, It sounds to me that you are missing one conversion.

You should receive data in base64, transform it to hex and, finally, from hex to ascii.

I needed to do this conversion to use THINGSBOARD http integration (so that Thingsboard can “read” the data properly).

PS: You should also “split” or “parse” the data in the correct bytes.

I have some guides here.
You need to convert from hex/base64 to json or human readable ascii

1 Like

I find the issue of my problem, yes.

function decodeUplink(input)
    data: Decode(input.fPort, input.bytes, input.variables)

function Decode(fPort, bytes, variables) {
  var data ={"Temp1":"",
  data.battery= bytes[1] & 0x0002;
  data.Temp1= (bytes[3] + bytes[2])/10;
  data.Temp2= (bytes[5] + bytes[4])/10;
  data.bytes= bytes;
  return data;

This is the code that I used to decode the payload of an Adeunis Temp sensor :slight_smile:

1 Like

Thanks for sharing!

May be useful for someone