How can i compare variable or text with number?

Hello, i'm new one using app inventor. I'm connecting esp32 and app inventor with server firebase. From esp32, app inventor get sensor data integer number like 53 and float number like 2.26. I wanted to compare data sensor realtime from esp32 with 70-80 for integer and 5.00-7.00 for float. If sensor data is not in range 70-80 and range 5.00-7.00, i want to make background layout color to red. and then if sensor data is in range 70-80 and range 5.00-7.00, background layout color change to green.
But the app inventor layout doesn't turn red when the data doesn't match.
Please help me
mit app
mit app1
mit app2

Use blocks from MATH (not from TEXT) to compare two numbers, and use AND/OR blocks for combination of conditions .

1 Like

is it like this?but it doesn't work yet
mit app3

the error message shows that you are compare a empty string with a number

Hello rizqa

When you need to upload blocks for use to study, can you use this method please (result is clear and scalable): right -click in the Blocks work area:

download blocks

Snap1

Regarding the blank value comparison,
don't compare values that have not yet arrived.

If the incoming tag is this, only check values for this.
If the incoming tag is that, only check values for that.

1 Like

thanks for information.

i have tried it, but still the same problem in the smartphone app (like the previous picture)

oh okay, sorry can you give an example for a correct block?
i feel confused as to which block to use

According to the error I see, the nilai_ph.Text might be empty, as it is the only comparison with < which is compared to a decimal value 5.

Try your blocks like this in your Firebase.GotValue event

image

Empty textboxes cause the error....

3 Likes

thanks a lot

1 Like

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