Skip to main content
4 votes
Accepted

printf %s gives gibberish

(Community Wiki answer assembled from the comments) Noting that the standard Arduino core doesn't have a Serial.printf() function. The ESP32 core does. You need .c_str() in your calls. .printf() is a ...
4 votes
Accepted

Strange behavior from uint32_t, acting like signed int (Nano clone)

%d expects a signed int. %u expects an unsigned int. Insert the l modifier to expect a long in each of those cases. So you need a format code of %lu to print a uint32_t. The following code: #include &...
JRobert's user avatar
  • 15.4k
3 votes
Accepted

How to use a variable format in `sprintf`

sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but the latter is definitely ...
AnT stands with Russia's user avatar
2 votes

Formatting of IP address via printf(...) family similar to Serial Object

There is also a one-line solution just as you wish. Instead of String(ip) use ip.toString(). IPAddress ip = WiFi.localIP(); char *buf = malloc(128); sprintf(buf, "%s", ip.toString().c_str());...
adams13's user avatar
  • 21
2 votes

Strange behavior from uint32_t, acting like signed int (Nano clone)

*printf and bit-width specified types #include <inttypes.h> or C++'s #include <cinttypes> counterpart (when you have it; not on AVR-based Arduinos) gives access to macros defined for the ...
timemage's user avatar
  • 5,739
1 vote

Porting the FastNoise c++ library to Due

The workaround is in the issue found by Jot. In file C:\Users\aaaaaa\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\cstdio comment ...
Juraj's user avatar
  • 18.3k
1 vote

Formatting of IP address via printf(...) family similar to Serial Object

"%u.%u.%u.%u", ip & 0xFF instead of, should be ... "%u.%u.%u.%u", (ip>>0) & 0xFF,...
Malmo's user avatar
  • 11

Only top scored, non community-wiki answers of a minimum length are eligible