Unable to read sensor values on the app

I checked the TimerEnabled setting with a TimerInterval of 2000 ms. The pressure values now appear on the app updating at every 2000 ms [Thanks to ABG]. In this iteration, the shortfloat setting was set to false. However, when I set the shortfload setting to true, some random values [-0.00067,160000], [495001856, 200000],.... were appearing.

But the problem now is that both values are of sensor A, but just for a fraction of a second, both values are of sensor B. I think I am unable to use the BLE FloatsReceived block correctly. Is there a way to distinguish between the float values of the two sensors? I am attaching my updated blocks.

I was also getting a Runtime Error "No connection with a BLE device" when I turned on the TimerEnabled setting. So I added a block [when BluetoothLE1.RssiChanged, set TimerEnabled to true] which solved the Runtime Error problem.

Thank you, Uskiara. I will also try this tactic. By enabling the clock timer, the float values are now visible on the app but the my blocks are not able to distinguish between float values of the two sensors. I think it will be easier to distinguish them if I convert them to string as you suggested.

Dear @Ahmed_Zaidi,
I've just had a quick look to your .ino.
If you convert the sensor values from float to string, you can put before the value a header like "A:" + valueA and "B:"+valueB. In this case it will be easy in your app to differentiate the two values. When the app receives a string it will search for a matching characters pair "A:" or "B:" an decide accordingly where (in which label) to display the value.

1 Like

The problem is in the floats received event block.

The event block is trying to tell you about the incoming float with those four local variables, but you ignore the one that tells you which stream of floats it came from.

Instead, you were using some out of sync global.

1 Like

Thank you ABG! I think I understood what you are suggesting and I am getting closer. I am attaching some pictures. The old .FloatsReceived block looked like this [old image attached]:

When I try to select from different options, I see this [Options image attached]:
Options

I do not see distinct floatValues of the two sensors. So I had to select the 'floatValues' which is what I think you are refering to 'out of sync global'. Is this true?

Thank you again,
Ahmed

Screenshot_20240314_074413_DuckDuckGo

If A = A always will be true... same for B = B...
try this

Taifun


Thank you Taifun! I just tried this [please check in the attached, whether I did what you suggested] but I see the characteristic UUID values in the sensor value.


If I use it like attached image, I still see sensor A values in both the labels updating at the clock's time interval. But just for a millisecond, I see sensor B values in both the labels.

Yes, this looks correct

Can you elaborate?
It might be a good idea to display all 3 local variables from the FloatsReceived event in labels to better understand what is going on

Taifun



Using this block, I am getting nothing in label A and B, but the new 3rd label [label 14] is showing correct pressure value.

To debug correctly, do not use if statements and use new labels to display all 3 values

My guess is, you additionally have a clock running, which overwrites SensorA.Text and SensorB.Text

Also you still did not understand, that comparing the same value results always in true...
A = A
characteristicUUID = characteristicUUID

Taifun

1 Like

Thanks a lot Taifun! I changed the blocks like this:


And on the app, I see this:

After 2 seconds, the value in the red block of sensor B changes to 0001 and the Sensor C value shows the value of second pressure sensor just for a fraction of a second. I think the problem is also in this block below:

In the Clock.Timer event you read A and then B
Which means in the FloatsReceived event you first get A and then B

Taifun

1 Like

You need an if/then test on characteristUUID to decide which Labels.Text get the incoming floats.

By the way, since it is a list, it will appear in brackets , which you can avoid by selecting item 1 of the list.

1 Like

I am trying to do the if/then test on characteristUUID like this:


And the timer block looks like this:

The output is as follows:
Sensor A: Nothing
Sensor B: Nothing
Sensor C: alternating value of sensor A and sensor B at timer's interval

I think the equality operator in the FloatsReceived block is not working.

The blocks look fine
We already talked about debugging...

As test use a label to display characteristisUuid and 2 more labels to display the 2 global variables

Taifun

1 Like

Like this?



For a fraction of a second, the value in the black box becomes 0001 and so does the value in the red box which at that moment displays sensor B's actual value. Thank you.

I think I found the problem, @Taifun. The characteristicuud has a small 'a' in '181a' while the characteristicuuid of sensor A and sensor B has a capital 'A' in '181A'. This might be the reason why the if/then logic is not working.

1 Like

@Taifun , @ABG and @uskiara Thank you for sharing your ideas to solve my problem. Instead of comparing the characteristicuuid with characteristicuuid of sensors, I directly campared the characteristicuuid with actual values with lower case a. But I wonder why is the timer block changing UUIDs to lowercase letters?

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