Select list item : list index too large

Hello everyone,
I create an app using to read measurement from Arduino. The application is reading from 4 Humidity and temperature sensors but its shows a message I provided in the attachment. I need help


Thank you

1 Like

Please also attach your Arduino code.
Use ``` above and below the code if inline.

Also show us your Clock1 Timer attributes and your BlueTooth Client attributes.

You ask for 9 list items, but you say you only have 4 or 5 readings?

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.

Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

ReceiveText(numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.

According to our application for each sensor there are 2 readings , Temperature and Humidity. and CO2 emission. So 9 readings will appear on the app.
Thank you

Hello Abdu

Can you clarify that in a list that shows which sensor delivers what? According to your first post:

4 Humidity and temperature sensors

So that is 8 sensors plus one C02 sensor? Humidity and Temperature Sensors send two values each? That would be 17 values at a time. None of that sounds correct......

Still awaiting that code.

My problem were solved.
Thank you guys

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