sprintf with floats for M0

Arduinos traditionally support C printf() but the cut-down version without f-p.
They expect you to use the C++ print() from Print.h

The overloaded print(float, prec=2) has a default precision of 2. So you can just say print(float)
If you want a different number of decimal places, use the full signature.
If you want to control width and precision, use dtostrf().

Some ARM cores use the full-fat version of printf(). After all, you have got plenty of Flash.

Most Arduinos can find dtostrf() by themselves. The M0 and Zero require you to specifically include the header. But the M0 and Zero come with full-fat printf() anyway.

STM32 ST Core has a cut-down printf() for compatibility.
STM32 stm32duino Core has full-fat printf()
ESP8266 and ESP32 have full-fat printf()

I did not try Due.

#if defined(ARDUINO_SAM_ZERO)
#include "avr/dtostrf.h"
#endif

void setup()
{
    Serial.begin(9600);
    Serial.println("print Floating Point on Arduino");
    Serial.print("regular Serial.print(1.234) ");
    Serial.println(1.234);
    char buf[40];
    Serial.print("sprintf(2.345) ");
    sprintf(buf, "%5.2f", 2.345);
    Serial.println(buf);
    Serial.print("dtostrf(3.456) ");
    dtostrf(3.456, 5, 2, buf);
    Serial.println(buf);
}

void loop()
{
}

Incidentally, dtostrf() is handy for formatting integers i.e. with prec=0.
Unfortunately, some cores don't use a proper dtostrf().

David.