TTN and Cayenne: how to do calculations

I just got the Dragino LDDS75 LoRaWAN Distance Detection Sensor and connected it successully to TTN, configured the payload decoder and can receive the sensors readings in Cayenne.

What I want to achieve with the distance sensor is to monitor the amount of fluid level in a tank. What I get is a distance reading to the surface of the fluid. So I need to do some calculations:


to get the amount of fluid in the tank.

Where is the typical place to do such a thing? Should I modify the Payload Decoder or is there any other place to do this kind of stuff?

Thank you in advance!

What do you mean by “receive the sensors reading in Cayenne”?
Are the sensor values encoded using the Cayenne format? Or are you watching the sensor values in a “Cayenne” dashboard or something like that?

In my personal opinion, the role of TTN should be primarily a data transport mechanism, to get the data from your node to your backend. I would put any validation, calculations, interpretations, etc in the backend application.

I can see a use case for the payload decoder to hide small differences in payload format, that (for example) occur because of historical reasons, different firmware versions in the field, etc.
But in my opinion it’s a mostly avoidable piece of software in the chain. It just adds extra work in version control, deployment, documentation, etc.

1 Like

I selected the LDDS75 hardware from the drop down menu (“Add new widget/new device”) and entered its DevEUI.

Not sure, to be honest. I think Cayenne gets the “raw data” from the device and “knows” how to interpret it.

Seems that packet decoder is not involved.

Okay. I got your point. Thank you very much!