PlatformIO Community

Arduino Nano RP2040 Connect, blinking RGB led does not compile

Hi, I have just started development with the new Arduino Nano RP2040 Connect board, installed the board and created the classic blink test project that blinks the built in LED. This compiles, and works as expected.
I then tried to use the built in RGB led, installed the WifiNINA library and write the following code:

#include <Arduino.h>
#include <WiFiNINA.h>
void setup() {
pinMode(LEDR, OUTPUT);
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(LEDR, HIGH); //RED
digitalWrite(LEDR, LOW); //RED

However this does not compile, giving errors:

c:/users/heikk/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: .pio\build\nanorp2040connect\src\main.cpp.o: in function setup': main.cpp:(.text.setup+0xe): undefined reference to pinMode(NinaPin, PinMode)’
c:/users/heikk/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: .pio\build\nanorp2040connect\src\main.cpp.o: in function loop': main.cpp:(.text.loop+0x26): undefined reference to digitalWrite(NinaPin, PinStatus)’
c:/users/heikk/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: main.cpp:(.text.loop+0x34): undefined reference to `digitalWrite(NinaPin, PinStatus)’

functions pinMode and digitalWrite should call overloaded versions with NinaPin argument, but what is wrong here ?
The code is taken from Arduino documentation and presumably works using Arduino IDE.

Probably an old version of WiFiNINA is used? The implementation is in

So try and use

lib_deps =
     arduino-libraries/WiFiNINA @ ^1.8.10

in the platformio.ini (from here).

I have version 1.8.10, so this is not the reason, my platform.ini:

platform = raspberrypi
board = nanorp2040connect
framework = arduino
lib_deps = arduino-libraries/WiFiNINA@^1.8.10

I’ve tried this and you are indeed correct. The problem is that PlatformIO doesn’t define a certain macro to let the code know it’s a RP2040 connect board.

It only defines

the problem is temporarily fixed by adding

build_flags = -DARDUINO_NANO_RP2040_CONNECT

to the platformio.ini.

A fix is proposed in Fix wrong board defines by maxgerhardt · Pull Request #11 · platformio/platform-raspberrypi · GitHub.

Thanks, I will be waiting for the fix, and adding build:flags to ini-file indeed help to get a successful compilation !