Post by roniin » Sun May 17, 2020 3:19 pm

Code: Select all float f; String s; void setup() { Serial.begin(9600); f = 1.23; } void loop() { char buforS[9]; dtostrf(f, 7 ,2 , buforS); //s = String(f, 2); //Serial.print(f, 4); }

In my program I have to convert the Float variable to String. I know two methods in Arduino. I was surprised by the memory consumption needed for this! Summary of my tests:1. STM32F103C8, Official core 1.9.0 Compilation of an empty sketch.Flash 9760 (14%), Ram 820 (4%)2. STM32F103C8, Official core 1.9.0Flash 14240 (21%), Ram 820 (4%)3. STM32F103C8, Official core 1.9.0Flash 14412 (21%), Ram 820 (4%)4. STM32F103C8, Rogers core 2020.5.16 Compilation of an empty sketch.Flash 18356 (28%), Ram 4256 (20%)5. STM32F103C8, Rogers core 2020.5.16Flash 34536 (52%), Ram 4312 (21%)6. STM32F103C8, Rogers core 2020.5.16Flash 34728 (52%) Ram 4312 (21%)7. Arduino Nano V3 (ATmega328P) Compilation of an empty sketch.Flash 2774 (9%), Ram 202 (9%)8. Arduino Nano V3 (ATmega328P)Flash 4298 (13%), Ram 206 (10%)9. Arduino Nano V3 (ATmega328P)Flash 4576 (14%), Ram 206 (10%)In summary, when I use the Official Core, the dtostrf command takes 4480 bytes, the second method s = String (f, 2); takes 4652 bytes.But if I use Rogers core, the dtostrf command takes 16180 bytes, s = String (f, 2); 16372 bytes.Similarly for Aurduino Nano V3: 1524 bytes, and 1802 bytes.Is there any other way to do this conversion? The one that won't eat 16KB? Using Arduino and STM32F103C8, I have a lot of RAM, but 64KB Flash is very low. Especially with the Rogers core.