MQTT Payload Help Please

MQTT Payload Help Please

@Rob Young

Hi Guys

So I have a LoRaWAN soil moisture sensor working perfectly. I have decided to go nb-iot instead and am trying to configure the equivalent device (same manufacturer, same sensor, NB version).

I have managed to get it connecting and sending a payload but I’m having trouble decoding it. I’m a looong way from being a coder but I’d managed to get the LoRaWAN device going with a payload parser in TheThingsNetwork. I’ve tried using the same parser in Tago but it’s not working.

Please help with what I need to do to get this device decoding and storing data.

This is what’s coming through in the Live Inspector:

This is from the user manual:
The payload is ASCII string, representative same HEX:
0x72403155615900640c7817075e0a8c02f900 where:
➢ Device ID: 0x 724031556159 = 724031556159
➢ Version: 0x0064=100=1.0.0
➢ BAT: 0x0c78 = 3192 mV = 3.192V
➢ Singal: 0x17 = 23
➢ Soil Moisture: 0x075e= 1886 = 18.86 %
➢ Soil Temperature:0x0a8c =2700=27 °C
➢ Soil Conductivity(EC) = 0x02f9 =761 uS /cm
➢ Interrupt: 0x00 = 0

This is the payload parser used in TTN for the other (LoRaWAN) device.

function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var value=(bytes[0]<<8 | bytes[1]) & 0x3FFF;
var batV=value/1000;//Battery,units:V

value=bytes[2]<<8 | bytes[3];
if(bytes[2] & 0x80)
{value |= 0xFFFF0000;}
var temp_DS18B20=(value/10);//DS18B20,temperature,units:℃

value=bytes[4]<<8 | bytes[5];
var water_SOIL=(value/100);//water_SOIL,Humidity,units:%

value=bytes[6]<<8 | bytes[7];
var temp_SOIL;
if((value & 0x8000)>>15 === 0)
temp_SOIL=(value/100);//temp_SOIL,temperature,units:°C
else if((value & 0x8000)>>15 === 1)
temp_SOIL=((value-0xFFFF)/100).toFixed(2);//temp_SOIL,temperature,units:°C

value=bytes[8]<<8 | bytes[9];
var conduct_SOIL=(value);//conduct_SOIL,conductivity,units:uS/cm

return {
Bat:batV,
TempC_DS18B20:temp_DS18B20,
water_SOIL:water_SOIL,
temp_SOIL:temp_SOIL,
conduct_SOIL:conduct_SOIL
};
}

Thanks in advance