# Tekelek TEK766 payload format

**URL:** <https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444>\
**Category:** Application Development\
**Created:** [May 29, 2020, 4:30pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444 "2020-05-29T16:30:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cloudnet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cloudnet/32/46598_2.png) [@cloudnet](https://www.thethingsnetwork.org/forum/u/cloudnet)\
**Post date:** [May 29, 2020, 4:30pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/1 "2020-05-29T16:30:46Z")

</div>

Hello.

I have recieved a tekelek766 lorawan device. Registered it and it is talking to the TTN.

However I have asked the company for the payload and they have not provided me the documentation to interpret the data. They keep asking me about who I bought it from and what support I am getting from the company. I think is a little strange taking into account the spirit of IoT.

Does anyone know where I can get this document from please.

Also if you have any php scripts to convert the payload into the grafana influx database. This would be appreciated but not a problem if not.

Thank you

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [May 29, 2020, 6:12pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/2 "2020-05-29T18:12:21Z")

</div>

At a commercial level, companies can try to offload their support to the reseller - I personally don’t as I try to make my documentation so clear that we get very few support issues and then only deal with the ‘interesting’ issues.

It does seem unusual that there are no documents on their website to help with this.

But they have asked you to go back to the people who sold it to you - what do they say?

---

<div class="post-metadata">

**Author:** ![cloudnet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cloudnet/32/46598_2.png) [@cloudnet](https://www.thethingsnetwork.org/forum/u/cloudnet)\
**Post date:** [May 29, 2020, 8:37pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/3 "2020-05-29T20:37:47Z")

</div>

Hi Nick.

Thank you for the response.

The company is a distributer, and I bought from Germany, so waiting a response from them. That was a few days ago.

Tekelek only asked who did I buy the product from, and what support agreements do I have with them… to which I replied accordingly. “none” the company is wholesale, much like RS Components or CPC. Interestingly and prior to this, I asked to purchase the devices from the company them selves, to be told no, go through their distributor. The contact given didnt get back to me, so searched and bought elsewhere.

Strange the company dont have any documentation, but I suspect they want people to use them for services and charge for thier time/portal etc, so as to generate income fro doing so.

Cheers

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [May 29, 2020, 9:01pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/4 "2020-05-29T21:01:48Z")

</div>

~~Just a wild idea, if no description is to be found anywhere: any chance it’s sending ASCII text…? (An example payload might easily confirm or confute that.)~~

It’s not text: [https://codereview.stackexchange.com/questions/225928/driver-for-sensor-payload-decoder](https://codereview.stackexchange.com/questions/225928/driver-for-sensor-payload-decoder) (not production ready code, I’d say).

---

<div class="post-metadata">

**Author:** ![cloudnet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cloudnet/32/46598_2.png) [@cloudnet](https://www.thethingsnetwork.org/forum/u/cloudnet)\
**Post date:** [May 29, 2020, 9:06pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/5 "2020-05-29T21:06:44Z")

</div>

I will capture the daya off the payload and see if there is any commonality.

I shall get data and let you see.

Thank you

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [May 29, 2020, 9:15pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/6 "2020-05-29T21:15:43Z")

</div>

See [https://github.com/faithhunja/Tekelek-Ultrasonic-LoraWAN-Level-Sensor](https://github.com/faithhunja/Tekelek-Ultrasonic-LoraWAN-Level-Sensor)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [May 29, 2020, 9:16pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/7 "2020-05-29T21:16:30Z")

</div>

> [@arjanvanb](#):
>
> It’s not text: [javascript - Driver for sensor payload decoder - Code Review Stack Exchange](https://codereview.stackexchange.com/questions/225928/driver-for-sensor-payload-decoder)

Strong is your GoogleFu master @arjanvanb!

And taking your cue of using the part number, I found this:

> <https://github.com/CampusIoT/payload-codec/blob/master/src/main/javascript/tekelec/tekelec_tek766_codec.js>

---

<div class="post-metadata">

**Author:** ![quintin5010](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/quintin5010/32/35697_2.png) [@quintin5010](https://www.thethingsnetwork.org/forum/u/quintin5010)\
**Post date:** [July 9, 2020, 10:56am UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/8 "2020-07-09T10:56:20Z")

</div>

Hi, this is the decode i use for the meter. hope it helps.

```
function Decode(fPort, bytes) {
  if(fPort == 16){
    
    var L1 = 0;
    var L2 = 0;
    var L3 = 0;
    var L4 = 0;
    
    var temp1 = 0;
    var temp2 = 0;
    var temp3 = 0;
    var temp4 = 0;
    
    var TotL = 287+5; //// Total height of the tank cm
    //var TotL = 228+8;
    var TotLL = 83000; //// Total liter of the tank L
    
    var LLeft1 = 0;
    var LLeft2 = 0;
    var LLeft3 = 0;
    var LLeft4 = 0;
    
    L1 = ((bytes[4] * 256) + bytes[5]);
    L2 = ((bytes[8] * 256) + bytes[9]);
    L3 = ((bytes[12] * 256) + bytes[13]);
    L4 = ((bytes[16] * 256) + bytes[17]);
    
    L1 = TotL - L1;
    LLeft1 = (L1/TotL)*100;
    LLeft1 = 100/LLeft1;
    LLeft1 = TotLL/LLeft1;
    LLeft1 = LLeft1.toFixed(2);

    L2 = TotL - L2;
    LLeft2 = (L2/TotL)*100;
    LLeft2 = 100/LLeft2;
    LLeft2 = TotLL/LLeft2;
    LLeft2 = LLeft2.toFixed(2);
    
    L3 = TotL - L3;
    LLeft3 = (L3/TotL)*100;
    LLeft3 = 100/LLeft3;
    LLeft3 = TotLL/LLeft3;
    LLeft3 = LLeft3.toFixed(2);
    
    L4 = TotL - L4;
    LLeft4 = (L4/TotL)*100;
    LLeft4 = 100/LLeft4;
    LLeft4 = TotLL/LLeft4;
    LLeft4 = LLeft4.toFixed(2);
    
    temp1 = bytes[6];
    temp2 = bytes[10];
    temp3 = bytes[14];
    temp4 = bytes[18];
    
    return {L1:L1,L2:L2,L3:L3,L4:L4,T1:LLeft1,T2:LLeft2,T3:LLeft3,T4:LLeft4,Temp1:temp1,Temp2:temp2,Temp3:temp3,Temp4:temp4};
    
  }
  if(fPort == 48){
    
    var Bat = 0;
    
    Bat = bytes[10];
    
    return {Bat:Bat};
    
  }  
  
}
```

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [July 9, 2020, 12:18pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/9 "2020-07-09T12:18:36Z")

</div>

Nice, thanks for sharing!

Just some minor asides:

> [@quintin5010](#):
>
> ```auto
> LLeft1 = LLeft1.toFixed(2);
> 
> ```

Note that `toFixed` returns a string, but [you may want a number](https://www.thethingsnetwork.org/forum/t/decrypting-messages-for-dummies/4894/22).

> [@quintin5010](#):
>
> ```auto
> temp1 = bytes[6];
> temp2 = bytes[10];
> temp3 = bytes[14];
> temp4 = bytes[18];
> 
> ```

Beware that these do not support negative temperatures. According to [some documentation](https://www.ime.de/shop/www.ime.de/produktdatenblaetter/A41702_2.pdf#page=8) it’s actually a signed integer:

 ![Payload format](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/5/b/5bb8bb3d94a9d7f14268a0919a25f00510d33380.png)

 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/7/c/7cb51d6bb74b755119fc2c7e5181d156141372d6.png)

> [@cloudnet](#):
>
> I will capture the daya off the payload and see if there is any commonality.
> 
> I shall get data and let you see.

Please share! And what decoder did you end up with?

---

<div class="post-metadata">

**Author:** ![quintin5010](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/quintin5010/32/35697_2.png) [@quintin5010](https://www.thethingsnetwork.org/forum/u/quintin5010)\
**Post date:** [July 9, 2020, 12:58pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/10 "2020-07-09T12:58:57Z")

</div>

Thanks for the advice, will defn change them to integer 😉

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [July 9, 2020, 1:27pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/11 "2020-07-09T13:27:45Z")

</div>

Do you have any example payloads for different temperatures, especially values of 33°C and above?

The two example values in the documentation (0x1B being 27°C, and 0xF2 being -14°C), happen to be [regular signed integers](https://www.thethingsnetwork.org/forum/t/laird-rs1xx-probably-a-question-on-bit-shifting/37808/7). But the “greater than 32” (rather than 127) in the following surprises me:

> Temperature ranges -20°C to +50°C (Variable range -127 → 127)
> 
> - - ([256 or 0] - Byte)
> - If the decimal conversion of the byte is greater than 32 then the number required for the formula is 256 otherwise the number required for the formula is 0.

That makes me wonder how temperatures of 33°C and above would be sent. I don’t think that’s possible at all with this formula?

[The decoder](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/7) that @descartes found also assumes a standard signed integer. (Note that `var temp0 = p.readInt8(6)` is not supported in the JavaScript version that TTN Payload Formats use.) And [another decoder](https://github.com/faithhunja/Tekelek-Ultrasonic-LoraWAN-Level-Sensor/blob/master/measurements_conversion.py#L15-L18) uses the value 50, rather than 32, which probably works as the documented range is -20°C to +50°C. But for a standard signed integer, it should really be 127 (or, when using bitwise operators, `if (value & 0x80) ...`).

I’d assume that the following should do:

```javascript
// Sign-extend a single byte to 32 bits to make JavaScript understand
// negative values, by shifting 24 bits to the left, followed by a
// sign-propagating right shift of the same number of bits.
temp1 = bytes[6]<<24>>24;
temp2 = bytes[10]<<24>>24;
temp3 = bytes[14]<<24>>24;
temp4 = bytes[18]<<24>>24;

```

---

<div class="post-metadata">

**Author:** ![cloudnet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cloudnet/32/46598_2.png) [@cloudnet](https://www.thethingsnetwork.org/forum/u/cloudnet)\
**Post date:** [July 9, 2020, 3:41pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/12 "2020-07-09T15:41:46Z")

</div>

Here is payload data that will definately have temperatures above 33DegC however, the distance will be very small, because its been sitting in a small area in a warm place.

[incoming\_014.txt](https://www.thethingsnetwork.org/forum/uploads/short-url/xrlUlVIsPMupS0Ko99pgxJmEqtO.txt) (108.5 KB)

---

<div class="post-metadata">

**Author:** ![jerrier77](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jerrier77/32/35374_2.png) [@jerrier77](https://www.thethingsnetwork.org/forum/u/jerrier77)\
**Post date:** [December 22, 2020, 2:11pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/13 "2020-12-22T14:11:25Z")

</div>

Hi,

Thanks for this, I found it really helpful. I am using it in Chirpstack and it seems to be working fine.

I just wanted to ask if this was your final version? Also, why are there 4 level values and 4 temp values?

Apologies if this is covered somewhere, but I am finding it incredibly difficult to find any documentation on this. If anyone can point me in the direction of where I can see it, that would be great.

---

<div class="post-metadata">

**Author:** ![mid-walesha](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mid-walesha/32/48324_2.png) [@mid-walesha](https://www.thethingsnetwork.org/forum/u/mid-walesha)\
**Post date:** [December 23, 2020, 4:59pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/15 "2020-12-23T16:59:21Z")

</div>

Keep running into this issue with various manufacturers… Annoying. Decoders should be readily available on their support/website.

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [December 23, 2020, 6:21pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/16 "2020-12-23T18:21:40Z")

</div>

> [@mid-walesha](#):
>
> Decoders should be readily available on their support/website.

At least a description of the payload format with examples.

---

<div class="post-metadata">

**Author:** ![mid-walesha](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mid-walesha/32/48324_2.png) [@mid-walesha](https://www.thethingsnetwork.org/forum/u/mid-walesha)\
**Post date:** [January 28, 2021, 12:04pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/17 "2021-01-28T12:04:31Z")

</div>

… And a description which is accurate ☹

---

<div class="post-metadata">

**Author:** ![mmadlena](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mmadlena/32/35697_2.png) [@mmadlena](https://www.thethingsnetwork.org/forum/u/mmadlena)\
**Post date:** [December 30, 2021, 8:21pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/18 "2021-12-30T20:21:14Z")

</div>

Hello, I have tried to copy and paste the js script in TTN Payload Converter section, but i t doesn’t work (_ReferenceError: module is not defined at :151:1(15)_) I have tried to test it with the string “1000000001121B7701131BAA01121BA90114F274”. Someone can help me ? Kind Regards, Marco.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [December 30, 2021, 8:48pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/19 "2021-12-30T20:48:55Z")

</div>

> [@mmadlena](#):
>
> I have tried to copy and paste the js script

Which script exactly?

None of the ones linked above are v3 ready.

---

<div class="post-metadata">

**Author:** ![mmadlena](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mmadlena/32/35697_2.png) [@mmadlena](https://www.thethingsnetwork.org/forum/u/mmadlena)\
**Post date:** [December 31, 2021, 12:38pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/20 "2021-12-31T12:38:38Z")

</div>

Hi Nick, after some try and errors, I have been able to write a working decoder for the TEK 766 Sensor. Here below the code. With a Input “30000001010836008A00630168060070FFAA” (port:48) the output is :  
{  
“temperature”: -1,  
“ullage”: 112  
}

function decodeUplink(input) {  
var data = {};  
var temp = 0.0;  
var offset = 0;  
if (input.fPort==16)  
{  
data.ullage = (input.bytes[4] \<\< 8) + input.bytes[5];  
temp=input.bytes[6]  
if (temp\>50)  
{  
offset=256;  
}  
else  
{  
offset=0;  
}  
data.temperature = -(offset-temp);  
}

if (input.fPort==48)  
{  
data.ullage = (input.bytes[14] \<\< 8) + input.bytes[15];  
temp=input.bytes[16]  
if (temp\>50)  
{  
offset=256;  
}  
else  
{  
offset=0;  
}  
data.temperature = -(offset-temp);  
}

return {  
data: data  
};  
}

---

<div class="post-metadata">

**Author:** ![yreiser](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/y/779978/32.png) [@yreiser](https://www.thethingsnetwork.org/forum/u/yreiser)\
**Post date:** [February 24, 2023, 5:36pm UTC](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444/21 "2023-02-24T17:36:35Z")

</div>

I created an extended version of the payload decoder:

> **[GitHub - yreiser/tek766-ttn-decoder: TTN V3 Decoder for the Tekelek Tek 766...](https://github.com/yreiser/tek766-ttn-decoder)**
>
> TTN V3 Decoder for the Tekelek Tek 766 Ultrasonic Sensor - GitHub - yreiser/tek766-ttn-decoder: TTN V3 Decoder for the Tekelek Tek 766 Ultrasonic Sensor

[Next page](https://www.thethingsnetwork.org/forum/t/tekelek-tek766-payload-format/37444.md?page=2)
