The Operation < cannot accept the arguments: , [""], [5]

I checked to see if there was a question like this specific for the MIT app and some were close but did not address the issue. I tried something with a previous help suggestion: the arduinoBluetoothClient = PollingRate from 0 to 10, but did not work.

The short code with the error is attached.

How can I fix this?
Appreciate the help.

Thanks,
Richard

You forgot to check, if BytesAvailableToReceive is > 0. .
Only if you received something, you can check if the temperatur is < 5....

Taifun

1 Like

Thanks for the reply.

I do not get what you mean.

I do not see any "purple" blocks to add after .BytesAvailableToReceive for a >0.

Thanks,
Richard

Use an if block from the control drawer...
See the clock.timer event here App Inventor Tutorials and Examples: Bluetooth Chat | Pura Vida Apps for an example

Taifun

Hello Richard

Here is an example file that you can copy from (via Backpack), to make your code more robust. Note for example that you must set a Delimiter Byte to tell the App where the end of the data is.

BT_Basic_Setup_ReceiveOne.aia (7.6 KB)

You must also ensure that the App time interval is approx 20% faster than the Arduino time interval to ensure the App can process the data packet before receiving the next one. Note that the Arduino time interval should be as long as is practical for the goal of the App to be met. Since you are receiving a sensor reading, use a millisecond time lapse to control the Arduino time interval, rather than a delay() - delay() can have a negative effect on the accuracy of the sensor reading.

The error you are receiving is, in cases like this, usually related to what is being sent by the Arduino - the message implies that there may be two values being sent in one data packet. If you are not sure (perhaps you didn't write the Arduino Sketch yourself), upload the .ino file to your Topic (the file, not the text of the file).

1 Like

Here is my standard Delimiter advice, in case the previous posts missed something ...

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.
BlueToothClient1_Properties
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.

2 Likes

Thanks for the response!!
Even though you have an image, I am still lost with compared to what I have.
Thanks,
Richard

Thank you for the response, but I do not understand it.

Within the code [not the blocks in the MIT App Inventor] I have this below but the error seems to me I need to modify something at the Block area.
Thanks,
RichardM

*/
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is connected to the Arduino digital pin 2

#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
unsigned long previousMillis = 0;
const long interval = 5000;
void setup() {
// Start up the library
sensors.begin();
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// Call sensors.requestTemperatures() to issue a
// global temperature and Requests to all devices on the bus
sensors.requestTemperatures();
// Celsius temperature
// Why "byIndex"? You can have more than one IC
// on the same bus. 0 refers to the first IC on the wire
Serial.print(sensors.getTempCByIndex(0));
//Fahrenheit temperature
//Serial.println(sensors.getTempFByIndex(0));
}

}

@ABG was explaining in detail, what you should do

You might want to follow his advice and if there are still issues, post again a screenshot of your relevant blocks

Taifun

Thanks for the comment. I do not find how to add those comments in the blocks or change it to that...couldn't find the specific blocks. Not sure how to proceed.

It looks like you do not understand what we are suggesting... I therefore recommend you to take a step back to first learn the basics and after that continue with your project...

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Tutorials for MIT App Inventor to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Okay, thanks!!!