Ubidots Community

[SOLVED] Accumulative Variable

Hey, i’m having a problem holding a value in a variable. I need to create a variable to add the values of a current sensor, those values are sent once every minute and i need so accumulate the result.

Hope someone can help me with this issue. Thanks.

1 Like

Hello @evrdaniel,

A rolling window variable will help you with it. Go to your device and create a Rolling Window Variable :

Then select Device > Current Sensor Variable > Sum > Every 1 Minute > Select the Start Date > Finish. Assign a name to the new variable and that’s it! You’ll have a variable which accumulate the needed result.

I hope this would help you,
Best Regards.
Maria C.

1 Like

Hey, I’ve already tried this but it didn’t worked. The variable doesn’t make the addition or even save it, it just keep updating the last value i get from the sensor.

I’ll attach two pictures showing the hour to let you see that it’s not updating correctly.

Hello @evrdaniel,

The rolling window variable will accumulate the values received on the variable selecting every time you setted, in this case it will accumulate the values every one minute.

As you can see on the images below, I’m sending the variable “test = 2” every second to Ubidots.

I created two rolling window variables to verify that the result is okay. First, I created a rolling window variable to sum the values received at “test”, and another to count every data point received during one minute.

As you can see the count-test variable received 53 data points during the minute:

So, the sum-test variable accumulate the sum of the 53 data point received, thats mean if the test value is equal to 2 the accumulated value will be 106

As you can see I made the test and everything works fine! To get a better a idea how the variables works, take a look of this video.

Maria C.