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.
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)
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
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 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
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
You did not tell us what microcontroller you are using - Make and Model
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.
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).
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.
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