Dragino LSE01

Hello my friends,

I lately bought a Dragino LSE01 and put it in TTN.
Everything works fine but the data that is coming out confusing me.
As you can see at the picture below is the output for Bat and conduct_SOIL correct.
But my other readings are within quots!
resultttn

So when I put everthing together in Nodered and connect it to my database I miss some readings.
Does anybody knows whats wrong?
nodered

Start looking at the decoder that you are using - if it looks wrong in the console view per the message metadat you have poasted above then there is an issue there… your node red code doesnt come into play at this point…

I use this payload.
It’s provided at Dragino:

function decodeUplink(input) {
var port = input.fPort;
var bytes = input.bytes;
var value=(bytes[0]<<8 | bytes[1]) & 0x3FFF;
var batV=value/1000;//Battery,units:V
value=bytes[2]<<8 | bytes[3];
var data = {};
switch (input.fPort) {
case 2:
if(bytes[2] & 0x80)
{value |= 0xFFFF0000;}
data.Bat=batV;
data.TempC_DS18B20=(value/10).toFixed(1);//DS18B20,temperature,units:℃

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

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

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

return {
data:data,
};
default:
return {
errors: [“unknown FPort”]
}
}
}


Save Edit
Close

…and is it the correct one for the firmware/build of your version of the sensor? (check any release notes etc.)

There were 4 different versions and I did try them all.

As the Bat and conduct_SOIL numbers are not quoted, you might want to look at the differences between how they are processed in the payload formatter and the other values.

And please use the </> formatting tool for code & logs.

This transforms your number into a string, hence the quotes. Leave it of and you will get numbers. Or in node red use a function with JavaScript code to transform the string back to a number.

Thanks Jac, that was the trick. Works like a charme now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.