Why is dotostrf() not declared for the Arduino Nano RP2040 connect?

I am measuring some sensors using the Arduino RP2040 connect and when I try to print these variables to a string using dtostrf() I receive a compilation error saying that dtostrf() is not declared within the scope.
For example:

although this code compiles fine for any other Arduino board. Is there a specific reason dtostrf() was not included in the Arduino Nano RP2040 connect background header files?

Hi @bradley2020. dtostrf() is not a standard part of the C++ language. This is a convenience function provided by the avr-libc of the AVR architecture's toolchain:
https://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga060c998e77fb5fc0d3168b3ce8771d42

I think the reason is that the limited resources of the AVR chips make the additional overhead you would get from using the standard C++ sprintf too onerous.

Since this function is very common in Arduino code, the non-AVR boards platforms often provide such functions for portability, but declared in header files in a dedicated subfolder of the core library. So to use them, you must add an #include directive to your sketch for that header file:

#include <avr/dtostrf.h>
1 Like

Hi @pert, ah I see.
I have never used c++ outside of Arduino so I was confused at first, thanks for the info!

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per