I am trying to write float variables in my ST7565 display using a Zero Board.
I am aware fo the Arduino libraries limitations with the sprintf function, It does not work using floats in both architectures AVR and SAMD, because it requires much memory resources in an embedded environment.
The usual solution for displaying floats in Serial/Displays are working with integer values, or using the dtostrf to convert the floats into char.
The dtostrf function is not available for the Arduino SAMD architecture and you need to include a bizarre include in the code: avr/dtostrf.h, as reported in this forum.
My problem is that I can not convert floats into char using dtostrf. As an example, the following code returns empty spaces in the place of the float variables:
#include <avr/dtostrf.h> // dtostrf missing in Arduino Zero/Due
char buffer[20];
void setup() {}
void loop() {
double a = 12.345;
char aChar[8]="";
dtostrf(a, 2, 2, aChar);
sprintf(buffer, "LCD Value: %s", aChar);
SerialUSB.print(a);
SerialUSB.print("\t");
SerialUSB.print(aChar);
SerialUSB.print("\t");
SerialUSB.println(buffer);
delay(1000);
}
What Am I doing wrong?