TTN Decoder for Wireless Stick Lite Board

Hello @rsmedia @Saber @Sivaelid

Kindly can somebody share the TTN Decoder JavaScript function for the sketch OTAA_DHT11 using wireless stick lite board ? For me was able to connect to the TTN. just want the decoder function.

@BDM I have the following decoder for the CubeCell node with HDC1080 sensor, maybe it can help you.

Blockquote
function tofloat32(a1,a2,a3,a4){
var s=(a1&0xff)>>7;
var E=(a1<<1&0xff)|a2>>7;
var M0=(a2&0x7f)<<16|a3<<8|a4;
var M=1;
for(var i=0;i<23;i++)
{
if(M0>>i&0x01==1)
{
M=M+Math.pow(2,i-23);
}
}
var result=Math.pow(-1,s)MMath.pow(2,E-127);
return result;
}
function Decoder(bytes, Port)
{
var temperature = tofloat32(bytes[3],bytes[2],bytes[1],bytes[0]);
var humidity = tofloat32(bytes[7],bytes[6],bytes[5],bytes[4]);
var voltge = bytes[8]<<8|bytes[9];
var result={
“sensor”:{
“Temperature”:temperature,
“Humidity”:humidity,
“Voltge”:voltge,
}
}
return result;
}

1 Like

@andrelmbraga1 Thanks for sharing

1 Like