I'm currently trying to convert a double into a character array for transmitting.
//Declaration of character array char stroutPart; //Calls function to shift, convert and get the original value into the correct form double particleDouble = convertShiftVal("Particle"); //Convert double to character dtostrf(particleDouble,6, 2, stroutPart);
After the convertShfitVal function has been called I receive a double value that in the range 1.11 up to 12345.67. The problem seems to be with the size of the "dtostrf()" function. I had 6 in there but it can vary from 4 to 8 and I can't figure out how to make this dynamic.
I have tried things like particleDouble.length() and also sizeof(particleDouble) in the following way:
//Convert double to character dtostrf(particleDouble,particleDouble.length(), 2, stroutPart);
//Convert double to character dtostrf(particleDouble, sizeof(particleDouble), 2, stroutPart);
but neither of these approaches seem to work and only give fixed values rather than dynamic ones. Just wondering is there some way I can inform the function of the number size before it runs?