Hello, i am trying to convert floats by rounding and converting values to one decimal point. like 1.66 to 1.7 somehow values 9 and 10 are empty and i dont know where is my error here? my setup esp32 dev board and arduino 1.8.19 ide.
char value1[4];
char value2[4];
char value3[4];
char value4[4];
char value5[4];
char value6[4];
char value7[4];
char value8[4];
char value9[4];
char value10[4];
char value11[4];
unsigned long serialLastUpdate;
const unsigned long serialRefreshIntervalue = 500;
String values; // all values combined together
void setup() {
Serial.begin(115200);
}
void loop() {
float roundedFloat1 = round(1.12 * 10) / 10.0; dtostrf(roundedFloat1, 3, 1, value1);
float roundedFloat2 = round(2.12 * 10) / 10.0; dtostrf(roundedFloat2, 3, 1, value2);
float roundedFloat3 = round(3.12 * 10) / 10.0; dtostrf(roundedFloat3, 3, 1, value3);
float roundedFloat4 = round(4.12 * 10) / 10.0; dtostrf(roundedFloat4, 3, 1, value4);
float roundedFloat5 = round(5.12 * 10) / 10.0; dtostrf(roundedFloat5, 3, 1, value5);
float roundedFloat6 = round(6.12 * 10) / 10.0; dtostrf(roundedFloat6, 3, 1, value6);
float roundedFloat7 = round(7.12 * 10) / 10.0; dtostrf(roundedFloat7, 3, 1, value7);
float roundedFloat8 = round(8.12 * 10) / 10.0; dtostrf(roundedFloat8, 3, 1, value8);
float roundedFloat9 = round(9.12 * 10) / 10.0; dtostrf(roundedFloat9, 3, 1, value9);
float roundedFloat10 = round(10.12 * 10) / 10.0; dtostrf(roundedFloat10, 3, 1, value10);
float roundedFloat11 = round(11.12 * 10) / 10.0; dtostrf(roundedFloat11, 3, 1, value11);
values = String(value1) + "| " + String(value2) + "| " + String(value3) + "| " + String(value4) + "| " + String(value5) + "| " + String(value6) + "| " + String(value7) + "| " + String(value8) + "| " + String(value9) + "| " + String(value10) + "| " + String(value11);
serial();
}
void serial()
{
if (millis() - serialLastUpdate >= serialRefreshIntervalue) {
serialLastUpdate = millis();
Serial.println(values);
}
}
serial output i am getting is
"1.1| 2.1| 3.1| 4.1| 5.1| 6.1| 7.1| 8.1| | | 11.1"