Get max value from tinyDB?

Thank you for reply
about the arduino code i get the data from the sensor, into a string and then send it all to the app. O
n the app i split the string into 1 variable. what i want is to create a list from the values ​​of that variable over a period of time and pick the largest value in that list.
Code here:
c

That is also my orientation. I'm having a problem creating a list.

what problem?

1 Like

The values ​​are saved in the list as items and I don't know how to compare the values ​​of the items in the list. Can you help me?
this block error:
image

I don't see any problem with this block.
what error do you get?

this error:
image

Display the contents of your list in a label to see what's wrong with that list. You probably have empty values ​​in the list, without numbers...

Check your Arduino code to see if it's sneaking in extra messages that don't have numbers.

There is an if/then value block you can use to return true or false values for noncomparable list items and there is a IS A Number block that will identify garbage before you apply math in your max/min tests

image
If your global A like this, you will get a list ["","123"], empty string can not be comparing with 123

A garbage filtering comparator...

AND(
Is a number(num1),
Is a number (num2),
num1 < num2)

1 Like

You need to check if it's empty or not BEFORE you decidet to add it to the String/List.

2 Likes


this problem is done. but the block only compares 2 values at the moment when i press the button, I want to compare all the values ​​in the list. how?

as mentioned, you need to make sure the item is a number before add to the list.
then you will not need the 'is number' block in the comparator.

2 Likes

how to compare all the values ​​in the list. this block only compares 2 values when i press button :slightly_frowning_face:

remove the 'is number 'block

1 Like

It looks like you send three variables but you want the maximum value of the entire set of variables.

Send the text with "," instead of "|" for easier coding.

borrar_listaord.aia (3.6 KB)

1 Like

Code based on ABG-s Maximum ermitteln - (Get the Max Number from a List) - #9 by SteveJG

might help. See his draggable blocks in post 10 to the above link.

1 Like

Here is a filter to give you a list with only numbers:


2 Likes

Thank you so much, it helped me. Can I use 2 TinyDB in a app?

You can use multiple TinyDBs in the app.
If the NameSpace of the TinyDBs is the same, it will be the same TinyDB, example:
TinyDB1, NameSpace=TinyDB1
TinyDB2, NameSpace=TinyDB1 are the same TinyDB.

If they had different NameSpace they would be different.

1 Like