Bad arguments to> the operation cannot accept the arguments: [ 34.36 ],…

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.

1 Like

I must clarify that I am new to this environment, I am not familiar with the /n theory, this variable datareceived is a string, my friend, which is equivalent to the temperature that is established as a limit, I did that block only to indicate by means of a led in the application that the oven is on when it passes that temperature threshold, but both that block and block four were made recently, the error in question occurred before adding these last two blocks (clock4 and clock 5)

CODIGO_CONTROL_DE_TEMP_BT_HORNO_.ino (1.9 KB)

friend I got lost in the middle of your explanation, it is a bit advanced for me, I am going to attach my arduino code so that you can verify what could be wrong in it, and I can keep up with it. Thank you very much I am also going to attach a photo about another question regarding the bluetooth client, I would like to know if that value (polling rate) that it brings by default is correct
bluetoothclient1

Check this

It sounds like you want to compare

[30.76 30.76] [31] > 31

that is wrong.

Your println()s look okay, one datum per line.

float temperatura;    //se definen las variables locales.
int pinlm35 = 5;      //El LM35 va conectado a una entrada anolgica, en este caso se define en 5
int Relepin = 8;      //El OPTOACOPLADOR va conectado a una salida digital, a la salida 8
String datorecibido; // Dato recibido que va a ser la temperatura que se establece como limite
int variableT = 0;

void setup() {
  Serial.begin(9600); //se activa el puerto serie comun del arduino
  pinMode(pinlm35, INPUT); //se configura el LM35 como entrada analoga
  pinMode(Relepin, OUTPUT); //se configura el Relay como salida digital
  digitalWrite(Relepin, HIGH);  //se establece desde un principio un voltaje HIGH, para evitar que el rele funcione.
}

void loop() {
  if (Serial.available())  {
    datorecibido = String("");  //se recibe el dato desde el bluetooth
    while (Serial.available()) {
      datorecibido = datorecibido + char(Serial.read()); //como el dato se recibe en forma de caracteres, 
      delay(1);                                         //se hace una especie de arreglo de estos para formar un entero
      variableT = datorecibido.toInt(); //Se convierte el dato recibido de String a Int
      temperatura = analogRead(pinlm35);  //se hace la lectura de la entrada analoga
      temperatura = 5.0 * temperatura * 100.0 / 1024.0; //se hace la conversion de la entrada analoga a un valor
      //de temperatura en °C, mediante la ecuacion dada
      Serial.println(temperatura);    //se imprime el valor de la temperatura
      delay(1000);      //el retraso será de 1 segundo

      if (temperatura > 31)   //Se programa para que cuando la lectura de temperatura sea mayor a 31, se desactive el rele
      {
        digitalWrite(Relepin, HIGH);
      }
      if (temperatura <= variableT)//Se programa para que cuando la lectura de temperatura sea menor a la temperatura recibida por el bluetooth, se active el rele
      {
        digitalWrite(Relepin, LOW);
      }
    }
  }
}

The next place to look is your blocks, to see if those readings pile up somewhere before your comparason to 31.

That's for when you graph the output directly in the new AI2 graph components.

Looking at your blocks, you should be receiving -1 bytes, not all the bytes in the buffer.

Change your blocks.

A sample:

Here is an updated blocks sample illustrating these ideas ...

BlueTooth_delimiter_sample.aia (3.4 KB) global message

(This sample expects 3 per line, I use it because I am in a rush. Just look for the -1/)

gd
Excuse me, friend, but does this have to be done with all the labels and texbox?

uuuu
Could you explain a little how this routine works, I had not used it before.

tttttt

And if you can explain this part to me, friend, what is it used for?

ururuuruuur

And finally I wanted to know, that value should be empty and why and what is that block used for (message)?

I had more time, so I made a simpler sample.

Here is a simple BlueTooth text receiver sample, for single value per line:
blocks
initialize global message to


That was for people who send multiple readings (temperature, humidity, etc.) in a comma separated row. You don't need that for your particular app.

A global variable is a good resting place for a piece of data, where you can apply the Do It debugging technique to see its value. That block gives it a name, and the required starting value should be compatible with how you plan to use that variable

  • plain text (empty text)
  • number (0)
  • list (create empty list).

See http://www.appinventor.org/bookChapters/chapter16.pdf
from the free book at
FAQ Section: Books, Tips, Tutorials for AI2


Hello dear friend, I am happy to inform you that thanks to your guidance I was able to solve the error in the pop-up window, there are only a few details that I hope can continue to guide me, when the temperature drops below the minimum hysteresis range, the digital output pin 8 is activated (oven on), but the indicator led in the app takes a long time to turn on (approximately 3 seconds), the shutdown signal does it quickly, and also the emergency stop button when pressed disconnects the system and then reconnects it, however grateful for your new orientations, the attached photo shows the new programming of the blocks

When using sensors, it is best not to use delay() as the sensor readings can become erroneous. Instead, use an elapsed milliseconds loop, like this:

CODIGO_CONTROL_DE_TEMPERATURA_BT_HORNO_UPTOS_2.ino (2.9 KB)
Compiles for Arduino Uno

  1. You did not tell us what microcontroller you are using - Make and Model
  2. You did not tell us the name of the Bluetooth Module

Sending data every second is really fast - is it necessary? The golden rule for reliability is to use the longest time interval that still meets the goal of the project.

I do not understand the use of 5 Clock Timers?

Your Sketch (.ino) is only sending one value, yet one Clock Timer and two Buttons are all receiving data via Bluetooth. It should only be the Clock Timer2 receiving the data. That timer should have a time interval approx 20% shorter than the Sketch time interval, so 800 milliseconds. It's best to have all the settings of all Clock Timers in the Blocks. When the App is Closed or the User is returned to Screen1, all Clock Timers must be enabled = false (this prevents the App from crashing).

How do I set the time of the timers friend?

I ran the application with the ino that you suggested but the delay to turn on the power indicator when the temperature drops remains the same, clocks 3, 4 and 5 are only for turning on the indicator led, but if you have a better suggestion for it I would be very grateful if you could share it with me

The two buttons that you indicate, I use them in my program for emergency stop and manual power on of the system, relieving the automatic control, these buttons should not receive bluetooth data, and excuse my lack of knowledge, thank you for your advice.

That modification is close to your suggestion.
?

Like this (an example only, not specific to your Project):

Yes, disable all Clocks when either swapping Screens or closing the App.

friend, is it also necessary to configure it here? Or is it only enough to do it on one of the two sides, or only on the blocks?

It is best to configure Clock Timers only in the Blocks.

solved this part thanks to all the experts who took the time to advise me. but
Now I need a little more of your valuable knowledge, I need to make a modification to the program that you are requesting, this consists of adding an emergency stop button that turns off the digital output that activates the oven (pin8) and another button to turn it on manual, these buttons must be activated at any time while the automatic control is executed through the sensor, but I get another error (arguments to< ) this time different from the previous one, here in the attachment the .ino almost completely redesigned
for this purpose, and the photo of the error, I am using the same app

codigo_tempertura_con_parada_emergencia.ino (3.9 KB)


note: if I have to make a new post for this query, please let me know