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
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.
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.