Weather_monitoring example's decode code

Hey Rak Community,

I am trying to use the Weather_Monitoring code given in Arduino (See the picture).

There is no payload decoder available for this example.
Can anyone provide me with one? If you can explain that would be great but if you can’t I understand.

Thanks,
HG

Hello Hiren,

The decoder can be found in the RAK Developer Kit 2 tutorial

function Decoder(bytes, port) 
{
  var decoded = {};
  
  if (port== 2)
  {
    var temp  = ((bytes[1]) << 8) | (bytes[2]);
    temp = (temp/100.0);
    decoded.temp = temp;
    
    var hum  = ((bytes[3]) << 8) | (bytes[4]);
    hum = (hum/100.0);
    decoded.hum = hum;
    
    var press = (bytes[5] << 24) | (bytes[6] << 16) | (bytes[7] << 8) | (bytes[8]);
    press = (press / 100.0);
    decoded.press = press;
    
    var light = ((bytes[9]) << 8) | (bytes[10]);
    light = (light / 100.0);
    decoded.light = light;

    return decoded;
  }
}

It is for TTN and will need little adjustments for other LoRaWAN servers.