Before I start, is this possible?

I have made an arduino based device that tells me how full my water tank is as a percentage.

I have written an AI2 app that lets me tell the Arduino to measure the percentage full, and then display the result on my phone.

I thought it would be nice if I could display the percentage full as a line (or bar) graph over (say) the last 10 days.

I imagine the best way is to store the values in TinyDB and then use the native graph functions to graph it. The question I have is do I just keep adding values to TinyDB, or somehow just keep the 10 values and refresh them.

Use case would be something like this: On starting the app, the graph displays with previous data. Once I measure the graph updates with the new percentage, and the database would update also.

Thoughts?

Hello Clark,

It is perfectly doable. Indeed the best way is the one you mention, saving the values ​​in tinyDB. You can then use AI2's graphics component or some extension if you want some more advanced capabilities.

As for the values ​​to be stored, if you want to keep only the last 10, you would add values ​​to the list until you reach 10, from that moment on, delete the oldest value (the first in the list) and add the new one.

In the Initialize block you can get the values stored in tinyDB and paint them in the graph. Once, you have the new value, then you need to update the list, store the new list in tinyDB and paint it again.

1 Like
1 Like

What would happen if I continued to add new entries to TinyDB without deleting any old values? In time, would my phone run out of space? Is there a utility whereby I can directly edit the values in TinyDB?

For sure, there will be a limit...infinite storage has not yet been invented. Anyway, you can store quite more than 10 percentages...

well, if you store a value over the same Tag, it will be updated...but if you are storing a list and you want to add/remove/change any element to the list, then you need to get the list, change it, and store it again.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.