I think I've specified this before but I will say it again, maybe I explained it poorly. The only data I have to send are the temperature and humidity. I don't need to serial.print() led_color, led_value etc. as for those are values that arduino has to Serial.read() from the phone digits. That part works just fine. It's the part where I wanna trigger an alarm whether the temp value is greater than the temp max value I set from the phone or not (and same goes for temp_min,hum_max,hum_min) that doesn't work, and I get that error about the list length that equals 0. I already fixed the correct proportion between arduino clock and the app clock, so I don't think that's the issue. This is the error I get, and for any other thing, I sent both the sketches above.
If you don't need it, don't send it. Remove it from the code ...
This part of the arduino code sends unnecessary data to the phone, the app receives it and creates a wrong list. By clicking on the button, you are trying to download the second item from the list that does not exist, because the app took garbage from arduino and overwritten the list with garbage.
How can I remove it though? That's the part I need to make the led section work. Plus, I didn't think it sent arduino data as it only reads data incoming from the phone, through Serial.readStringUntil(). Either way, I need this part for the program. I will send the updated code once again since I've also sent older sketches and you might have got confused.
bluetooth_automation.txt (8.6 KB)
What it is? And why do you send it via bt to the app, if you don't receive this data in the app?
}
if (Serial.available() > 0) {
led_color_str = Serial.readStringUntil(';');
int led_color = led_color_str.toInt();
Serial.println(led_color);
switch(led_color){
case 1:
int led_value = Serial.read();
led_value = map(led_value,0,100,0,255);
Serial.println(led_value);
analogWrite(9,led_value);
break;
}
Exactly that:
Serial.println(led_color);
and that:
Serial.println(led_value);
The fact that you set the brightness of the led I understand. But why are you sending it back to the App?
Wait, I think I got something wrong by copying the sketch, I'll send it again shortly.
Nevermind that file, I mistakenly copied it twice and some parts of the program appeared where they shouldn't have. Now look at the one I just sent
This is the correct one.
Yes, it should work, have you tried with the App?
That's the sketch I used to test it and it gave me that list error. It's probably a silly one, now @ABG is checking the App sketch
These are draggable replacement Click events that will prevent the Select List Item error messages ...
P.S. These blocks can be dragged directly into your Blocks Editor workspace.
I found a bug in your blocks. In the clock component, remove the block that sets Sensor_Data to "epty list".
This will protect the program but still won't work because its list is still empty, reset by the clock.
Okay, I will try all of what you two told me tomorrow, thank you!
Okay, I've done this and it works just fine! Thanks! Should I add also what @ABG suggested or are these 2 different approaches to the problem?
Plus, I've just noticed a problem that comes up with the excessive amount of Serial.readStringUntil(). I tried controlling the leds by fluidly sliding the thumb on the slider and I experienced a massive delay in the response, and once I disabled the temperature and humidity Serial.readStringUntil() , it started working again. Is there any way I can correct this? Perhaps I could divide the two blocks but I don't know how since the condition is always if(Serial.available())
bluetooth_automation.txt (7.9 KB)
You can add these security features. In case the list breaks down somehow.
You have a lot of delays of 500ms in the program.
The best program is one that works without "delay()";