Float ArrayNot Working As Expected

Hi All,
I have been trying to understand the crazy logic behind Receiving Float data from a Arduino device. I have a device that sends a float value every 1 second. The first float value is X and the second is Y. When the values are received they are attempted to be put in different text boxes for display to a user. The code snippet attached seems to put the same value in both boxes always no matter how I slice this onion. My code logic in theory should receive floats until the count reaches >=2 then grab the correct indexed value from the float array list and stick it in the right text box. I am sure it is me being stupid somehow. Has anyone ever seen this issue be


Error_AI2
fore, and if so how did you correct it? Any help would be greatly appreciated.
Thanks,
Hillbilly

error clearly says, your target item is not a list. It means 1.64678 is not a list. Where as if you block called split the text at "." (dot) , then you will get it as list item like ["1","64678"] and you can use select list item list

 index will give you 1
index 2 will give you 64678

Hi,
Thanks but the number shown is only the first float that is received. The second float has not arrived yet. It would be something like (1.6435 then 72.12). After the two floats are received they would repeat again. I am measuring voltage and temp on some Hardware. What I need is the float array to store both values then put values in each text box. After that clear the float array counter and overwrite the next two incoming float values into the two element array again so they can be updated.
Thanks,
Hillbilly

Will it work for you? if it have single float whichmean less than 9

Thanks I will look into it. I just hate to have to use the value as a determinate for where to stick the floats in case I need to add more floats down the road. I was hoping someone knew why indexing floats in a list does not seem to work right. The Bluetooth LE does not appear to have a single float option like the Classic Bluetooth does.

I understand your concern now.

in the circled place try like this

image

this block wont throw such error again with all increment

I tried the suggestion earlier and still got errors. I decided to break this down as simple as I could for now and do what you suggested earlier on comparing the value as a decision maker. It seems that the float coming in is not being read as a number for some reason even though I know it is being sent as a float from the Hardware side using the BLE stack. I listed the code below from my ESP32 device. For some reason the float has brackets around it and I am guessing this messes up the math logic compare. Is there a way to compare the number only to the constant 2. I could not upload a picture for some reason.
Thanks,
Hillbilly

ESP32 Code:
float t = (TempRead * 9 / 5) +32;
float voltage = ((ADCValue / 4096.0) * 3.3);
pTxCharacteristic->setValue(t);
pTxCharacteristic->notify();
delay(1000); // Reduce transmission frequency
pTxCharacteristic->setValue(voltage);
pTxCharacteristic->notify();

delay(2000);  // Reduce transmission frequency

Continued:
I modified the block to count how many times it is executed between floats being sent. It seems to run really fast so I suspect this is part of the issue. Is there any way to slow down the block to only evaluate when a new float is received?

Trying to receive different float values on the same characteristic is a recipe for madness.

Coordinating that is very hard, as you have seen.

You have two alternatives, at least:

  1. Use two different characteristics, one for Voltage and the other for Temperature.
    When FloatsReceived, test the incoming characteristicUuid to see which Label should get the incoming float in item 1 of the list floatValues. (Use a Select List Item block, because it will be a list, regardless.)

  2. Switch from float to Text, adding prefixes to each item, like "T:" or "V:" and test incoming text using the text Contains block, to see what arrived.

image

This is more direct, and does not add a "[" in front of item 1.

Thanks for the suggestions. I am still trying to peel this onion. It appears to me that the create list and insert list only ever stores one float variable for some reason. I would think if I gave it a index and value it should store at least two or more. Not sure I understand this block.

If I try to index more than 1 it kicks out this error
image_2025-05-19_112545954

Read the introductory articles on lists at

Understand that AI2 lists are Linked Lists, not Arrays.

I will thank you. Is there a array block available to use instead?

No, but you can create a fixed list using a create list block, with as many sockets as needed, fill the sockets with values , and refrain from removing them or adding new items.

Thanks for the update. I am still trying to figure out a easy way to solve this complex issue. It seems that values can indeed be stored in the list correctly, but accessing them is another story. I modified my BLE block to count the items stuff into the list and they appear to be shoved in at a rapid rate as expected since the When BLE block is fast. My confusion is why I can not access a index reference > 1 when the list is growing as expected. A good challenge I must like :slight_smile:


floatValues is a list.

Hence the square JSON brackets.

There is no need to keep a separate Count variable, and it only muddies the waters.

Use for indices Length of List and Length of List - 1, from your growing list where you pile up the readings.