I enter this text in the terminal of the arduino IDE
text -> 2023-03-24 17:50;10180049;100;20190306;40;100;4;8;A;0;35;a;12.8;A;0;35;c;12.8;A;0;35;h;13.3;A;0;35;l;12.1;B;0;11;a;4.0;B;0;11;c;4.2;B;0;11;h;4.4;B;0;11;l;3.3;236C
what I do is detect the value of the variables a, c, h, l that is embedded in the text
when I print the variables there is no problem it shows me all the variables:
void loop() {
while (Serial.available() > 0) {
char c = Serial.read();
if (c != '\n') {
if (light != false) {
if (c != ';' && !isspace(c)) {
data += c;
} else {
if (index == 0 && data != "RS") {
light = false;
} else {
if (index == 1) {date = data;}
if (index == 2) {hour = data;}
if (index == 3) {retri_id = data;}
if (index == 4) {retri_charge = data;}
if (index == 5) {pub_id = data;}
if (index == 7) {pub_charge = data;}
if (data == "A" || data == "B" || data == "C" || data == "D") {port = data;}
if (data == "a" || data == "c" || data == "h" || data == "l") {
variable = data;
light_var = true;
index_var = index + 1;
}
if (light_var == true && index == index_var) {
value = data;
light_var = false;
light_up = true;
}
if (light_up == true) {
Serial.println(value);
light_up = false;
}
data = "";
index++;
}
}
}
} else {
data = "";
index = 0;
light = true;
Serial.println("... Finish");
}
}
}
but when what I do is first form a string and then print it in if (light_up == true) {} , it doesn't print all of them:
if (light_up == true) {
//Serial.println(value);
String urix = date + "|" + hour + "|" + retri_id + "|" + retri_charge + "|" + pub_id + "|" + pub_charge + "|" + port + "|" + variable + "|" + value + "\"";
Serial.println(urix);
light_up = false;
}
What can be ?