Ubidots Community

Synthetic variable not efficient

Hi everyone.

I have a temperature sensor, which is uploading data every minute, and I wanted to take the derivative of the temperature (°C/H) using a synthetic variable.

The idea I had was to first smooth the temperature curve making a moving average, and then take the difference of this moving average by itself 20 minutes in the past, just to smooth even more the values, making some kind of secant line.

The code I made is this:

It worked perfectly, and after clicking on accept it calculated the last 1000 dots.
The problem is that after that, the synthetic variable doesn’t update, some times after many hours.
I don’t know if the problem is the complexity of the calculation, which I doubt it, or something that i did wrong with my code.

Here is the code:
a0 = mean( , “2T”)
a1 = shift(a0, -1)
a2 = shift(a1, -1)
a3 = shift(a2, -1)
a4 = shift(a3, -1)
a5 = shift(a4, -1)
a6 = shift(a5, -1)
a7 = shift(a6, -1)
a8 = shift(a7, -1)
a9 = shift(a8, -1)
avg1 = (a0+a1+a2+a3+a4+a5+a6+a7+a8+a9)/10
avg2 = shift(avg1, -10)

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Hi @Dante
thanks for sharing this with the community.

I’ll take a look at your formula from my end in order to check what could be out of place, however, I’d like to also check yours and the variable that is nurturing it, to this end, could you please advise your username?

Hi @sergio, thanks for your reply.

Yes, my username is DanteRocket.

Thanks for your reply Dante. I’ll take a look at your synthetic variables and get back once I have a more solid answer.