Using Serial.println with Rpi pico

I'm trying to print this function by using RPi pico 2040 ,

  void setup() {
   //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
 int value=256;   
 Serial.println("from sketch value %d  size %d\n",value,value*sizeof(double)); 

But I have this error! how can solve it?!

C:\Users\hp\Desktop\double\double.ino: In function 'void setup()':
double:45:94: error: no matching function for call to 'arduino::UART::println(const char [45], int&, unsigned int)'
Serial.println("from sketch value %d size %d\n",value,valuesizeof(double));
In file included from C:\Users\hp\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\2.6.1\cores\arduino/api/ArduinoAPI.h:31:0,
from C:\Users\hp\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\2.6.1\cores\arduino/Arduino.h:27,
from sketch\double.ino.cpp:1:
C:\Users\hp\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\2.6.1\cores\arduino/api/Print.h:77:12: note: candidate: size_t arduino::Print::println(const arduino::__FlashStringHelper
size_t println(const __FlashStringHelper *);

println is not printf. Arduino doesn't use printf. use multiple print statements

I used println.

Like the dude wrote it is not printf.

Serial.print( "from sketch value " );
Serial.print( size );
Serial.print ( ",value,value " );
Seriallprint( value * sizeof(double) );

or something like that.

yes that's right!!
when I use printf ("from sketch value %d size %d\n",value,value*sizeof(double));
I get on just 0, 1, 2
and printf doesn't printed .
Why do I have this problem with the Rpi pico ,
Where this method works well with ESP32 ?!

it not a problem.

ESP32 core is different..

log_i( "Hour:%d Azimuth %f, elevation %f, transit %dhr %dmin, dawn %dhr %dmin, dusk %dhr %dmin", rtc.getHour(true), x_eData.azimuth, x_eData.elevation, x_eData.TransitHr, x_eData.TransitMin, x_eData.DawnHr, x_eData.DawnMin, x_eData.DuskHr, x_eData.DuskMin );

<<< Printing from an ESP32.

on that would not work on esp32 either. there you would use printf as they added it to the core

Is there a method that I can use is similar to printf ?
I mean, I wanted to use one line and like this " "from sketch value %d size %d\n",value,value*sizeof(double)"


Well you could do

serail.println( "some words " + String(somevariable) + " some more words " + String(someothervariable) + "some more words " ) and get it all on one line.

Is calling functions different? I used

Serial.println(" before function");
 int value=256; 
size_t out;
 float *ar=(float*)malloc(value*sizeof(float));
unsigned char  bytes = function_trt(arr, out );
Serial.println("after function");

The output was only
"before function"
After upload the code , the output in serial monitor is just print
"before function " after that the COM be offline and then re printing
"before function " .... and so on...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.