Cant print in serial monitor with Raspberry Pi Pico W

Hello, I am not new to arduino but it is the first time I try a Raspberry Pi Pico (here the W version).

I can properly upload a sketch (it blinks).
However I really do not find a way to have a working serial connection.

Config : Ubuntu with Arduino IDE 2.0.3 and Raspberry Pi Pico W

I tried a simple sketch :

void setup() {
  pinMode(LED_BUILTIN, OUTPUT); // to blink for debug
  Serial.begin(9600);
  while(!Serial)
  {
     // blink slowly
  }
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  // blink fast
}

Test 1 :
With that code the sketch is well uploaded but it stays in the while(!Serial) because it blinks slowly.
It does not change if I close or open again the monitor. I also tried to disconnect the board.

Test 2 :
I changed Serial to Serial1. It is better : it goes into the loop() and blinks fast.
But i see nothing in the monitor !
The monitor seems correctly configured (tested /dev/ttyACM0 and 1) and at 9600.
I also tried minicom -b 9600 -o -D /dev/ttyACM1 (ACM0 and ACM1) in a linux terminal

So I am a bit lost, Serial1 manage to connect but nothings comes...

I would be very happy if someone had an idea of what I can do :slight_smile:

Thanks !!

So that means posting in a section reserved for just getting the IDE working is not the right place to post. I have moved your post here.

Pleas read the getting the best from this forum sticky post at the start of each section.

You need to supply more information.
What framework are you downloading to get the Pi Pico available for selection? There are two you can use.

Why have you not use the examples this framework gives you for the led blink code?

1 Like

Thanks for moving my post ! I read the "getting the best" thank you.

Framework :
I installed "Raspberry Pi Pico/RP2040" by Earle F. Philhower, III version 2.6.5 in the board manager.

Code example :
I took the blink example in File/Examples/Basics/Blink. So I believe it's the generic example (not only for this framework) but it works.

Then I took the File/Examples/Basics/AnalogReadSerial which was not working so I mixed the two examples to be able to debug without serial monitor.

Here is the complete latest code :

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // initialize serial communication at 9600 bits per second:
  Serial1.begin(9600);
  while (!Serial1) {
    digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
    delay(1000);                      // wait for a second
    digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
    delay(1000);
  }
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial1.println(sensorValue);
  delay(1);                         // delay in between reads for stability
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(100);                       
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(100);
}

With that code I see the led blinking every ~100ms but I do not see anything in the serial monitor.

Thanks :slight_smile:

If you connect to the board with USB, you should use Serial, not a Serial1.

Your blink code blinks slowly because you didn't open Monitor with correct terminal port.
Unfortunately, as far I know, the RP2040 driver is incompatible with recent linux kernels. I couldn't get it to work with RP2040 on Fedora35.

Some info regarding the issue:
https://forums.raspberrypi.com/viewtopic.php?p=1958770#p1958770

1 Like

Moving to Windows 10 and using Serial (not Serial1) fixed the issue !

Thanks a lot @b707 and @Grumpy_Mike for helping me clarify and then solve my problem :slight_smile:

I hope the issue with linux will be fixed...

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